Commit 8673a27b authored by Krzysztof Karas's avatar Krzysztof Karas Committed by Jim Harris
Browse files

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: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Change-Id: Ibb9c25e6e1d28ddb4cde42baa20a7e9808652ae8
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6582


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Community-CI: Mellanox Build Bot
parent 84c349e1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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);

	/**
+13 −0
Original line number Diff line number Diff line
@@ -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) {