Re: [PATCH 1/2] cgroup/cpuset: Skip v2 sibling checks with an empty exclusive CPU mask

From: Ridong Chen

Date: Thu Dec 03 2026 - 07:54:40 EST




On 12/2/2026 6:44 PM, Chuyi Zhou wrote:
validate_change() skips the sibling walk on v2 only for members whose
exclusive CPU mask stays empty. It still scans siblings when a partition
root has no explicit exclusive CPUs or when a cpuset clears its mask.

An empty exclusive CPU mask can neither intersect a sibling's exclusive
CPUs nor contain a sibling's nonempty allowed CPU mask. Only the top
cpuset is memory-exclusive on v2, and it has no siblings.

Skip the walk whenever the trial exclusive CPU mask is empty. For a
partition root, compute_trialcs_excpus() still accounts for CPUs held
by siblings when computing the effective exclusive mask.

Suggested-by: Ridong Chen <ridong.chen@xxxxxxxxx>
Link: https://lore.kernel.org/r/825c0c94-8565-4c4c-82c7-9c0f5872e6a9@xxxxxxxxx
Signed-off-by: Chuyi Zhou <zhouchuyi@xxxxxxxxxxxxx>
---
kernel/cgroup/cpuset.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index fb6359d72b68..d2337f817568 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -805,14 +805,11 @@ int validate_change(struct cpuset *cur, struct cpuset *trial)
!cpuset_cpumask_can_shrink(cur->effective_cpus, user_xcpus(trial)))
goto out;
- xcpus_changed = !cpumask_equal(cur->exclusive_cpus, trial->exclusive_cpus);
-
/*
- * On v2 an unchanged, empty exclusive CPU mask cannot conflict with
+ * On v2 an empty exclusive CPU mask cannot conflict with
* a sibling's CPU masks. Only the top cpuset is memory-exclusive.
*/
- if (cpuset_v2() && cs_is_member(cur) && !xcpus_changed &&
- cpumask_empty(trial->exclusive_cpus))
+ if (cpuset_v2() && cpumask_empty(trial->exclusive_cpus))
goto valid;
/*
@@ -820,6 +817,7 @@ int validate_change(struct cpuset *cur, struct cpuset *trial)
* overlap. exclusive_cpus cannot overlap with each other if set.
*/
ret = -EINVAL;
+ xcpus_changed = !cpumask_equal(cur->exclusive_cpus, trial->exclusive_cpus);
cpuset_for_each_child(c, css, par) {
if (c == cur)
continue;

Hi Chuyi,

Thank you for patches.

I don't think this should be a separate patch. I know Tejun has
already accepted patch 4 of your previous series, but if he can
update or drop it, a cleaner way would be to do patch 2 of this
series first, and then filter out the cpumask_empty(trial->exclusive_cpus)
case on top of it. That would make the changes easier to follow.

--
Best regards
Ridong