schedulers: Switch to interrupt mode if core is unused

Save CPU resources by switching reactors w/o any
threads to interrupt mode.

Signed-off-by: Maciej Szwed <maciej.szwed@intel.com>
Change-Id: Ibd1c1d50d1f6c6d7ed226d585e14999c2fd04621
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5456
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Maciej Szwed 2020-12-04 12:41:34 +01:00 committed by Tomasz Zawadzki
parent 6859a49a98
commit e742a41456

View File

@ -109,6 +109,7 @@ static void
balance(struct spdk_scheduler_core_info *cores_info, int cores_count,
struct spdk_governor *governor)
{
struct spdk_reactor *reactor;
struct spdk_lw_thread *lw_thread;
struct spdk_thread *thread;
struct spdk_scheduler_core_info *core;
@ -202,6 +203,19 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count,
}
}
/* Switch unused cores to interrupt mode and switch cores to polled mode
* if they will be used after rebalancing */
SPDK_ENV_FOREACH_CORE(i) {
reactor = spdk_reactor_get(i);
core = &cores_info[i];
/* We can switch mode only if reactor already does not have any threads */
if (core->pending_threads_count == 0 && TAILQ_EMPTY(&reactor->threads)) {
core->interrupt_mode = true;
} else if (core->pending_threads_count != 0) {
core->interrupt_mode = false;
}
}
if (!g_core_mngmnt_available) {
return;
}