diff --git a/lib/event/scheduler_dynamic.c b/lib/event/scheduler_dynamic.c index f71151e93..7fa279237 100644 --- a/lib/event/scheduler_dynamic.c +++ b/lib/event/scheduler_dynamic.c @@ -109,6 +109,7 @@ _move_thread(struct spdk_lw_thread *lw_thread, uint32_t dst_core) struct core_stats *dst = &g_cores[dst_core]; struct core_stats *src = &g_cores[lw_thread->lcore]; uint64_t busy_tsc = lw_thread->current_stats.busy_tsc; + uint64_t idle_tsc = lw_thread->current_stats.idle_tsc; if (src == dst) { /* Don't modify stats if thread is already on that core. */ @@ -119,8 +120,10 @@ _move_thread(struct spdk_lw_thread *lw_thread, uint32_t dst_core) dst->idle -= spdk_min(dst->idle, busy_tsc); dst->thread_count++; + /* Decrease busy/idle from core as if thread was not present on it. + * Core load will reflect the sum of all other threads on it. */ src->busy -= spdk_min(src->busy, busy_tsc); - src->idle += spdk_min(UINT64_MAX - src->busy, busy_tsc); + src->idle -= spdk_min(src->idle, idle_tsc); assert(src->thread_count > 0); src->thread_count--;