[PATCH 3/6] sched: Restore preferred CPUs when hotplug removes the last one
From: Yury Norov
Date: Sun Nov 01 2026 - 14:27:39 EST
Offlining the last preferred CPU leaves cpu_preferred_mask empty. Normal
fair load balancing stops, potentially leaving CPUs idle while tasks
remain queued.
Currently, the steal governor is the only module that may modify the mask,
so it takes care of this by resetting the mask to mirror the active
cpumask, but stops sampling after that.
This series adds more ways to control the preferred cpumask, so steal
governor may not be active.
Restore all remaining active CPUs as preferred in sched_cpu_deactivate()
path, without relying on the steal governor to recover.
Signed-off-by: Yury Norov <ynorov@xxxxxxxxxx>
---
kernel/sched/core.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 04b62c16fa8c..98f4f9434965 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -8712,6 +8712,14 @@ int sched_cpu_deactivate(unsigned int cpu)
set_cpu_active(cpu, false);
+#ifdef CONFIG_PREFERRED_CPU
+ if (cpumask_empty(cpu_preferred_mask)) {
+ pr_notice("sched: last preferred CPU%u offlined; make all active CPUs preferred\n",
+ cpu);
+ reset_preferred_cpumask();
+ }
+#endif
+
/*
* From this point forward, this CPU will refuse to run any task that
* is not: migrate_disable() or KTHREAD_IS_PER_CPU, and will actively
--
2.53.0