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 <[email protected]>
This commit is contained in:
Augustin Cavalier
2026-08-11 21:15:55 +00:00
committed by waddlesplash
parent 5e58c857f1
commit a08764fd75
+8 -1
View File
@@ -196,9 +196,16 @@ pack_irqs()
return; return;
cpu_ent* cpu = get_cpu_struct(); cpu_ent* cpu = get_cpu_struct();
if (smallTaskCore == CoreEntry::GetCore(cpu->cpu_num)) CoreEntry* thisCore = CoreEntry::GetCore(cpu->cpu_num);
if (smallTaskCore == thisCore)
return; 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); SpinLocker locker(cpu->irqs_lock);
while (list_get_first_item(&cpu->irqs) != NULL) { while (list_get_first_item(&cpu->irqs) != NULL) {
irq_assignment* irq = (irq_assignment*)list_get_first_item(&cpu->irqs); irq_assignment* irq = (irq_assignment*)list_get_first_item(&cpu->irqs);