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