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 <krzysztof.karas@intel.com>
Change-Id: Ibb9c25e6e1d28ddb4cde42baa20a7e9808652ae8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6582
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Krzysztof Karas 2021-02-26 08:37:11 +01:00 committed by Jim Harris
parent 84c349e1d8
commit 8673a27b46
2 changed files with 14 additions and 1 deletions

View File

@ -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);
/**

View File

@ -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) {