From: Waiman Long <longman@redhat.com>
To: Guopeng Zhang <zhangguopeng@kylinos.cn>,
tj@kernel.org, juri.lelli@redhat.com, chenridong@huaweicloud.com,
mkoutny@suse.com
Cc: hannes@cmpxchg.org, mingo@redhat.com, peterz@infradead.org,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de,
vschneid@redhat.com, kprateek.nayak@amd.com,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Subject: Re: [PATCH] cgroup/cpuset: make DL attach bandwidth reservation root-domain aware
Date: Mon, 27 Apr 2026 09:47:59 -0400 [thread overview]
Message-ID: <60bc60ba-670e-49f5-8482-54aed4563fae@redhat.com> (raw)
In-Reply-To: <ed0fa795-10f4-4dd0-a6f5-cbc6e29b38c4@kylinos.cn>
On 4/26/26 9:48 AM, Guopeng Zhang wrote:
>
> 在 2026/4/24 22:15, Waiman Long 写道:
>> On 4/21/26 4:34 AM, Guopeng Zhang wrote:
>>> cpuset_can_attach() currently sums the bandwidth of all migrating
>>> SCHED_DEADLINE tasks and reserves destination bandwidth whenever the
>>> old and new cpuset effective CPU masks do not overlap.
>>>
>>> That condition is stronger than what the scheduler uses when migrating
>>> a deadline task. set_cpus_allowed_dl() only subtracts bandwidth from
>>> the source side when moving the task requires a DL bandwidth move
>>> between root domains.
>>>
>>> As a result, moving a deadline task between disjoint member cpusets that
>>> still belong to the same root domain can reserve destination bandwidth
>>> even though no matching source-side subtraction happens. Successful
>>> back-and-forth migrations between such cpusets can monotonically
>>> increase dl_bw->total_bw.
>>>
>>> Fix this by extracting the source root-domain test already used by
>>> set_cpus_allowed_dl() into a shared helper and make cpuset DL bandwidth
>>> preallocation use that same condition. Count all migrating deadline
>>> tasks for cpuset task accounting, but only accumulate sum_migrate_dl_bw
>>> for tasks that actually need a DL bandwidth move. Reserve and rollback
>>> bandwidth only for that subset.
>>>
>>> This keeps successful attach accounting aligned with
>>> set_cpus_allowed_dl() and avoids double-accounting within a single
>>> root domain.
>>>
>>> Fixes: 2ef269ef1ac0 ("cgroup/cpuset: Free DL BW in case can_attach() fails")
>>> Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
>>> ---
>>> include/linux/sched/deadline.h | 9 +++++++++
>>> kernel/cgroup/cpuset-internal.h | 1 +
>>> kernel/cgroup/cpuset.c | 34 ++++++++++++++++-----------------
>>> kernel/sched/deadline.c | 14 +++++++++++---
>>> 4 files changed, 38 insertions(+), 20 deletions(-)
>>>
> ...
>>> @@ -3137,6 +3135,16 @@ static void set_cpus_allowed_dl(struct task_struct *p,
>>> set_cpus_allowed_common(p, ctx);
>>> }
>>> +bool dl_task_needs_bw_move(struct task_struct *p,
>>> + const struct cpumask *new_mask)
>>> +{
>>> + if (!dl_task(p))
>>> + return false;
>>> +
>>> + guard(rcu)();
>> What do you need a RCU guard here?
> Hi Longman,
>
> Thanks for the review.
>
> I added the RCU guard in the first version because the helper reads
> task_rq(p)->rd->span, and root domains are replaced and freed through
> RCU. My initial thought was to make the helper self-contained for the
> rq->rd/span lifetime aspect.
>
> After re-checking the current callers more carefully,
> dl_task_needs_bw_move() is only used by cpuset_can_attach() and
> set_cpus_allowed_dl() in this patch.
>
> cpuset_can_attach() runs in the cgroup attach path, which already holds
> cpus_read_lock(), and cpuset itself also holds cpuset_mutex there.
> set_cpus_allowed_dl() runs under task_rq_lock()/rq->lock in the affinity
> change path.
>
> So for the current callers, the RCU guard does not appear to be
> strictly necessary.
>
> I plan to drop guard(rcu)() in the next version. Does that sound
> reasonable to you?
>
> I am also checking the Sashiko bot comments and will address them in the
> next revision as appropriate.
That sounds reasonable. Creation/destruction of root domains are
controlled by cpuset. So root domains won't be changing when calling
from the cpuset code in cpuset_can_attach().
Cheers,
Longman
next prev parent reply other threads:[~2026-04-27 13:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 8:34 [PATCH] cgroup/cpuset: make DL attach bandwidth reservation root-domain aware Guopeng Zhang
2026-04-22 2:14 ` Guopeng Zhang
2026-04-24 14:15 ` Waiman Long
2026-04-26 13:48 ` Guopeng Zhang
2026-04-27 13:47 ` Waiman Long [this message]
2026-04-30 8:53 ` Guopeng Zhang
2026-04-30 12:39 ` Waiman Long
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=60bc60ba-670e-49f5-8482-54aed4563fae@redhat.com \
--to=longman@redhat.com \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=chenridong@huaweicloud.com \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox