From b99df8ee33d7f23ef50ff79c776a1a4f2193d517 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Sun, 8 Dec 2019 18:32:41 -0500 Subject: [PATCH] app/rpc: Add cpumask to output of thread_get_stats RPC Thread's core affinity had not been visible to users. This patch adds thread's core affinity information to the existing thread_get_stats RPC. We can create an new RPC to retrieve thread's core affinity information but using thread_get_stats RPC will be enough for now. Besides, the name of SPDK thread 0 is not reactor_0 but app_thread now. So fix it together in this patch. Signed-off-by: Shuhei Matsumoto Change-Id: I634da46c411d648837538ebf227074d307273c97 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/475187 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Paul Luse Reviewed-by: Jim Harris Reviewed-by: Alexey Marchuk --- doc/jsonrpc.md | 3 ++- module/event/rpc/app_rpc.c | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/jsonrpc.md b/doc/jsonrpc.md index ed7ac0c2f..996f2776b 100644 --- a/doc/jsonrpc.md +++ b/doc/jsonrpc.md @@ -518,7 +518,8 @@ Example response: "ticks": 2523538189523655, "threads": [ { - "name": "reactor_0", + "name": "app_thread", + "cpumask": "1", "busy": 139223208, "idle": 8641080608 } diff --git a/module/event/rpc/app_rpc.c b/module/event/rpc/app_rpc.c index 08670b4bc..999ac4929 100644 --- a/module/event/rpc/app_rpc.c +++ b/module/event/rpc/app_rpc.c @@ -173,11 +173,14 @@ static void rpc_thread_get_stats(void *arg) { struct rpc_thread_get_stats_ctx *ctx = arg; + struct spdk_thread *thread = spdk_get_thread(); struct spdk_thread_stats stats; if (0 == spdk_thread_get_stats(&stats)) { spdk_json_write_object_begin(ctx->w); - spdk_json_write_named_string(ctx->w, "name", spdk_thread_get_name(spdk_get_thread())); + spdk_json_write_named_string(ctx->w, "name", spdk_thread_get_name(thread)); + spdk_json_write_named_string(ctx->w, "cpumask", + 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_object_end(ctx->w);