All of lore.kernel.org
 help / color / mirror / Atom feed
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 v13 20/36] sched/deadline: Keep a task in the root domain that counts its bandwidth
Date: Tue, 01 Dec 2026 19:02:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-244007@kernel.org> (raw)
In-Reply-To: <ed252d9e5a0378c5b212bef2da7b6892ca5fd92b.1796146461.git.mathieu.desnoyers@efficios.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] sched/deadline: stale dl_bw_def for departed tasks in
  dl_clear_root_domains()
--

commit 951a7fe2fe695c77ff8cf06e107558af78b19d1b
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>

sched/deadline: Keep a task in the root domain that counts its bandwidth

This commit introduces dl_task_bw_span() and dl_bw_def tracking to keep
SCHED_DEADLINE tasks and their bandwidth in the root domain that admitted
them across CPU selection, hotplug, and sched domain rebuilds.

> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 67dfd3e11832b..0a925f91ebec7 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c

[ ... ]

> @@ -4272,7 +4465,7 @@ void dl_add_task_root_domain(struct task_struct *p)
>  	raw_spin_lock(&dl_b->lock);
>  	__dl_add(dl_b, p->dl.dl_bw, cpumask_weight(rq->rd->span));
>  	raw_spin_unlock(&dl_b->lock);
> -	p->dl.dl_bw_cpu = cpu;
> +	dl_record_bw_cpu(&p->dl, cpu);
>  	p->dl.dl_bw_gen = dl_bw_gen;
>  unlock:
>  	raw_spin_unlock(&dl_departed_lock);
> @@ -4428,7 +4621,11 @@ void dl_clear_root_domains(void)
>  	 * has not reached still waits for it: see dl_bw_move_blocked().
>  	 */
>  	WARN_ON_ONCE(!(dl_bw_rebuild_seq & 1));
> -	WRITE_ONCE(dl_bw_rebuild_seq, dl_bw_rebuild_seq + 1);
> +	/*
> +	 * After the writes of rq->rd and of dl_bw_gen: pairs with the
> +	 * acquire in dl_task_bw_rd().
> +	 */
> +	smp_store_release(&dl_bw_rebuild_seq, dl_bw_rebuild_seq + 1);
>  	WRITE_ONCE(dl_bw_walking, true);
>  	for_each_possible_cpu(cpu) {
>  		if (!dl_bw_visited(cpu, cookie))

[Severity: Medium]
Should the dl_departed_list loop in dl_clear_root_domains() also call
dl_record_bw_cpu(dl_se, cpu) when it re-counts a departed task's bandwidth?

kernel/sched/deadline.c:dl_clear_root_domains() {
    ...
	list_for_each_entry(dl_se, &dl_departed_list, dl_departed_node) {
		cpu = dl_se->dl_bw_cpu;
    ...
		dl_b = dl_bw_of(cpu);
		raw_spin_lock(&dl_b->lock);
		__dl_add(dl_b, dl_se->dl_bw, dl_bw_cpus(cpu));
		raw_spin_unlock(&dl_b->lock);
		dl_se->dl_bw_gen = dl_bw_gen;
	}
}

If the rebuild moved cpu into or out of def_root_domain (for example, when
a cpuset partition changes between root and isolated), dl_se->dl_bw_def is
left stale, and dl_add_task_root_domain() skips the task because
dl_se->dl_bw_gen is already equal to dl_bw_gen.  If priority inheritance
then boosts the task back into dl_sched_class before its 0-lag time and
another rebuild runs, dl_task_rebuild_cpu() will read the stale dl_bw_def
and move the bandwidth to the wrong side without admission control.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796146461.git.mathieu.desnoyers@efficios.com?part=20

  reply	other threads:[~2026-12-01 19:02 UTC|newest]

Thread overview: 47+ 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-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-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-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-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 [this message]
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-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-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-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-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-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-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=sashiko-outbox-244007@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.