diff --git a/lib/event/scheduler_dynamic.c b/lib/event/scheduler_dynamic.c index ffc9dc963..d9fa634de 100644 --- a/lib/event/scheduler_dynamic.c +++ b/lib/event/scheduler_dynamic.c @@ -161,6 +161,11 @@ balance(struct spdk_scheduler_core_info *cores_info, int cores_count, target_lcore = g_next_lcore; g_next_lcore = spdk_env_get_next_core(g_next_lcore); + /* Do not use main core if it is too busy for new thread */ + if (target_lcore == g_main_lcore && thread_busy > main_core_idle) { + continue; + } + if (spdk_cpuset_get_cpu(cpumask, target_lcore)) { lw_thread->new_lcore = target_lcore; diff --git a/test/unit/lib/event/reactor.c/reactor_ut.c b/test/unit/lib/event/reactor.c/reactor_ut.c index c1b5c4e8f..56941b331 100644 --- a/test/unit/lib/event/reactor.c/reactor_ut.c +++ b/test/unit/lib/event/reactor.c/reactor_ut.c @@ -560,6 +560,9 @@ test_scheduler(void) spdk_poller_unregister(&busy); } + reactor->busy_tsc = 0; + reactor->idle_tsc = UINT32_MAX; + /* Run scheduler again, this time all threads are busy */ _reactors_scheduler_gather_metrics(NULL, NULL);