From 72f8138ca1c40b3db630fa63ccf213eb3ce5f878 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 25 Aug 2024 15:29:05 +0300 Subject: [PATCH] Kernel: Disable scheduler load balancing until I get it fixed Scheduler keeps crashing all the time when running on multiple cores. This patch disabled the load balancer, which seems to get rid of most scheduler crashes. --- kernel/kernel/Scheduler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/kernel/Scheduler.cpp b/kernel/kernel/Scheduler.cpp index 11f34ae5..7c52c7dc 100644 --- a/kernel/kernel/Scheduler.cpp +++ b/kernel/kernel/Scheduler.cpp @@ -8,6 +8,7 @@ #define DEBUG_SCHEDULER 0 #define SCHEDULER_ASSERT 1 +#define SCHEDULER_LOAD_BALANCE 0 #if SCHEDULER_ASSERT == 0 #undef ASSERT @@ -295,8 +296,9 @@ namespace Kernel { ASSERT(Processor::get_interrupt_state() == InterruptState::Disabled); - if (Processor::is_smp_enabled()) - do_load_balancing(); + if constexpr(SCHEDULER_LOAD_BALANCE) + if (Processor::is_smp_enabled()) + do_load_balancing(); { const uint64_t current_ns = SystemTimer::get().ns_since_boot(); @@ -386,6 +388,7 @@ namespace Kernel return least_loaded_id; } +#if SCHEDULER_LOAD_BALANCE void Scheduler::do_load_balancing() { ASSERT(Processor::get_interrupt_state() == InterruptState::Disabled); @@ -563,6 +566,7 @@ namespace Kernel m_last_load_balance_ns += s_load_balance_interval_ns; } +#endif BAN::ErrorOr Scheduler::add_thread(Thread* thread) {