diff --git a/include/spdk_internal/event.h b/include/spdk_internal/event.h index 5684ffed80..1e6608e455 100644 --- a/include/spdk_internal/event.h +++ b/include/spdk_internal/event.h @@ -259,8 +259,10 @@ struct spdk_governor *_spdk_governor_get(void); * A list of cores and threads which is used for scheduling. */ struct spdk_scheduler_core_info { - uint64_t core_idle_tsc; - uint64_t core_busy_tsc; + /* stats over a lifetime of a core */ + uint64_t total_idle_tsc; + uint64_t total_busy_tsc; + uint32_t lcore; uint32_t threads_count; uint32_t pending_threads_count; diff --git a/lib/event/gscheduler.c b/lib/event/gscheduler.c index 49bb7fc542..251eaa7d47 100644 --- a/lib/event/gscheduler.c +++ b/lib/event/gscheduler.c @@ -89,7 +89,7 @@ balance(struct spdk_scheduler_core_info *cores, int core_count, struct spdk_gove turbo_available = (capabilities.turbo_available && capabilities.turbo_set) ? true : false; - if (core->core_busy_tsc < (core->core_idle_tsc / 1000)) { + if (core->total_busy_tsc < (core->total_idle_tsc / 1000)) { rc = governor->set_core_freq_min(core->lcore); if (rc < 0) { SPDK_ERRLOG("setting to minimal frequency for core %u failed\n", core->lcore); @@ -103,7 +103,7 @@ balance(struct spdk_scheduler_core_info *cores, int core_count, struct spdk_gove } SPDK_DEBUGLOG(reactor, "setting to minimal frequency for core: %u\n", core->lcore); - } else if (core->core_idle_tsc > core->core_busy_tsc) { + } else if (core->total_idle_tsc > core->total_busy_tsc) { rc = governor->core_freq_down(core->lcore); if (rc < 0) { SPDK_ERRLOG("lowering frequency for core %u failed\n", core->lcore); @@ -117,7 +117,7 @@ balance(struct spdk_scheduler_core_info *cores, int core_count, struct spdk_gove } SPDK_DEBUGLOG(reactor, "lowering frequency for core: %u\n", core->lcore); - } else if (core->core_idle_tsc < (core->core_busy_tsc / 1000)) { + } else if (core->total_idle_tsc < (core->total_busy_tsc / 1000)) { rc = governor->set_core_freq_max(core->lcore); if (rc < 0) { SPDK_ERRLOG("setting to maximal frequency for core %u failed\n", core->lcore); diff --git a/lib/event/reactor.c b/lib/event/reactor.c index 6c9c2d4a8b..92886887c3 100644 --- a/lib/event/reactor.c +++ b/lib/event/reactor.c @@ -792,8 +792,8 @@ _reactors_scheduler_gather_metrics(void *arg1, void *arg2) reactor->flags.is_scheduling = true; core_info = &g_core_infos[reactor->lcore]; core_info->lcore = reactor->lcore; - core_info->core_idle_tsc = reactor->idle_tsc; - core_info->core_busy_tsc = reactor->busy_tsc; + core_info->total_idle_tsc = reactor->idle_tsc; + core_info->total_busy_tsc = reactor->busy_tsc; core_info->interrupt_mode = reactor->in_interrupt; SPDK_DEBUGLOG(reactor, "Gathering metrics on %u\n", reactor->lcore); diff --git a/lib/event/scheduler_dynamic.c b/lib/event/scheduler_dynamic.c index 724ba15ede..5744fcd5c6 100644 --- a/lib/event/scheduler_dynamic.c +++ b/lib/event/scheduler_dynamic.c @@ -139,10 +139,10 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count, uint8_t load; bool busy_threads_present = false; - main_core_busy = cores_info[g_main_lcore].core_busy_tsc - g_last_main_core_busy; - main_core_idle = cores_info[g_main_lcore].core_idle_tsc - g_last_main_core_idle; - g_last_main_core_busy = cores_info[g_main_lcore].core_busy_tsc; - g_last_main_core_idle = cores_info[g_main_lcore].core_idle_tsc; + main_core_busy = cores_info[g_main_lcore].total_busy_tsc - g_last_main_core_busy; + main_core_idle = cores_info[g_main_lcore].total_idle_tsc - g_last_main_core_idle; + g_last_main_core_busy = cores_info[g_main_lcore].total_busy_tsc; + g_last_main_core_idle = cores_info[g_main_lcore].total_idle_tsc; SPDK_ENV_FOREACH_CORE(i) { cores_info[i].pending_threads_count = cores_info[i].threads_count;