From 1f03d23daec075e3da90c13b2fcd5cc7bbecf1a1 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 10 Jan 2026 01:46:08 +0200 Subject: [PATCH] Kernel: Fix load balancing My code to find least loaded processor used processor index instead of processor id to index the array. Most of the time this lead to wrong processor returned as the least loaded, leaving some processors basically idle. --- kernel/kernel/Scheduler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/kernel/Scheduler.cpp b/kernel/kernel/Scheduler.cpp index b52606d3..83f826a1 100644 --- a/kernel/kernel/Scheduler.cpp +++ b/kernel/kernel/Scheduler.cpp @@ -411,10 +411,10 @@ namespace Kernel uint32_t least_max_load_threads = static_cast(-1); for (uint8_t i = 0; i < Processor::count(); i++) { - auto processor_id = Processor::id_from_index(i); + const auto processor_id = Processor::id_from_index(i); if (processor_id == Processor::current_id()) continue; - const auto& info = s_processor_infos[i]; + const auto& info = s_processor_infos[processor_id.as_u32()]; if (info.idle_time_ns < most_idle_ns || info.max_load_threads > least_max_load_threads) continue; least_loaded_id = processor_id;