mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: sashiko-reviews@lists.linux.dev
Cc: linux-rt-devel@lists.linux.dev, tj@kernel.org,
	hannes@cmpxchg.org, mkoutny@suse.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 15/21] sched/deadline: Record the root domain holding a task's bandwidth
Date: Thu, 5 Nov 2026 14:11:21 -0500	[thread overview]
Message-ID: <550d3b35-5780-4726-82df-274b4d39d401@efficios.com> (raw)
In-Reply-To: <sashiko-outbox-198299@kernel.org>

On 2026-11-04 18:31, sashiko-bot@kernel.org wrote:
[...]
> 
> [Severity: High]
> Can root domain bandwidth accounting be corrupted during a rebuild when a
> departed task is boosted into dl_sched_class via priority inheritance before
> its 0-lag time expires?
> 
> When a SCHED_DEADLINE task leaves the deadline policy before its 0-lag time,
> switched_from_dl() arms inactive_timer and calls dl_task_depart(p) to link
> p->dl.dl_departed_node onto dl_departed_list with p->dl.dl_bw_cpu recording
> its root domain CPU. If p is then PI-boosted via rt_mutex_setprio() ->
> switched_to_dl(), dl_task_undepart(p) unlinks p->dl.dl_departed_node while
> preserving p->dl.dl_bw_cpu.
> 
> If dl_rebuild_rd_accounting() runs while p is PI-boosted,
> dl_add_task_root_domain(p) sees list_empty(&p->dl.dl_departed_node) == true:
> 
> 1. If p was moved to another cpuset partition while in SCHED_NORMAL (where no
> deadline admission check ran because !dl_task(p)), dl_add_task_root_domain(p)
> ignores p->dl.dl_bw_cpu, adds p->dl.dl_bw to the new cpuset's root domain via
> dl_get_task_effective_cpus(p), and overwrites p->dl.dl_bw_cpu with cpu. Or,
> if an earlier rebuild had already dropped p's departing bandwidth, this path
> resurrects p->dl.dl_bw into p's effective cpuset.
> 
> 2. Because rt_mutex_setprio() only holds p->pi_lock and rq->__lock (not
> cpuset_mutex or dl_accounting_mutex), p can be PI-boosted when
> dl_clear_root_domains() runs (so it is not on dl_departed_list and is not
> restored there) and then deboost via rt_mutex_setprio() -> switched_from_dl()
> before the task walk reaches p. switched_from_dl() puts p back onto
> dl_departed_list after dl_clear_root_domains() has already finished, and
> dl_add_task_root_domain(p) skips p because !dl_task(p) is now true, dropping
> p's active 0-lag bandwidth completely.
> 

[ Repeating answer to PATCH v2 09/21, which is also relevant here. ]

A departed task boosted into the class before its 0-lag time is counted
once, wherever a rebuild runs: the walk finds it in the class and counts
it in its cpuset's root domain, the record is updated, and the release at
the deboost reads the record. Where the deboost races the walk, the
departing bandwidth is dropped for the remaining lag, as it is for a
departed task whose recorded CPU went inactive; the generation keeps the
release out, so nothing underflows.

A rebuild that finds a CPU for a task an earlier one dropped counts it again,
which is the intent: the bandwidth of a departed task is held until its 0-lag
time.

> 3. For a regular non-deadline task with p->dl.dl_bw == 0 that is PI-boosted
> during a rebuild, dl_add_task_root_domain(p) unconditionally sets
> p->dl.dl_bw_cpu = cpu, leaving a non-negative dl_bw_cpu on a task with zero
> bandwidth after it deboosts.
> 
> Should a departed task stay on dl_departed_list across PI boost/deboost until
> its bandwidth is actually released, and should dl_add_task_root_domain(p) skip
> tasks with p->dl.dl_bw == 0?

Part 3 is fixed in v3: the walk skips a task with no bandwidth of its own, so a
boosted task gets no record. A departed task need not stay on the list across a
boost: the record stays, and the release at the deboost reads it.

> [Severity: Medium]
> Does updating a task's deadline parameters while it is asleep after moving to
> a new cpuset partition still use the stale task_cpu(p) root domain in
> __sched_setscheduler() and sched_dl_overflow()?

The EPERM is the baseline's affinity check of __sched_setscheduler(),
which compares the span of the runqueue the sleeping task is on with its
new mask; out of scope here. The uncounted path runs with admission
control off alone.

Thanks,

Mathieu

-- 
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com

  reply	other threads:[~2026-11-05 19:11 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 21:11 [PATCH v2 00/21] sched/deadline: bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-11-04 21:11 ` [PATCH v2 01/21] sched: Reject SCHED_FLAG_KEEP_PARAMS before reserving deadline bandwidth Mathieu Desnoyers
2026-11-05  7:14   ` Juri Lelli
2026-11-04 21:11 ` [PATCH v2 02/21] sched: Refuse SCHED_FLAG_KEEP_PARAMS that would change the policy Mathieu Desnoyers
2026-11-05  7:15   ` Juri Lelli
2026-11-04 21:11 ` [PATCH v2 03/21] sched/deadline: Do not admit bandwidth for parameters that are kept Mathieu Desnoyers
2026-11-05 10:20   ` Juri Lelli
2026-11-04 21:11 ` [PATCH v2 04/21] sched/deadline: Do not divide by zero active CPUs of a root domain Mathieu Desnoyers
2026-11-04 21:46   ` sashiko-bot
2026-11-05 19:11     ` Mathieu Desnoyers
2026-11-05 10:53   ` Juri Lelli
2026-11-04 21:11 ` [PATCH v2 05/21] sched/deadline: Do not BUG() on a deadline task with no active CPU allowed Mathieu Desnoyers
2026-11-05 10:59   ` Juri Lelli
2026-11-04 21:11 ` [PATCH v2 06/21] sched/deadline: Do not lose a throttled task switched out and back Mathieu Desnoyers
2026-11-04 22:09   ` sashiko-bot
2026-11-05 14:48   ` Juri Lelli
2026-11-04 21:11 ` [PATCH v2 07/21] sched/deadline: Do not release a departing sleeper's bandwidth twice Mathieu Desnoyers
2026-11-04 22:15   ` sashiko-bot
2026-11-05 19:11     ` Mathieu Desnoyers
2026-11-04 21:11 ` [PATCH v2 08/21] selftests/sched: Add a test of SCHED_DEADLINE policy round trips Mathieu Desnoyers
2026-11-05 15:00   ` Juri Lelli
2026-11-04 21:11 ` [PATCH v2 09/21] sched/deadline: Keep departing bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-04 22:44   ` sashiko-bot
2026-11-05 19:11     ` Mathieu Desnoyers
2026-11-04 21:11 ` [PATCH v2 10/21] selftests/sched: Test SCHED_DEADLINE " Mathieu Desnoyers
2026-11-04 21:11 ` [PATCH v2 11/21] sched/deadline: Do not take a waking task's bandwidth off a runqueue it left Mathieu Desnoyers
2026-11-04 21:11 ` [PATCH v2 12/21] sched/debug: Show the deadline bandwidth of each runqueue Mathieu Desnoyers
2026-11-04 21:11 ` [PATCH v2 13/21] sched/deadline: Rebuild the root domains' accounting without cpusets too Mathieu Desnoyers
2026-11-04 23:18   ` sashiko-bot
2026-11-04 21:12 ` [PATCH v2 14/21] selftests/sched: Add a test of SCHED_DEADLINE bandwidth accounting Mathieu Desnoyers
2026-11-04 21:12 ` [PATCH v2 15/21] sched/deadline: Record the root domain holding a task's bandwidth Mathieu Desnoyers
2026-11-04 23:31   ` sashiko-bot
2026-11-05 19:11     ` Mathieu Desnoyers [this message]
2026-11-04 21:12 ` [PATCH v2 16/21] sched/deadline: Move a task's bandwidth only where room was made Mathieu Desnoyers
2026-11-04 21:12 ` [PATCH v2 17/21] cgroup/cpuset: Give back the bandwidth an attach did not move Mathieu Desnoyers
2026-11-04 23:56   ` sashiko-bot
2026-11-04 21:12 ` [PATCH v2 18/21] sched/deadline: Credit a rebuild to a CPU that can hold the bandwidth Mathieu Desnoyers
2026-11-05  0:18   ` sashiko-bot
2026-11-04 21:12 ` [PATCH v2 19/21] sched: Clear cpuset_locked where the policy check retries Mathieu Desnoyers
2026-11-05 16:43   ` Andrea Parri
2026-11-05 17:08     ` Mathieu Desnoyers
2026-11-05 17:28       ` Andrea Parri
2026-11-04 21:12 ` [PATCH v2 20/21] sched/deadline: Cancel the replenishment timer with the parameters Mathieu Desnoyers
2026-11-05  0:25   ` sashiko-bot
2026-11-04 21:12 ` [PATCH v2 21/21] sched/deadline: Count the bandwidth a boosted task is given Mathieu Desnoyers
2026-11-05  0:36   ` sashiko-bot
     [not found] ` <CGME20261105111941eucas1p1b50e9720b000ca86204aff3977c9fcbb@eucas1p1.samsung.com>
2026-11-05 11:19   ` [PATCH v2 00/21] sched/deadline: bandwidth accounting fixes and selftests Marek Szyprowski

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=550d3b35-5780-4726-82df-274b4d39d401@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --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

all inboxes | Powered by JetHome®