Re: [PATCH] cgroup/cpuset: Fix missing effective_xcpus accounting of child partitions
From: Guopeng Zhang
Date: Wed Oct 28 2026 - 21:53:12 EST
在 2026/10/28 23:30, Waiman Long 写道:
> On 10/27/26 8:38 AM, Guopeng Zhang wrote:
>> From: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
>>
>> When a partition root expands its exclusive CPUs, a valid child
>> partition will be able to claim more CPUs from its parent. As
>> update_cpumasks_hier() always updates a cpuset before its descendants,
>> the parent has already been committed when the child partition is
>> reached. Its effective_cpus is computed with the child's old
>> effective_xcpus subtracted and no further adjustment is made
>> after the child commits its new effective_xcpus.
>>
>> The additional CPUs are thus granted to both the parent and the child
>> partitions. generate_sched_domains() then emits the warning below
>> about the overlapping sched domains:
>>
>> WARNING: kernel/cgroup/cpuset.c:919 at rebuild_sched_domains_locked+0x1ec/0x2e0, CPU#21: bash/1225
>>
>> Fix that by taking the CPUs newly added to a valid child partition
>> away from its parent at the commit point of update_cpumasks_hier()
>> right before the new effective_xcpus is committed. The tasks in the
>> parent cpuset as well as its other children will be updated if its
>> effective_cpus is changed.
>>
>> A new test case is added to test_cpuset_prs.sh to test this patch.
>>
>> Fixes: e2ffe502ba45 ("cgroup/cpuset: Add cpuset.cpus.exclusive for v2")
>> Signed-off-by: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
>
> Thanks for reporting this bug. Yes, the current code doesn't handle expansion of parent effective_xcpus correctly. I would prefer to handle it inside update_parent_effective_cpumask() and try to minimize partition related changes in update_cpumasks_hier(). I have posted an alternative patch for your review. Let me know how you think about it.
>
Thanks for the alternative patch.
Well, I am still learning how you approach this whole series of
problems.
One more thing I found yesterday: neither the current code nor my
patch runs the housekeeping check when a valid child partition gains
CPUs from its parent, e.g. when its parent expands the exclusive
CPUs. With nohz_full, an isolated child partition can take over the
last housekeeping CPU. I verified this on a nohz_full=1-7 boot.
I handled it roughly like the diff below. Please take a look and see
if it is worth handling together in this series.
@@ -2142,12 +2142,28 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
deleting = !cpumask_empty(tmp->delmask);
else
part_error = PERR_NOTEXCL;
+ } else if (cpumask_andnot(tmp->addmask, tmp->delmask,
+ cs->effective_xcpus) &&
+ prstate_housekeeping_conflict(cs->partition_root_state,
+ parent_prs,
+ tmp->delmask, NULL)) {
+ /*
+ * A valid partition may be able to claim more CPUs
+ * from its parent, e.g. when its parent expands the
+ * exclusive CPUs. The newly computed effective xcpus
+ * may not have been housekeeping checked before.
+ */
+ part_error = PERR_HKEEPING;
+ adding = cpumask_and(tmp->addmask,
+ cs->effective_xcpus,
+ parent->effective_xcpus);
}
I have something urgent at hand today, so I will get to your patch a
bit later and run it through the test cases I have, including the
isolated_cpus accounting case I mentioned in my previous reply.
Thanks,
Guopeng