From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 9EA8625747 for ; Tue, 23 Jul 2019 14:00:49 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id i6AvCaCqNMpr for ; Tue, 23 Jul 2019 14:00:49 -0400 (EDT) Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 2C29A25741 for ; Tue, 23 Jul 2019 14:00:48 -0400 (EDT) Received: by mail-wm1-f51.google.com with SMTP id s15so17934280wmj.3 for ; Tue, 23 Jul 2019 11:00:48 -0700 (PDT) MIME-Version: 1.0 From: Maria K Date: Tue, 23 Jul 2019 21:00:35 +0300 Message-ID: Subject: [tarantool-patches] [PATCH] Output of fiber.info will contain only non-idle fibers Content-Type: multipart/alternative; boundary="000000000000e3f7dd058e5cf8ff" Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: georgy@tarantool.org --000000000000e3f7dd058e5cf8ff Content-Type: text/plain; charset="UTF-8" The output used to be too cluttered due to idle ones. Closes #4235 --- src/lib/core/fiber.c | 3 ++- src/lib/core/fiber.h | 10 ++++++++++ src/lib/core/fiber_pool.c | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/core/fiber.c b/src/lib/core/fiber.c index ce90f930c..b1d7a5be2 100644 --- a/src/lib/core/fiber.c +++ b/src/lib/core/fiber.c @@ -1411,7 +1411,8 @@ int fiber_stat(fiber_stat_cb cb, void *cb_ctx) struct cord *cord = cord(); int res; rlist_foreach_entry(fiber, &cord->alive, link) { - res = cb(fiber, cb_ctx); + if (!fiber_is_idle(fiber)) + res = cb(fiber, cb_ctx); if (res != 0) return res; } diff --git a/src/lib/core/fiber.h b/src/lib/core/fiber.h index fb168e25e..d05132a8d 100644 --- a/src/lib/core/fiber.h +++ b/src/lib/core/fiber.h @@ -97,6 +97,10 @@ enum { * This flag is set when fiber uses custom stack size. */ FIBER_CUSTOM_STACK = 1 << 5, + /* + * + */ + FIBER_IS_IDLE = 1 << 6, FIBER_DEFAULT_FLAGS = FIBER_IS_CANCELLABLE }; @@ -620,6 +624,12 @@ fiber_is_dead(struct fiber *f) return f->flags & FIBER_IS_DEAD; } +static inline bool +fiber_is_idle(struct fiber *f) +{ + return f->flags & FIBER_IS_IDLE; +} + typedef int (*fiber_stat_cb)(struct fiber *f, void *ctx); int diff --git a/src/lib/core/fiber_pool.c b/src/lib/core/fiber_pool.c index 77f89c9fa..c04141e63 100644 --- a/src/lib/core/fiber_pool.c +++ b/src/lib/core/fiber_pool.c @@ -72,8 +72,10 @@ restart: * Add the fiber to the front of the list, so that * it is most likely to get scheduled again. */ + f->flags |= FIBER_IS_IDLE; rlist_add_entry(&pool->idle, fiber(), state); fiber_yield(); + f->flags &= ~FIBER_IS_IDLE; goto restart; } pool->size--; -- 2.21.0 --000000000000e3f7dd058e5cf8ff Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
The output used to be too cluttered due to idle ones.
<= br>Closes #4235
---
=C2=A0src/lib/core/fiber.c =C2=A0 =C2=A0 =C2=A0| = =C2=A03 ++-
=C2=A0src/lib/core/fiber.h =C2=A0 =C2=A0 =C2=A0| 10 ++++++++= ++
=C2=A0src/lib/core/fiber_pool.c | =C2=A02 ++
=C2=A03 files changed= , 14 insertions(+), 1 deletion(-)

diff --git a/src/lib/core/fiber.c = b/src/lib/core/fiber.c
index ce90f930c..b1d7a5be2 100644
--- a/src/li= b/core/fiber.c
+++ b/src/lib/core/fiber.c
@@ -1411,7 +1411,8 @@ int f= iber_stat(fiber_stat_cb cb, void *cb_ctx)
=C2=A0 struct cord *cord =3D c= ord();
=C2=A0 int res;
=C2=A0 rlist_foreach_entry(fiber, &cord-&g= t;alive, link) {
- res =3D cb(fiber, cb_ctx);
+ if (!fiber_is_idle(= fiber))
+ res =3D cb(fiber, cb_ctx);
=C2=A0 if (res !=3D 0)
=C2= =A0 return res;
=C2=A0 }
diff --git a/src/lib/core/fiber.h b/src/li= b/core/fiber.h
index fb168e25e..d05132a8d 100644
--- a/src/lib/core/f= iber.h
+++ b/src/lib/core/fiber.h
@@ -97,6 +97,10 @@ enum {
=C2=A0= * This flag is set when fiber uses custom stack size.
=C2=A0 */
= =C2=A0 FIBER_CUSTOM_STACK =3D 1 << 5,
+ /*
+ *
+ */
+ FIB= ER_IS_IDLE =3D 1 << 6,
=C2=A0 FIBER_DEFAULT_FLAGS =3D FIBER_IS_CAN= CELLABLE
=C2=A0};
=C2=A0
@@ -620,6 +624,12 @@ fiber_is_dead(struct= fiber *f)
=C2=A0 return f->flags & FIBER_IS_DEAD;
=C2=A0}
= =C2=A0
+static inline bool
+fiber_is_idle(struct fiber *f)
+{
= + return f->flags & FIBER_IS_IDLE;
+}
+
=C2=A0typedef int (= *fiber_stat_cb)(struct fiber *f, void *ctx);
=C2=A0
=C2=A0int
diff= --git a/src/lib/core/fiber_pool.c b/src/lib/core/fiber_pool.c
index 77f= 89c9fa..c04141e63 100644
--- a/src/lib/core/fiber_pool.c
+++ b/src/li= b/core/fiber_pool.c
@@ -72,8 +72,10 @@ restart:
=C2=A0 * Add the fi= ber to the front of the list, so that
=C2=A0 * it is most likely to ge= t scheduled again.
=C2=A0 */
+ f->flags |=3D FIBER_IS_IDLE;
= =C2=A0 rlist_add_entry(&pool->idle, fiber(), state);
=C2=A0 fib= er_yield();
+ f->flags &=3D ~FIBER_IS_IDLE;
=C2=A0 goto rest= art;
=C2=A0 }
=C2=A0 pool->size--;
--
2.21.0
--000000000000e3f7dd058e5cf8ff--