[PATCH-next 2/3] sched/isolation: Forbid the boot CPU from being isolated

From: Waiman Long

Date: Fri Nov 20 2026 - 22:14:57 EST


It is reported that with CONFIG_CPUSETS=n, a kernel booted with
isolcpus=domain,0 hits the BUG() in select_fallback_rq() during boot
[1]. At boot time, cpu 0 is the only CPU online and an unbound kworker
cannot be run on a domain isolated CPU causing kernel panic.

Sashiko also reports that domain isolating the boot CPU can break system
suspend and trigger a BUG_ON() [2]. So it is problematic if the boot CPU
is domain isolated.

There may be other kernel subsystems that have problem if the boot CPU
is domain isolated as most of them won't take into account the fact
that boot CPU is currently allowed to be domain isolated. The current
housekeeping code enforces the rule that if both isolcpus and nohz_full
boot parameters are set, they should match each other. Given the fact
that the boot CPU is likely to be disallowed from the nohz_full list,
it makes sense that we should not allow the boot CPU from being set
in the isolcpus boot parameter as well. This will also avoid the above
problems due to boot CPU being domain isolated.

Do that by clearing the boot CPU from the isolcpus range when it is
specified in the boot command line. A warning will also be printed when
that happens.

This is indeed a change in behavior which is customer visible. So the
kernel-paremeters.txt is updated to mention the fact that boot CPU
cannot be isolated.

[1] https://lore.kernel.org/lkml/20261117144817.265109-1-mathieu.desnoyers@xxxxxxxxxxxx
[2] https://sashiko.dev/#/patchset/20261108180849.1268263-1-longman%40redhat.com

Signed-off-by: Waiman Long <longman@xxxxxxxxxx>
---
Documentation/admin-guide/kernel-parameters.txt | 7 ++++---
kernel/sched/isolation.c | 16 ++++++++++++----
2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 930cee4de79a..1c8bf3583b0b 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -2954,11 +2954,12 @@ Kernel parameters

You can move a process onto or off an "isolated" CPU via
the CPU affinity syscalls or cpuset.
- <cpu number> begins at 0 and the maximum value is
- "number of CPUs in system - 1".
+ <cpu number> begins at 0 and the maximum value
+ is "number of CPUs in system - 1". However boot
+ CPU (cpu 0) cannot be domain isolated as it
+ may cause problem with some kernel subsystems.

managed_irq
-
Isolate from being targeted by managed interrupts
which have an interrupt mask containing isolated
CPUs. The affinity of managed interrupts is
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 18b50c0d807a..ef4aa5126dc5 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -232,6 +232,7 @@ static int __init housekeeping_setup(char *str, unsigned long flags)
{
cpumask_var_t non_housekeeping_mask, housekeeping_staging;
unsigned int first_cpu;
+ int boot_cpu = smp_processor_id();
int err = 0;

if ((flags & HK_FLAG_KERNEL_NOISE) && !(housekeeping.flags & HK_FLAG_KERNEL_NOISE)) {
@@ -254,14 +255,21 @@ static int __init housekeeping_setup(char *str, unsigned long flags)

first_cpu = cpumask_first_and(cpu_present_mask, housekeeping_staging);
if (first_cpu >= nr_cpu_ids || first_cpu >= setup_max_cpus) {
- __cpumask_set_cpu(smp_processor_id(), housekeeping_staging);
- __cpumask_clear_cpu(smp_processor_id(), non_housekeeping_mask);
+ __cpumask_set_cpu(boot_cpu, housekeeping_staging);
+ __cpumask_clear_cpu(boot_cpu, non_housekeeping_mask);
if (!housekeeping.flags) {
- pr_warn("Housekeeping: must include one present CPU, "
- "using boot CPU:%d\n", smp_processor_id());
+ pr_warn("Housekeeping: must include one present CPU, using boot CPU:%d\n",
+ boot_cpu);
}
}

+ if ((flags & HK_FLAG_DOMAIN) && cpumask_test_cpu(boot_cpu, non_housekeeping_mask)) {
+ pr_warn("Housekeeping: Boot CPU must not be isolated, clearing %d from isolcpus range\n",
+ boot_cpu);
+ __cpumask_set_cpu(boot_cpu, housekeeping_staging);
+ __cpumask_clear_cpu(boot_cpu, non_housekeeping_mask);
+ }
+
if (cpumask_empty(non_housekeeping_mask))
goto free_housekeeping_staging;

--
2.56.1