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 v9 17/33] cgroup/cpuset: Refuse to take a deadline task out of its root domain
Date: Fri, 20 Nov 2026 14:32:02 +0000 [thread overview]
Message-ID: <sashiko-outbox-225378@kernel.org> (raw)
In-Reply-To: <4baa44df95dd38644a85999954acce718b79661b.1795181240.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] sched/deadline: dl_task_keeps_root_domain() checks cpus_ptr
instead of cpus_mask
- [Medium] cgroup/cpuset: stale root domain check in
update_parent_effective_cpumask()
--
commit 4c72bde1a70aea14e6251ce1be702d2fe1b0466d
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
cgroup/cpuset: Refuse to take a deadline task out of its root domain
This commit rejects cpuset.cpus updates with -EBUSY and invalidates
partitions with PERR_DLTASK when a cpumask change would remove all CPUs
of the root domain accounting a deadline task's bandwidth.
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index ef95c730853e0..421e0bfc1c81e 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
[ ... ]
> @@ -2106,10 +2232,13 @@ static int update_parent_effective_cpumask(struct cpuset *cs, int cmd,
> }
> rcu_read_unlock();
> }
> - if (exclusive)
> - deleting = !cpumask_empty(tmp->delmask);
> - else
> + if (!exclusive)
> part_error = PERR_NOTEXCL;
> + else if (!dl_tasks_keep_without(parent, cs, tmp->delmask,
> + NULL, true))
> + part_error = PERR_DLTASK;
> + else
> + deleting = !cpumask_empty(tmp->delmask);
> }
> /*
> * When both cs and parent remain valid, parent's
[Severity: Medium]
Can this dl_tasks_keep_without() check fail with PERR_DLTASK against a
stale root domain span before the sched domains are rebuilt?
This branch (partcmd_update with newmask == NULL) runs from
update_cpumasks_hier() and cpuset_hotplug_update_tasks() after
parent->effective_cpus grows, but before rebuild_sched_domains_locked() or
rebuild_sched_domains_cpuslocked() updates rd->span to include the newly
added or onlined CPUs.
If a valid non-top partition parent holding CPU 0, a deadline task on CPU
0, and an invalid child partition requesting CPU 0 (previously PERR_NOCPUS)
is expanded to CPUs 0-1, dl_tasks_keep_without() checks parent's remaining
CPU 1 against the task's pre-rebuild dl_task_bw_span() of CPU 0 and keeps
the child invalid with PERR_DLTASK. Similarly, when a CPU comes online for
an invalid partition holding a deadline task on a fallback CPU,
dl_tasks_keep_without() tests the newly onlined CPU against the fallback
root domain span and sets PERR_DLTASK before hotplug_update_tasks() moves
the task onto the onlined CPU anyway.
[ ... ]
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index 2ed99b55d8a60..a21b504d467f3 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -5268,6 +5268,31 @@ int dl_bw_deactivate(int cpu)
> return ret;
> }
>
> +/*
> + * Return false if @p has CPUs in the root domain that counts its
> + * bandwidth and @new_mask holds none of them. A cpuset refuses such a
> + * mask: only a move to another cpuset makes room in another root domain.
> + * Like __set_cpus_allowed_ptr(), keep @new_mask within the affinity set by
> + * the user, if they intersect.
> + */
> +bool dl_task_keeps_root_domain(struct task_struct *p,
> + const struct cpumask *new_mask)
> +{
> + const struct cpumask *span;
> +
> + if (!dl_bandwidth_enabled() || !task_has_dl_policy(p))
> + return true;
> + /* pi_lock also protects p->user_cpus_ptr. */
> + guard(raw_spinlock_irqsave)(&p->pi_lock);
> + guard(rcu)();
> + span = dl_task_bw_span(p);
> + if (!span || !cpumask_intersects(span, p->cpus_ptr))
> + return true;
> + if (p->user_cpus_ptr && cpumask_intersects(new_mask, p->user_cpus_ptr))
> + return cpumask_intersects_and(span, new_mask, p->user_cpus_ptr);
> + return cpumask_intersects(span, new_mask);
> +}
[Severity: Medium]
Should dl_task_keeps_root_domain() check &p->cpus_mask instead of
p->cpus_ptr, as dl_task_leaves_span() and dl_task_rebuild_cpu() do?
When p is scheduled out inside a migrate_disable() section,
migrate_disable_switch() sets p->cpus_ptr to cpumask_of(rq->cpu) while
p->cpus_mask retains the task's allowed mask. If a domain rebuild (such
as switching an isolated partition covering housekeeping and isolated CPUs
back to a member cpuset) happens while p is scheduled out in
migrate_disable() on a housekeeping CPU, dl_task_rebuild_cpu() inspects
&p->cpus_mask and keeps p's bandwidth in def_root_domain. At that point
span intersects &p->cpus_mask but not p->cpus_ptr, so
cpumask_intersects(span, p->cpus_ptr) is false and a subsequent
cpuset.cpus write can strip all def_root_domain CPUs from p, moving its
bandwidth into the housekeeping root domain without admission control when
p wakes.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795181240.git.mathieu.desnoyers@efficios.com?part=17
next prev parent reply other threads:[~2026-11-20 14:32 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 13:55 [PATCH v9 00/33] sched/deadline: bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 01/33] sched/deadline: Keep departing bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 02/33] sched/deadline: Rebuild the root domains' accounting from the task list Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 03/33] sched/deadline: Record the root domain holding a task's bandwidth Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 04/33] sched/deadline: Leave a dying task out of a rebuild of the accounting Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 05/33] selftests/sched: Test SCHED_DEADLINE bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 06/33] selftests/sched: Test the root domain rebuild in deadline_bw_test Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 07/33] sched/deadline: Move a task's bandwidth only where room was made Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 08/33] cgroup/cpuset: Wait for an attach before rebuilding the sched domains Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 09/33] sched: Make deadline policy and affinity changes wait for a cpuset attach Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 10/33] cgroup/cpuset: Give back the bandwidth an attach did not move Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 11/33] cgroup/cpuset: Reserve the bandwidth in the root domain a task moves to Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 12/33] selftests/sched: Test cpuset moves in deadline_bw_test Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 13/33] sched/deadline: Make a rebuild count a task in the root domain it runs in Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 14/33] sched/deadline: Move a task's bandwidth to " Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 15/33] sched/deadline: Keep a task in the root domain that counts its bandwidth Mathieu Desnoyers
2026-11-20 14:12 ` sashiko-bot
2026-11-20 13:55 ` [PATCH v9 16/33] sched/deadline: Keep the last CPU a task has in its root domain Mathieu Desnoyers
2026-11-20 14:31 ` sashiko-bot
2026-11-20 13:55 ` [PATCH v9 17/33] cgroup/cpuset: Refuse to take a deadline task out of " Mathieu Desnoyers
2026-11-20 14:32 ` sashiko-bot [this message]
2026-11-20 13:55 ` [PATCH v9 18/33] selftests/sched: Test the root domain of a task in deadline_bw_test Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 19/33] sched/deadline: Count only active CPUs when spreading extra_bw Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 20/33] rtmutex: Continue the chain walk when a waiter's deadline donor changes Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 21/33] rtmutex: Continue the walk when the owner's top waiter changes lock Mathieu Desnoyers
2026-11-20 14:20 ` sashiko-bot
2026-11-20 13:55 ` [PATCH v9 22/33] selftests/sched: Test the rtmutex chain walk in deadline_bw_test Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 23/33] sched/deadline: Reset the donor's runtime at a deboost in the class Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 24/33] sched/deadline: Replenish a throttled task boosted while asleep Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 25/33] sched/deadline: Count the bandwidth a boosted task is given Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 26/33] sched/deadline: Start a period for a task that enters the class blocked Mathieu Desnoyers
2026-11-20 14:39 ` sashiko-bot
2026-11-20 13:55 ` [PATCH v9 27/33] sched/deadline: Start a period at a deboost out of the class Mathieu Desnoyers
2026-11-20 14:27 ` sashiko-bot
2026-11-20 13:55 ` [PATCH v9 28/33] selftests/sched: Test deadline boosts in deadline_bw_test Mathieu Desnoyers
2026-11-20 14:26 ` sashiko-bot
2026-11-20 13:55 ` [PATCH v9 29/33] sched/deadline: Cancel the replenishment timer with the parameters Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 30/33] sched/deadline: Cap the runtime left of a constrained task at dl_runtime Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 31/33] sched/deadline: Check the runtime of a task that comes back runnable Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 32/33] sched/deadline: Check the runtime of a task whose parameters change Mathieu Desnoyers
2026-11-20 13:55 ` [PATCH v9 33/33] selftests/sched: Test parameter changes in deadline_bw_test 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-225378@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
all inboxes | Powered by JetHome®