From: Guopeng Zhang <guopeng.zhang@linux.dev>
To: Waiman Long <longman@redhat.com>
Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org,
mkoutny@suse.com, shuah@kernel.org, cgroups@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
Guopeng Zhang <zhangguopeng@kylinos.cn>
Subject: Re: [PATCH] cgroup/cpuset: Fix missing effective_xcpus accounting of child partitions
Date: Thu, 29 Oct 2026 09:52:51 +0800 [thread overview]
Message-ID: <ed6fecb4-38e9-4a73-8c1a-7bdd80175a69@linux.dev> (raw)
In-Reply-To: <c00f13e5-d048-4d5d-98ea-984ea7ebc13b@redhat.com>
在 2026/10/28 23:30, Waiman Long 写道:
> On 10/27/26 8:38 AM, Guopeng Zhang wrote:
>> From: Guopeng Zhang <zhangguopeng@kylinos.cn>
>>
>> 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@kylinos.cn>
>
> 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
prev parent reply other threads:[~2026-10-29 1:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 12:38 [PATCH] cgroup/cpuset: Fix missing effective_xcpus accounting of child partitions Guopeng Zhang
2026-10-27 13:44 ` Guopeng Zhang
2026-10-28 5:51 ` Guopeng Zhang
2026-10-28 15:30 ` Waiman Long
2026-10-29 1:52 ` Guopeng Zhang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed6fecb4-38e9-4a73-8c1a-7bdd80175a69@linux.dev \
--to=guopeng.zhang@linux.dev \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mkoutny@suse.com \
--cc=ridong.chen@linux.dev \
--cc=shuah@kernel.org \
--cc=tj@kernel.org \
--cc=zhangguopeng@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.