From a08764fd751b1bf988027a4418391fa783379804 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 11 Aug 2026 17:14:23 -0400 Subject: [PATCH] kernel/scheduler: Avoid packing IRQs if it's not going to change much. If we've gotten to pack_irqs, it means the current CPU is idle, so it's not totally overloaded. We then check whether the "small task" core is less loaded than us, or whether it has a significant load difference from us, and bail if it doesn't. This avoids thousands of unnecessary IRQ reassignments when using power saving mode. Follows up #18588. (cherry picked from commit 5ba228dfc6fbf87de734d3f08369c824bd4553a3) Change-Id: Idc914023911f374ec70a87e13437ce388bcdbd8a Reviewed-on: https://review.haiku-os.org/c/haiku/+/11520 Reviewed-by: waddlesplash --- src/system/kernel/scheduler/power_saving.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/scheduler/power_saving.cpp b/src/system/kernel/scheduler/power_saving.cpp index 4ebd746d37..c9c28bd25d 100644 --- a/src/system/kernel/scheduler/power_saving.cpp +++ b/src/system/kernel/scheduler/power_saving.cpp @@ -196,9 +196,16 @@ pack_irqs() return; cpu_ent* cpu = get_cpu_struct(); - if (smallTaskCore == CoreEntry::GetCore(cpu->cpu_num)) + CoreEntry* thisCore = CoreEntry::GetCore(cpu->cpu_num); + if (smallTaskCore == thisCore) return; + // Avoid packing IRQs if it's not really going to change much. + if (thisCore->GetLoad() >= smallTaskCore->GetLoad() + || (smallTaskCore->GetLoad() - thisCore->GetLoad()) < kLoadDifference) { + return; + } + SpinLocker locker(cpu->irqs_lock); while (list_get_first_item(&cpu->irqs) != NULL) { irq_assignment* irq = (irq_assignment*)list_get_first_item(&cpu->irqs);