From 725c6bf8a04ca1d1880e818141368d19915f6490 Mon Sep 17 00:00:00 2001 From: Maciej Szwed Date: Wed, 11 Mar 2020 13:53:36 +0100 Subject: [PATCH] thread: Add pollers number to threads stats This will be used by upcoming spdk_top application. Signed-off-by: Maciej Szwed Change-Id: I066567f0f14d70e6744821e8e805934a3d790882 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1235 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto --- doc/jsonrpc.md | 5 ++++- module/event/rpc/app_rpc.c | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index f21390a25..43eb6e5b2 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -566,7 +566,10 @@ Example response: "id": 1, "cpumask": "1", "busy": 139223208, - "idle": 8641080608 + "idle": 8641080608, + "active_pollers_count": 1, + "timed_pollers_count": 2, + "paused_pollers_count": 0 } ] } diff --git a/module/event/rpc/app_rpc.c b/module/event/rpc/app_rpc.c index aeb953385..5a7d255a3 100644 --- a/module/event/rpc/app_rpc.c +++ b/module/event/rpc/app_rpc.c @@ -197,7 +197,21 @@ rpc_thread_get_stats(void *arg) { struct rpc_get_stats_ctx *ctx = arg; struct spdk_thread *thread = spdk_get_thread(); + struct spdk_poller *poller; struct spdk_thread_stats stats; + uint64_t active_pollers_count = 0; + uint64_t timed_pollers_count = 0; + uint64_t paused_pollers_count = 0; + + TAILQ_FOREACH(poller, &thread->active_pollers, tailq) { + active_pollers_count++; + } + TAILQ_FOREACH(poller, &thread->timed_pollers, tailq) { + timed_pollers_count++; + } + TAILQ_FOREACH(poller, &thread->paused_pollers, tailq) { + paused_pollers_count++; + } if (0 == spdk_thread_get_stats(&stats)) { spdk_json_write_object_begin(ctx->w); @@ -207,6 +221,9 @@ rpc_thread_get_stats(void *arg) spdk_cpuset_fmt(spdk_thread_get_cpumask(thread))); spdk_json_write_named_uint64(ctx->w, "busy", stats.busy_tsc); spdk_json_write_named_uint64(ctx->w, "idle", stats.idle_tsc); + spdk_json_write_named_uint64(ctx->w, "active_pollers_count", active_pollers_count); + spdk_json_write_named_uint64(ctx->w, "timed_pollers_count", timed_pollers_count); + spdk_json_write_named_uint64(ctx->w, "paused_pollers_count", paused_pollers_count); spdk_json_write_object_end(ctx->w); } }