Re: [PATCH 1/2] cgroup/cpuset: Skip v2 sibling checks with an empty exclusive CPU mask
From: Chuyi Zhou
Date: Thu Dec 03 2026 - 07:59:49 EST
On 2026-12-03 8:54 p.m., Ridong Chen wrote:
>
>
> 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.
>
Thanks for the suggestion. I agree that splitting the v1 and v2 checks
first would make the empty-mask case easier to follow.
Tejun, would you be willing to drop patch 4 of the previous series? If
so, I'll rebase on top of patch 3 and send the split first, followed by
the v2 empty-mask check.
Thanks.