thread: Add pollers number to threads stats

This will be used by upcoming spdk_top application.

Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: I066567f0f14d70e6744821e8e805934a3d790882
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1235
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Maciej Szwed 2020-03-11 13:53:36 +01:00 committed by Tomasz Zawadzki
parent c3d0a83347
commit 725c6bf8a0
2 changed files with 21 additions and 1 deletions

View File

@ -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
}
]
}

View File

@ -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);
}
}