From 8673a27b46ce970269f5d126d296baf603b6c4a8 Mon Sep 17 00:00:00 2001 From: Krzysztof Karas Date: Fri, 26 Feb 2021 08:37:11 +0100 Subject: [PATCH] lib/event: modify RPC to get core frequencies from governor Modifies RPC "framework_get_reactors" to get core frequency for current core and insert it into JSON response. Signed-off-by: Krzysztof Karas Change-Id: Ibb9c25e6e1d28ddb4cde42baa20a7e9808652ae8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6582 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris Community-CI: Mellanox Build Bot --- include/spdk_internal/event.h | 2 +- lib/event/app_rpc.c | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/spdk_internal/event.h b/include/spdk_internal/event.h index fa1a282dc..9ecc4209d 100644 --- a/include/spdk_internal/event.h +++ b/include/spdk_internal/event.h @@ -236,7 +236,7 @@ struct spdk_governor { /* freqs - the buffer array to save the frequencies; num - the number of frequencies to get; return - the number of available frequencies */ uint32_t (*get_core_freqs)(uint32_t lcore_id, uint32_t *freqs, uint32_t num); - /* return - current frequency */ + /* return - current frequency on success, 0 on failure */ uint32_t (*get_core_curr_freq)(uint32_t lcore_id); /** diff --git a/lib/event/app_rpc.c b/lib/event/app_rpc.c index 5a6d2cfd5..9a168080c 100644 --- a/lib/event/app_rpc.c +++ b/lib/event/app_rpc.c @@ -365,9 +365,12 @@ _rpc_framework_get_reactors(void *arg1, void *arg2) { struct rpc_get_stats_ctx *ctx = arg1; uint32_t current_core; + uint32_t curr_core_freq; struct spdk_reactor *reactor; struct spdk_lw_thread *lw_thread; struct spdk_thread *thread; + struct spdk_governor *governor; + struct spdk_governor_capabilities capabilities; current_core = spdk_env_get_current_core(); reactor = spdk_reactor_get(current_core); @@ -378,6 +381,16 @@ _rpc_framework_get_reactors(void *arg1, void *arg2) spdk_json_write_named_uint32(ctx->w, "lcore", current_core); spdk_json_write_named_uint64(ctx->w, "busy", reactor->busy_tsc); spdk_json_write_named_uint64(ctx->w, "idle", reactor->idle_tsc); + governor = _spdk_governor_get(); + /* We need to check whether governor can return current core frequency. */ + if (governor->get_core_capabilities && governor->get_core_freqs) { + governor->get_core_capabilities(current_core, &capabilities); + if (capabilities.freq_getset) { + /* Governor returns core freqs in kHz, we want MHz. */ + curr_core_freq = governor->get_core_curr_freq(current_core) / 1000; + spdk_json_write_named_uint32(ctx->w, "core_freq", curr_core_freq); + } + } spdk_json_write_named_array_begin(ctx->w, "lw_threads"); TAILQ_FOREACH(lw_thread, &reactor->threads, link) {