From: sashiko-bot@kernel.org
To: "Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>
Cc: linux-rt-devel@lists.linux.dev, tj@kernel.org,
hannes@cmpxchg.org, mkoutny@suse.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 12/16] sched/deadline: Fix this_bw when a task is changed during a remote wakeup
Date: Wed, 18 Nov 2026 20:46:51 +0000 [thread overview]
Message-ID: <sashiko-outbox-221950@kernel.org> (raw)
In-Reply-To: <dfe9865764c347295703c25e9a781438784f061b.1795031605.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: this_bw desync in add_rq_bw() for PI-boosted
tasks
--
commit 31f5271550e5299348b26e477800f7ac60f7e6c1
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
sched/deadline: Fix this_bw when a task is changed during a remote wakeup
This commit introduces a dl_bw_oncpu bit in struct sched_dl_entity to track
whether a runqueue's this_bw currently accounts for the task's bandwidth,
preventing bandwidth drift when parameters change during a remote wakeup.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index f0e03f97fd82f..c36516210669d 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -267,18 +267,35 @@ void __sub_rq_bw(u64 dl_bw, struct dl_rq *dl_rq)
> WARN_ON_ONCE(dl_rq->running_bw > dl_rq->this_bw);
> }
>
> +/*
> + * @dl_se->dl_bw_oncpu tells whether the this_bw of a runqueue counts the
> + * bandwidth of @dl_se. add_rq_bw() adds the bandwidth only if no runqueue
> + * counts it. sub_rq_bw() subtracts it only if one does.
> + *
> + * A wakeup on another CPU takes the bandwidth off the old runqueue. The
> + * enqueue on the new CPU adds it back later. A change of the task in
> + * between must not count the bandwidth twice, nor take it off a runqueue
> + * that does not count it.
> + *
> + * The servers track their bandwidth with dl_bw_attached. They call
> + * __add_rq_bw() and __sub_rq_bw() directly.
> + */
> static inline
> void add_rq_bw(struct sched_dl_entity *dl_se, struct dl_rq *dl_rq)
> {
> - if (!dl_entity_is_special(dl_se))
> - __add_rq_bw(dl_se->dl_bw, dl_rq);
> + if (dl_entity_is_special(dl_se) || dl_se->dl_bw_oncpu)
> + return;
> + __add_rq_bw(dl_se->dl_bw, dl_rq);
> + dl_se->dl_bw_oncpu = 1;
> }
[Severity: Medium]
Can add_rq_bw() set dl_bw_oncpu = 1 while dl_se->dl_bw is 0 for a PI-boosted
non-deadline task, causing dl_rq->this_bw to miss a later SCHED_DEADLINE
bandwidth assignment?
When a non-deadline task (dl_runtime == 0, dl_bw == 0) is PI-boosted into
dl_sched_class via rt_mutex_setprio(), enqueue_dl_entity(ENQUEUE_RESTORE) or
switched_to_dl() calls add_rq_bw(), which adds 0 to this_bw and sets
dl_bw_oncpu = 1.
If sched_setattr() assigns SCHED_DEADLINE with new_bw > 0 while the boosted
task is unqueued (either sleeping or on a remote wake_list), prev_class and
next_class are both &dl_sched_class so ENQUEUE_CLASS is not set, and
!task_has_dl_policy(p) is true so sched_dl_overflow() skips
dl_change_utilization(). __setparam_dl() then sets p->dl.dl_bw = new_bw
while dl_bw_oncpu is already 1 and this_bw still has 0.
When the task finishes waking up, task_contending() calls add_rq_bw(), which
returns early because dl_bw_oncpu is 1, and then add_running_bw() adds new_bw
to running_bw, triggering WARN_ON_ONCE(dl_rq->running_bw > dl_rq->this_bw).
When the task later migrates, leaves SCHED_DEADLINE, or exits, sub_rq_bw()
subtracts new_bw and underflows this_bw. Should add_rq_bw() also return
early when !dl_se->dl_bw (or !dl_se->dl_runtime)?
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795031605.git.mathieu.desnoyers@efficios.com?part=12
next prev parent reply other threads:[~2026-11-18 20:46 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 20:06 [PATCH 00/16] sched/deadline: first bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 01/16] sched: Refuse SCHED_FLAG_KEEP_PARAMS that would change the policy or the class Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 02/16] sched/deadline: Do not admit bandwidth for parameters that are kept Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 03/16] sched: Let a task boosted by a deadline waiter change its policy Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 04/16] sched/deadline: Do not divide by zero active CPUs of a root domain Mathieu Desnoyers
2026-11-18 20:23 ` sashiko-bot
2026-11-18 21:08 ` Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 05/16] sched/deadline: Refuse dl_server debugfs writes while the rq is offline Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 06/16] sched: Take cpuset_mutex for a deadline policy change only with pi Mathieu Desnoyers
2026-11-18 20:17 ` sashiko-bot
2026-11-18 21:09 ` Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 07/16] sched/deadline: Do not lose a throttled task switched out and back Mathieu Desnoyers
2026-11-18 20:31 ` sashiko-bot
2026-11-18 21:09 ` Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 08/16] sched/deadline: Do not replenish a boost from cleared parameters Mathieu Desnoyers
2026-11-18 20:35 ` sashiko-bot
2026-11-18 21:10 ` Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 09/16] sched/deadline: Reset the deadline and the runtime with the parameters Mathieu Desnoyers
2026-11-18 20:38 ` sashiko-bot
2026-11-18 21:10 ` Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 10/16] sched/deadline: Release the bandwidth of a task that leaves the class asleep Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 11/16] sched/deadline: Reject SCHED_DEADLINE on exited tasks Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 12/16] sched/deadline: Fix this_bw when a task is changed during a remote wakeup Mathieu Desnoyers
2026-11-18 20:46 ` sashiko-bot [this message]
2026-11-18 21:11 ` Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 13/16] sched/deadline: Check SCHED_DEADLINE affinity under the rq lock Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 14/16] sched/debug: Show the deadline bandwidth of each runqueue Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 15/16] selftests/sched: Add a test of SCHED_DEADLINE policy round trips Mathieu Desnoyers
2026-11-18 20:06 ` [PATCH 16/16] selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting Mathieu Desnoyers
2026-11-18 21:04 ` sashiko-bot
2026-11-18 21:12 ` Mathieu Desnoyers
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=sashiko-outbox-221950@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=mathieu.desnoyers@efficios.com \
--cc=mkoutny@suse.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tj@kernel.org \
/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.