lib/app: only print cpumask for thread within app core mask

For cases where cpumask for a thread was not set,
all bits were turned on for whole length of cpuset structure.

This resulted in JSON RPC reponses with way too long cpumask
for what is useful.

Now the response is limited to the applications core mask,
as that makes sense so long as number of cores cannot change.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ib5cf271d3b219ba679f1abe498516796693a87dd
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8288
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
Tomasz Zawadzki 2021-06-10 12:18:34 -04:00 committed by Ben Walker
parent fe2f80961c
commit 57a2f03eb6

View File

@ -196,6 +196,7 @@ _rpc_thread_get_stats(void *arg)
{
struct rpc_get_stats_ctx *ctx = arg;
struct spdk_thread *thread = spdk_get_thread();
struct spdk_cpuset tmp_mask = {};
struct spdk_poller *poller;
struct spdk_thread_stats stats;
uint64_t active_pollers_count = 0;
@ -221,8 +222,9 @@ _rpc_thread_get_stats(void *arg)
spdk_json_write_object_begin(ctx->w);
spdk_json_write_named_string(ctx->w, "name", spdk_thread_get_name(thread));
spdk_json_write_named_uint64(ctx->w, "id", spdk_thread_get_id(thread));
spdk_json_write_named_string(ctx->w, "cpumask",
spdk_cpuset_fmt(spdk_thread_get_cpumask(thread)));
spdk_cpuset_copy(&tmp_mask, spdk_app_get_core_mask());
spdk_cpuset_and(&tmp_mask, spdk_thread_get_cpumask(thread));
spdk_json_write_named_string(ctx->w, "cpumask", spdk_cpuset_fmt(&tmp_mask));
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);
@ -384,6 +386,7 @@ _rpc_framework_get_reactors(void *arg1, void *arg2)
struct spdk_reactor *reactor;
struct spdk_lw_thread *lw_thread;
struct spdk_thread *thread;
struct spdk_cpuset tmp_mask = {};
struct spdk_governor *governor;
struct spdk_governor_capabilities capabilities;
@ -414,8 +417,9 @@ _rpc_framework_get_reactors(void *arg1, void *arg2)
spdk_json_write_object_begin(ctx->w);
spdk_json_write_named_string(ctx->w, "name", spdk_thread_get_name(thread));
spdk_json_write_named_uint64(ctx->w, "id", spdk_thread_get_id(thread));
spdk_json_write_named_string(ctx->w, "cpumask",
spdk_cpuset_fmt(spdk_thread_get_cpumask(thread)));
spdk_cpuset_copy(&tmp_mask, spdk_app_get_core_mask());
spdk_cpuset_and(&tmp_mask, spdk_thread_get_cpumask(thread));
spdk_json_write_named_string(ctx->w, "cpumask", spdk_cpuset_fmt(&tmp_mask));
spdk_json_write_named_uint64(ctx->w, "elapsed",
GET_DELTA(ctx->now, lw_thread->tsc_start));
spdk_json_write_object_end(ctx->w);