scheduler_dynamic: prioritize g_main_lcore during _find_optimal_core

_find_optimal_core was always consolidating idle threads to g_main_lcore.
Meanwhile for active threads lower lcore id were prioritized over the
higher ones.

So long as g_main_lcore can fit the active thread, it should be prioritized
over any other. Regardless of the lcore id.

Fix #2080

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I30b3a7353bcf243d4362b4db9dde5446c435d675
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9243
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Tomasz Zawadzki 2021-08-20 05:47:16 -04:00
parent 45dddbc891
commit f8a961f5ea

View File

@ -232,12 +232,14 @@ _find_optimal_core(struct spdk_scheduler_thread_info *thread_info)
if (!_can_core_fit_thread(thread_info, i) || i == current_lcore) {
continue;
}
if (i < current_lcore) {
if (i == g_main_lcore) {
/* First consider g_main_lcore, consolidate threads on main lcore if possible. */
return i;
} else if (i < current_lcore && current_lcore != g_main_lcore) {
/* Lower core id was found, move to consolidate threads on lowest core ids. */
return i;
} else if (core_at_limit) {
/* When core is over the limit, even higher core ids are better than current one. */
/* When core is over the limit, any core id is better than current one. */
return i;
}
}