scheduler_dynamic: balance idle threads in separate pass
Idle threads are always moved to main core, there are no other considations. Doing it as separate first pass, allows to have the core stats be up to date for second pass for active threads. Core load stats will be used later in the series to determine optimal target core for an active thread. Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Change-Id: I6a9bc11b86e954e461f7badebf3a6e4d1718f63c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8067 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Maciej Szwed <maciej.szwed@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
e209981dd1
commit
2d79bf58fb
@ -205,20 +205,27 @@ deinit(struct spdk_governor *governor)
|
||||
}
|
||||
|
||||
static void
|
||||
_balance_thread(struct spdk_lw_thread *lw_thread)
|
||||
_balance_idle(struct spdk_lw_thread *lw_thread)
|
||||
{
|
||||
if (_get_thread_load(lw_thread) >= SCHEDULER_LOAD_LIMIT) {
|
||||
return;
|
||||
}
|
||||
/* This thread is idle, move it to the main core. */
|
||||
_move_thread(lw_thread, g_main_lcore);
|
||||
}
|
||||
|
||||
static void
|
||||
_balance_active(struct spdk_lw_thread *lw_thread)
|
||||
{
|
||||
uint32_t target_lcore;
|
||||
uint8_t load;
|
||||
|
||||
load = _get_thread_load(lw_thread);
|
||||
if (load < SCHEDULER_LOAD_LIMIT) {
|
||||
/* This thread is idle, move it to the main core. */
|
||||
_move_thread(lw_thread, g_main_lcore);
|
||||
} else {
|
||||
/* This thread is active. */
|
||||
target_lcore = _find_optimal_core(lw_thread);
|
||||
_move_thread(lw_thread, target_lcore);
|
||||
if (_get_thread_load(lw_thread) < SCHEDULER_LOAD_LIMIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* This thread is active. */
|
||||
target_lcore = _find_optimal_core(lw_thread);
|
||||
_move_thread(lw_thread, target_lcore);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -239,8 +246,11 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count,
|
||||
}
|
||||
main_core = &g_cores[g_main_lcore];
|
||||
|
||||
/* Distribute active threads across all cores and move idle threads to main core */
|
||||
_foreach_thread(cores_info, _balance_thread);
|
||||
/* Distribute threads in two passes, to make sure updated core stats are considered on each pass.
|
||||
* 1) Move all idle threads to main core. */
|
||||
_foreach_thread(cores_info, _balance_idle);
|
||||
/* 2) Distribute active threads across all cores. */
|
||||
_foreach_thread(cores_info, _balance_active);
|
||||
|
||||
/* Switch unused cores to interrupt mode and switch cores to polled mode
|
||||
* if they will be used after rebalancing */
|
||||
|
Loading…
Reference in New Issue
Block a user