[PATCH v5 09/12] cpuset: Add dhm_cycling_cpus mask to suppress transient invalidation
From: Qiliang Yuan
Date: Fri Oct 02 2026 - 09:26:18 EST
When the cpuset code cycles a CPU through hotplug to apply kernel-noise
isolation (remove_cpu followed by add_cpu), the CPU disappears from
cpu_active_mask temporarily. cpuset_hotplug_update_tasks() sees an
empty effective CPU set on the isolated partition and issues
partcmd_invalidate, tearing down the partition. The subsequent add_cpu
brings the CPU back online, but the partition has already been marked
invalid and requires manual user intervention to restore.
Add a global dhm_cycling_cpus cpumask protected by dhm_cycling_lock.
The isolation cycling path sets the bits for CPUs being cycled before
calling remove_cpu(), clears them after add_cpu() completes.
cpuset_hotplug_update_tasks() checks whether any of the cpuset's
effective exclusive CPUs are in dhm_cycling_cpus and skips the
invalidation command when they are, treating the transient empty-CPU
state as expected rather than an error.
A global cpumask avoids the need to walk the cpuset tree to find the
owning cpuset during the cycling loop which runs without cpuset locks.
Signed-off-by: Qiliang Yuan <odys.yuan@xxxxxxxxx>
---
kernel/cgroup/cpuset.c | 40 ++++++++++++++++++++++++++++++++++++++--
1 file changed, 38 insertions(+), 2 deletions(-)
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 8b3bb034adf62..6213e63cf348d 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -157,6 +157,14 @@ static bool update_housekeeping; /* RWCS */
*/
static cpumask_var_t isolated_hk_cpus; /* T */
+/*
+ * CPUs currently being cycled through hotplug for kernel-noise isolation.
+ * Protected by dhm_cycling_lock; read in cpuset_hotplug_update_tasks() to
+ * suppress transient partition invalidation during the offline step.
+ */
+static DEFINE_SPINLOCK(dhm_cycling_lock);
+static cpumask_var_t dhm_cycling_cpus;
+
/*
* A flag to force sched domain rebuild at the end of an operation.
* It can be set in
@@ -3906,6 +3914,7 @@ int __init cpuset_init(void)
BUG_ON(!zalloc_cpumask_var(&subpartitions_cpus, GFP_KERNEL));
BUG_ON(!zalloc_cpumask_var(&isolated_cpus, GFP_KERNEL));
BUG_ON(!zalloc_cpumask_var(&isolated_hk_cpus, GFP_KERNEL));
+ BUG_ON(!zalloc_cpumask_var(&dhm_cycling_cpus, GFP_KERNEL));
cpumask_setall(top_cpuset.cpus_allowed);
nodes_setall(top_cpuset.mems_allowed);
@@ -3991,6 +4000,20 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
if (remote && (cpumask_empty(subpartitions_cpus) ||
(cpumask_empty(&new_cpus) &&
partition_is_populated(cs, NULL)))) {
+ bool cycling;
+
+ /*
+ * Suppress transient invalidation when the offline is part
+ * of a hotplug cycling step for kernel-noise isolation.
+ */
+ spin_lock(&dhm_cycling_lock);
+ cycling = cpumask_available(dhm_cycling_cpus) &&
+ cpumask_intersects(cs->effective_xcpus,
+ dhm_cycling_cpus);
+ spin_unlock(&dhm_cycling_lock);
+ if (cycling)
+ goto unlock;
+
WRITE_ONCE(cs->prs_err, PERR_HOTPLUG);
remote_partition_disable(cs, tmp);
compute_effective_cpumask(&new_cpus, cs, parent);
@@ -4008,8 +4031,21 @@ static void cpuset_hotplug_update_tasks(struct cpuset *cs, struct tmpmasks *tmp)
if (is_local_partition(cs) &&
(!is_partition_valid(parent) ||
tasks_nocpu_error(parent, cs, &new_cpus) ||
- cpumask_empty(subpartitions_cpus)))
- partcmd = partcmd_invalidate;
+ cpumask_empty(subpartitions_cpus))) {
+ bool cycling;
+
+ /*
+ * Suppress transient invalidation when the offline is part
+ * of a hotplug cycling step for kernel-noise isolation.
+ */
+ spin_lock(&dhm_cycling_lock);
+ cycling = cpumask_available(dhm_cycling_cpus) &&
+ cpumask_intersects(cs->effective_xcpus,
+ dhm_cycling_cpus);
+ spin_unlock(&dhm_cycling_lock);
+ if (!cycling)
+ partcmd = partcmd_invalidate;
+ }
/*
* On the other hand, an invalid partition root may be transitioned
* back to a regular one with a non-empty effective xcpus.
--
2.43.0