From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Juri Lelli <juri.lelli@redhat.com>
Cc: peterz@infradead.org, mingo@redhat.com,
vincent.guittot@linaro.org, tglx@kernel.org, will@kernel.org,
boqun@kernel.org, dietmar.eggemann@arm.com, rostedt@goodmis.org,
bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
kprateek.nayak@amd.com, luca.abeni@santannapisa.it,
tommaso.cucinotta@gmail.com, mathieu.poirier@linaro.org,
longman@redhat.com, ridong.chen@linux.dev, tj@kernel.org,
hannes@cmpxchg.org, mkoutny@suse.com, shuah@kernel.org,
bigeasy@linutronix.de, clrkwllms@kernel.org,
parri.andrea@gmail.com, m.szyprowski@samsung.com,
kayracizmeci@gmail.com, weihengqiuu@gmail.com,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-rt-devel@lists.linux.dev,
oleg@redhat.com, brauner@kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH v13 05/36] sched/deadline: Keep a departing constrained task until its next period
Date: Wed, 2 Dec 2026 13:02:13 -0500 [thread overview]
Message-ID: <9430f4cd-bdb6-4003-98a2-740296aed499@efficios.com> (raw)
In-Reply-To: <axAxdNEE1Q2OuxNQ@jlelli-thinkpadt14gen4.remote.csb>
Hi Juri,
On 2026-12-02 15:55, Juri Lelli wrote:
[...]
> The fixes first; neither is new with this series.
>
> 1. check_dl_overrun() clears dl_overrun with a plain store, without the
> rq lock.
[...]
> Clearing it under
> task_rq_lock() should do (siglock -> pi_lock -> rq lock is already a
> valid order, from signal_wake_up_state()).
Agreed. The planned next version will have it as a new patch, right
after patch 4. check_dl_overrun() will call a new helper,
dl_task_clear_overrun(), which clears the flag under task_rq_lock().
> This is also the reason dl_inactive_pending is a bool at the end of
> the struct (8 bytes more per task at this point of the series)? With
> dl_overrun fixed, it can be a bit like the others.
Yes, that was the reason. With your approach below, the planned next
version will not need dl_inactive_pending at all.
> 2. sched_dl_overflow() admits a task coming back to SCHED_DEADLINE
> before its 0-lag time with old_bw = 0:
[...]
> Discounting it when the timer is active (and, after your patch 6, when
> the recorded root domain is this dl_b) would make the two consistent,
> and would also close the window where patch 6 counts both.
Agreed. It will be the second new patch. A new case of patch 30,
params_return_full, tests it. In a partition with no room for two tasks
of 60%, a task of 60% leaves the class and comes back before its 0-lag
time. Without the fix, the return gets EBUSY.
From patch 6 on, a departed task records the CPU whose root domain
counts its old bandwidth. The old bandwidth will be discounted only if
the task comes back in that root domain. sched_dl_overflow() will then
swap the old and the new bandwidth in one lock section. If the task
comes back in another root domain, the old bandwidth is still removed
in a second lock section. The cover letter will list that as a known
limit.
> Could you add these two as separate patches ahead of this one (or I can
> send them, if you prefer)?
I will add them, with your Reported-by.
> Now the approach. IIUC, the only thing a returning constrained task
> needs is its deadline.
[...]
> So, what about keeping the release at the 0-lag time as it is now, and,
> for constrained tasks only, clearing the runtime but keeping the
> deadline when we release?
Yes, this works, and the planned next version will do this. The rule
will be a new helper, dl_release_params(), called in the two release
paths. The timer restart and dl_inactive_pending will be gone. The
patch will add about 30 lines, more than half of them a comment.
reenter_asleep_late_in_gap runs the example of the changelog of this
patch. The task wakes up at 155ms, after its deadline and before its
next period. If dl_release_params() also clears the deadline, the case
fails in 3 of 3 runs: the task runs right after its wakeup. With the
deadline kept, it passes in 3 of 3 runs.
Two details:
- "Record the start of the period" (patch 28) adds a field,
period_start. Patch 29 computes the next period from it. So
dl_release_params() will keep period_start with the deadline.
- Your sketch leaves a runtime of 0. A task that comes back before its
deadline with no runtime left is not throttled at once. It runs
until the next tick, and pays that back at its next replenishment.
"Keep the debt of a task across a change of parameters" (patch 29)
makes enqueue_dl_entity() throttle it at once.
There are two costs, which the cover letter will list:
- A constrained task that leaves with much runtime left can reach its
0-lag time before its deadline. If it comes back between the two, it
has no runtime left until its next period. Had it stayed in the
class, it could have used that runtime until its deadline.
- A priority inheritance boost of a departed task replaces the deadline
it kept, and the deboost clears it. If the task then comes back
before its next period, it starts a new period at once. The priority
inheritance series will handle this case.
One question. The inactive timer can be armed in one period. Its
handler can then wait for the rq lock while the task runs a new period.
If the task leaves the class then, task_non_contending() releases the
bandwidth at once, as on v7.4-rc2. This is before the 0-lag time of the
new period. The root domain can then admit another task into that
bandwidth too early. The task itself keeps its deadline, so it gains no
runtime. v13 closed this window with the timer restart. Is this window
fine with you, or should the planned next version close it?
> If you see something that breaks with it, I'd still
> suggest splitting the current version: the bail in inactive_task_timer()
> for a task back in the class looks like a standalone fix (exit race,
> already on v7.4-rc2), then dl_inactive_pending on its own, then the
> rule. Reading the state once in task_non_contending() (it is read up to
> four times now) would also help.
The bail will be a patch of its own, after the two fixes above. As you
say, it fixes a race of v7.4-rc2. A task can wake up and die while the
handler waits for the rq lock. Its last dequeue then leaves its
bandwidth in running_bw and this_bw. The changelog will have the
sequence as a diagram.
With the rework, task_non_contending() reads the task state twice, as
on v7.4-rc2. Patch 6 adds a third read, for a dying task.
The full test suite passes on the reworked series.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2026-12-02 18:02 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 17:43 [PATCH v13 00/36] sched/deadline: bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-12-01 17:43 ` [PATCH v13 01/36] sched/deadline: Hold a reference on the deadline donor of a boosted task Mathieu Desnoyers
2026-12-02 9:43 ` Juri Lelli
2026-12-01 17:43 ` [PATCH v13 02/36] sched/deadline: Replenish a throttled task boosted while asleep Mathieu Desnoyers
2026-12-01 17:43 ` [PATCH v13 03/36] sched/deadline: Do not truncate a bandwidth to 32 bits in __dl_add/sub() Mathieu Desnoyers
2026-12-01 17:43 ` [PATCH v13 04/36] sched/deadline: Count the 0-lag time from the next period Mathieu Desnoyers
2026-12-01 17:43 ` [PATCH v13 05/36] sched/deadline: Keep a departing constrained task until its " Mathieu Desnoyers
2026-12-01 18:17 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-02 14:55 ` Juri Lelli
2026-12-02 18:02 ` Mathieu Desnoyers [this message]
2026-12-03 7:27 ` Juri Lelli
2026-12-01 17:44 ` [PATCH v13 06/36] sched/deadline: Keep departing bandwidth across a root domain rebuild Mathieu Desnoyers
2026-12-01 18:20 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 07/36] sched/deadline: Rebuild the root domains' accounting from the task list Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 08/36] sched/deadline: Record the root domain holding a task's bandwidth Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 09/36] sched/deadline: Leave a dying task out of a rebuild of the accounting Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 10/36] selftests/sched: Test SCHED_DEADLINE bandwidth across a root domain rebuild Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 11/36] selftests/sched: Test the root domain rebuild in deadline_bw_test Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 12/36] sched/deadline: Move a task's bandwidth only where room was made Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 13/36] cgroup/cpuset: Wait for an attach before rebuilding the sched domains Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 14/36] sched: Make deadline policy and affinity changes wait for a cpuset attach Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 15/36] cgroup/cpuset: Give back the bandwidth an attach did not move Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 16/36] cgroup/cpuset: Reserve the bandwidth in the root domain a task moves to Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 17/36] selftests/sched: Test cpuset moves in deadline_bw_test Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 18/36] sched/deadline: Make a rebuild count a task in the root domain it runs in Mathieu Desnoyers
2026-12-01 19:11 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 19/36] sched/deadline: Move a task's bandwidth to " Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 20/36] sched/deadline: Keep a task in the root domain that counts its bandwidth Mathieu Desnoyers
2026-12-01 19:02 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 21/36] sched/deadline: Keep the last CPU a task has in its root domain Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 22/36] cgroup/cpuset: Refuse to take a deadline task out of " Mathieu Desnoyers
2026-12-01 19:29 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 23/36] selftests/sched: Test the root domain of a task in deadline_bw_test Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 24/36] sched/deadline: Count only active CPUs when spreading extra_bw Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 25/36] sched/deadline: Cancel the replenishment timer with the parameters Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 26/36] sched/deadline: Cap the runtime left of a constrained task at dl_runtime Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 27/36] sched/deadline: Check the runtime of a task that comes back runnable Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 28/36] sched/deadline: Record the start of the period Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 29/36] sched/deadline: Keep the debt of a task across a change of parameters Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 30/36] selftests/sched: Test parameter changes in deadline_bw_test Mathieu Desnoyers
2026-12-01 19:34 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 31/36] sched/deadline: Count a task that departs while a rebuild walks the tasks Mathieu Desnoyers
2026-12-01 19:41 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 32/36] sched/deadline: Count again a departed task that a boost brings back Mathieu Desnoyers
2026-12-01 19:47 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 33/36] sched/deadline: Keep a reaped deadline task in a rebuild Mathieu Desnoyers
2026-12-01 19:57 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 34/36] sched/deadline: Warn when a runqueue keeps the bandwidth of a task Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 35/36] selftests/sched: Test PI against hotplug and rebuilds in deadline_bw_test Mathieu Desnoyers
2026-12-01 19:51 ` sashiko-bot
2026-12-02 14:54 ` Mathieu Desnoyers
2026-12-01 17:44 ` [PATCH v13 36/36] selftests/sched: Share the helpers of the deadline tests 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=9430f4cd-bdb6-4003-98a2-740296aed499@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=bigeasy@linutronix.de \
--cc=boqun@kernel.org \
--cc=brauner@kernel.org \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=clrkwllms@kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=kayracizmeci@gmail.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=longman@redhat.com \
--cc=luca.abeni@santannapisa.it \
--cc=m.szyprowski@samsung.com \
--cc=mathieu.poirier@linaro.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=oleg@redhat.com \
--cc=parri.andrea@gmail.com \
--cc=peterz@infradead.org \
--cc=ridong.chen@linux.dev \
--cc=rostedt@goodmis.org \
--cc=shuah@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=tj@kernel.org \
--cc=tommaso.cucinotta@gmail.com \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=weihengqiuu@gmail.com \
--cc=will@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
all inboxes | Powered by JetHome®