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 v6 31/37] sched/deadline: Start a period for a task that enters the class blocked
Date: Mon, 16 Nov 2026 20:12:38 +0000 [thread overview]
Message-ID: <sashiko-outbox-217639@kernel.org> (raw)
In-Reply-To: <20261116190549.230119-32-mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] sched/deadline: unstarted period in switched_to_dl() when
!pi_blocked_on
- [Medium] sched/deadline: switched_to_dl() skips period reset on
boosted pre-0-lag task
- [Medium] sched/deadline: stale deadline on rt_mutex waiter when donor
or policy changes
--
commit 97588bc2bebff0e4575bb7d4c8f530868b8856a3
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
sched/deadline: Start a period for a task that enters the class blocked
This commit starts a new period in switched_to_dl() when a task blocked on
an rt_mutex enters dl_sched_class with an expired deadline so that the
rt_mutex waiter tree does not sort it with a deadline of 0.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 69a338c1526d0..ffa8b946e8047 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
[ ... ]
> @@ -4352,6 +4363,17 @@ static void switched_to_dl(struct rq *rq, struct task_struct *p)
> if (!task_on_rq_queued(p)) {
> add_rq_bw(&p->dl, &rq->dl);
>
> + /*
> + * A task that waits on an rt_mutex cannot wait for its wakeup.
> + * The chain walk sorts its waiter by its deadline first. A task
> + * new to the class has a deadline of 0, which goes before every
> + * real one. Start a new period now, as setup_new_dl_entity()
> + * does at an enqueue.
> + */
> + if (dl_task_pi_blocked(p) && !p->dl.dl_throttled &&
> + dl_time_before(p->dl.deadline, rq_clock(rq)))
> + replenish_dl_new_period(&p->dl, rq);
[Severity: Medium]
Does gating replenish_dl_new_period() on dl_task_pi_blocked(p) leave
p->dl.deadline at 0 when a sleeping task participates in rt_mutex priority
inheritance before waking up?
While a task sleeps in futex_wait_requeue_pi() on a non-PI futex,
p->pi_blocked_on is NULL. If sched_setattr() or a PI boost moves p into
dl_sched_class there, switched_to_dl() leaves p->dl.deadline at 0, and a
later FUTEX_CMP_REQUEUE_PI calls rt_mutex_start_proxy_lock() ->
task_blocks_on_rt_mutex() without waking p, queuing its waiter ahead of all
deadline waiters with deadline 0. Likewise, if a task holding an rt_mutex
is switched to SCHED_DEADLINE while sleeping on a non-rt_mutex wait,
p->dl.deadline stays 0 and rt_mutex_setprio() fails to boost p when a
deadline waiter with an earlier deadline blocks on that rt_mutex
(dl_entity_preempt(&pi_task->dl, &p->dl) is false against 0).
[Severity: Medium]
What happens when a task that left SCHED_DEADLINE before its 0-lag time is
PI-boosted back into dl_sched_class while blocked on an rt_mutex?
switched_from_dl() preserves p->dl.deadline and p->dl.dl_throttled until
inactive_timer fires. If p then blocks on an rt_mutex while holding
another and is boosted back into dl_sched_class, enqueue_task_dl() is not
called because p is not queued, and switched_to_dl() checks
!p->dl.dl_throttled && dl_time_before(p->dl.deadline, rq_clock(rq)) without
checking is_dl_boosted(&p->dl).
If p->dl.dl_throttled is still set, switched_to_dl() skips
replenish_dl_new_period() and leaves p throttled with its expired deadline;
if p->dl.dl_timer then fires while p is boosted, dl_task_timer() bails out
on is_dl_boosted(dl_se) without clearing dl_throttled, which prevents
enqueue_dl_entity() from queuing p after deboost. Even when p is not
throttled, if its old pre-0-lag p->dl.deadline is still in the future,
switched_to_dl() skips replenish_dl_new_period() and the chain walk sorts p
using its abandoned reservation's deadline instead of the donor's.
[Severity: Medium]
Does starting a period in switched_to_dl() leave p->dl.deadline stale if the
top PI donor on a blocked task changes while it remains in dl_sched_class?
If a non-deadline task p owns rt_mutex M1 and blocks on rt_mutex M2, an
initial deadline waiter W1 on M1 moves p into dl_sched_class and
switched_to_dl() sets p->dl.deadline from W1. If a second deadline waiter
W2 with a much earlier deadline then blocks on M1, rt_mutex_setprio(p, W2)
keeps prev_class == next_class == &dl_sched_class and sets p->dl.pi_se =
W2->dl.pi_se with ENQUEUE_REPLENISH. Because p is not queued,
sched_change_end() calls prio_changed_dl() instead of enqueue_task_dl() or
switched_to_dl(), leaving p->dl.deadline at W1's later deadline.
rt_mutex_adjust_prio_chain() then sees an unchanged waiter deadline and
stops the chain walk on M2, and when p later wakes up, update_dl_entity()
keeps W1's future deadline if dl_entity_overflow() is not triggered.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116190549.230119-1-mathieu.desnoyers@efficios.com?part=31
next prev parent reply other threads:[~2026-11-16 20:12 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 19:05 [PATCH v6 00/37] sched/deadline: bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 01/37] sched: Refuse SCHED_FLAG_KEEP_PARAMS that would change the policy or the class Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 02/37] sched/deadline: Do not admit bandwidth for parameters that are kept Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 03/37] sched: Let a task boosted by a deadline waiter change its policy Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 04/37] sched/deadline: Do not divide by zero active CPUs of a root domain Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 05/37] sched/deadline: Refuse dl_server debugfs writes while the rq is offline Mathieu Desnoyers
2026-11-16 19:30 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 06/37] sched: Take cpuset_mutex for a deadline policy change only with pi Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 07/37] sched/deadline: Do not lose a throttled task switched out and back Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 08/37] sched/deadline: Do not replenish a boost from cleared parameters Mathieu Desnoyers
2026-11-16 19:42 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 09/37] sched/deadline: Reset the deadline and the runtime with the parameters Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 10/37] sched/deadline: Reset the donor's runtime at a deboost in the class Mathieu Desnoyers
2026-11-16 19:38 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 11/37] sched/deadline: Release the bandwidth of a task that leaves the class asleep Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 12/37] sched/deadline: Reject SCHED_DEADLINE on exited tasks Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 13/37] sched/deadline: Keep departing bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 14/37] sched/deadline: Fix this_bw when a task is changed during a remote wakeup Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 15/37] sched/deadline: Rebuild the root domains' accounting from the task list Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 16/37] sched/deadline: Record the root domain holding a task's bandwidth Mathieu Desnoyers
2026-11-16 19:44 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 17/37] sched/deadline: Leave a dying task out of a rebuild of the accounting Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 18/37] sched/deadline: Check SCHED_DEADLINE affinity under the rq lock Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 19/37] sched/deadline: Move a task's bandwidth only where room was made Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 20/37] cgroup/cpuset: Wait for an attach before rebuilding the sched domains Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 21/37] sched: Make deadline policy and affinity changes wait for a cpuset attach Mathieu Desnoyers
2026-11-16 19:31 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 22/37] cgroup/cpuset: Give back the bandwidth an attach did not move Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 23/37] cgroup/cpuset: Reserve the bandwidth in the root domain a task moves to Mathieu Desnoyers
2026-11-16 19:56 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 24/37] sched/deadline: Make a rebuild count a task in the root domain it runs in Mathieu Desnoyers
2026-11-16 20:01 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 25/37] sched/deadline: Move a task's bandwidth to " Mathieu Desnoyers
2026-11-16 19:47 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 26/37] sched/deadline: Keep a task in the root domain that counts its bandwidth Mathieu Desnoyers
2026-11-16 19:50 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 27/37] sched/deadline: Keep the last CPU a task has in its root domain Mathieu Desnoyers
2026-11-16 19:51 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 28/37] cgroup/cpuset: Refuse to take a deadline task out of " Mathieu Desnoyers
2026-11-16 20:08 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 29/37] sched/deadline: Cancel the replenishment timer with the parameters Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 30/37] sched/deadline: Count the bandwidth a boosted task is given Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 31/37] sched/deadline: Start a period for a task that enters the class blocked Mathieu Desnoyers
2026-11-16 20:12 ` sashiko-bot [this message]
2026-11-16 19:05 ` [PATCH v6 32/37] sched/deadline: Check the runtime of a task that comes back runnable Mathieu Desnoyers
2026-11-16 20:08 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 33/37] sched/deadline: Check the runtime of a task whose parameters change Mathieu Desnoyers
2026-11-16 20:04 ` sashiko-bot
2026-11-16 19:05 ` [PATCH v6 34/37] sched/debug: Show the deadline bandwidth of each runqueue Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 35/37] selftests/sched: Add a test of SCHED_DEADLINE policy round trips Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 36/37] selftests/sched: Test SCHED_DEADLINE bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-16 19:05 ` [PATCH v6 37/37] selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting Mathieu Desnoyers
2026-11-16 19:49 ` sashiko-bot
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-217639@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox