From a09bf113a86f07efa98ce4b6604ca89bc44ee735 Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Fri, 27 Aug 2021 04:42:19 -0400 Subject: [PATCH] event/scheduler_dynamic: remove g_core_mngmnt_available There is no need to track if governor was enabled during initialization of the scheduler dynamic. Instead _spdk_governor_get() can be used to determine that. While here set the default g_governor to NULL. Signed-off-by: Tomasz Zawadzki Change-Id: Ibdfde3d2714dd0b6d629f19f0d246b4fc3c9d214 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9325 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Reviewed-by: Jim Harris Reviewed-by: Konrad Sztyber Reviewed-by: Ben Walker --- lib/event/reactor.c | 2 +- lib/event/scheduler_dynamic.c | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 4433a4121e..7b726996d9 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -76,7 +76,7 @@ static struct spdk_scheduler_core_info *g_core_infos = NULL; TAILQ_HEAD(, spdk_governor) g_governor_list = TAILQ_HEAD_INITIALIZER(g_governor_list); -static struct spdk_governor *g_governor; +static struct spdk_governor *g_governor = NULL; static int reactor_interrupt_init(struct spdk_reactor *reactor); static void reactor_interrupt_fini(struct spdk_reactor *reactor); diff --git a/lib/event/scheduler_dynamic.c b/lib/event/scheduler_dynamic.c index f53bd25d03..c460678b13 100644 --- a/lib/event/scheduler_dynamic.c +++ b/lib/event/scheduler_dynamic.c @@ -41,7 +41,6 @@ #include "spdk_internal/event.h" static uint32_t g_main_lcore; -static bool g_core_mngmnt_available; struct core_stats { uint64_t busy; @@ -223,12 +222,11 @@ _find_optimal_core(struct spdk_scheduler_thread_info *thread_info) static int init(void) { - int rc; - g_main_lcore = spdk_env_get_current_core(); - rc = _spdk_governor_set("dpdk_governor"); - g_core_mngmnt_available = !rc; + if (_spdk_governor_set("dpdk_governor") != 0) { + SPDK_NOTICELOG("Unable to initialize dpdk governor\n"); + } g_cores = calloc(spdk_env_get_last_core() + 1, sizeof(struct core_stats)); if (g_cores == NULL) { @@ -314,13 +312,11 @@ balance(struct spdk_scheduler_core_info *cores_info, uint32_t cores_count) } } - if (!g_core_mngmnt_available) { + governor = _spdk_governor_get(); + if (governor == NULL) { return; } - governor = _spdk_governor_get(); - assert(governor != NULL); - /* Change main core frequency if needed */ if (busy_threads_present) { rc = governor->set_core_freq_max(g_main_lcore);