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 v8 17/33] cgroup/cpuset: Refuse to take a deadline task out of its root domain
Date: Thu, 19 Nov 2026 20:43:31 +0000 [thread overview]
Message-ID: <sashiko-outbox-224041@kernel.org> (raw)
In-Reply-To: <b9c82782e39a90f12daa052f5189fbfc97e2eb11.1795116791.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] cgroup/cpuset: stale root domain check in
update_parent_effective_cpumask()
- [Medium] cgroup/cpuset: offline CPU mismatch in
dl_tasks_keep_without() for top_cpuset
--
commit b32b990dae89a854c1147c1874b9e7ba8e861a7d
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
cgroup/cpuset: Refuse to take a deadline task out of its root domain
This commit refuses cpuset cpumask updates and invalidates partitions that
would remove all CPUs of the root domain accounting a SCHED_DEADLINE task's
bandwidth.
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 5299652d47b6e..4350977601eb1 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 dl_tasks_keep_without() here reject a valid partition recovery with
PERR_DLTASK because the root domains have not been rebuilt yet?
This partcmd_update branch with newmask == NULL runs from
cpuset_hotplug_update_tasks() and update_cpumasks_hier() after
parent->effective_cpus has grown, but before rebuild_sched_domains_locked()
or rebuild_sched_domains_cpuslocked() updates rd->span.
For example, when 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}, update_cpumasks_hier() updates
parent->effective_cpus to {0, 1} and calls
update_parent_effective_cpumask(cp, partcmd_update, NULL, tmp) before
rebuilding sched domains. At that point dl_task_bw_span() for parent's
deadline task is still {0}, so dl_tasks_keep_without(parent, cp, {0}, NULL,
true) sees that parent's remaining CPU {1} does not intersect {0} and leaves
the child partition invalid with PERR_DLTASK. The same stale span check also
runs when a CPU comes online in cpuset_hotplug_update_tasks(), which then
migrates the task onto the newly onlined CPU anyway while leaving the
partition invalid.
> diff --git a/kernel/sched/deadline.c b/kernel/sched/deadline.c
> index eead45a0c1191..641674f65931f 100644
> --- a/kernel/sched/deadline.c
> +++ b/kernel/sched/deadline.c
> @@ -5141,6 +5141,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]
Does dl_task_keeps_root_domain() mismatch cpuset_update_tasks_cpumask() when
offline CPUs are present in top_cpuset?
For top_cpuset, dl_tasks_keep_without() builds new_mask from
top_cpuset.effective_cpus, which only contains active CPUs, whereas
cpuset_update_tasks_cpumask() passes possible_mask & ~subpartitions_cpus
(including offline CPUs) to set_cpus_allowed_ptr():
kernel/cgroup/cpuset.c:cpuset_update_tasks_cpumask() {
...
if (top_cs) {
if (task->flags & (PF_KTHREAD | PF_NO_SETAFFINITY))
continue;
cpumask_andnot(new_cpus, possible_mask, subpartitions_cpus);
} else {
cpumask_and(new_cpus, possible_mask, cs->effective_cpus);
}
set_cpus_allowed_ptr(task, new_cpus);
}
If a deadline task in top_cpuset has user_cpus_ptr set to {offline CPU,
online CPU X} and a partition takes CPU X, cpumask_intersects(new_mask,
p->user_cpus_ptr) is false because new_mask excludes the offline CPU, so
dl_task_keeps_root_domain() assumes user_cpus_ptr will be ignored and allows
the partition change. When cpuset_update_tasks_cpumask() then calls
set_cpus_allowed_ptr() with the offline CPU included in new_cpus,
__set_cpus_allowed_ptr() intersects with user_cpus_ptr down to the offline
CPU alone and fails with -EINVAL, leaving the top_cpuset deadline task bound
to CPU X inside the new partition.
In addition, cpumask_intersects(span, p->cpus_ptr) does not mask with
cpu_active_mask; because def_root_domain.span and top_cpuset tasks' cpus_ptr
both include all offline possible CPUs, that test stays true whenever any
possible CPU is offline even if p has no active CPUs in def_root_domain.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795116790.git.mathieu.desnoyers@efficios.com?part=17
next prev parent reply other threads:[~2026-11-19 20:43 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 20:15 [PATCH v8 00/33] sched/deadline: bandwidth accounting fixes and selftests Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 01/33] sched/deadline: Keep departing bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 02/33] sched/deadline: Rebuild the root domains' accounting from the task list Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 03/33] sched/deadline: Record the root domain holding a task's bandwidth Mathieu Desnoyers
2026-11-19 20:51 ` sashiko-bot
2026-11-19 20:15 ` [PATCH v8 04/33] sched/deadline: Leave a dying task out of a rebuild of the accounting Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 05/33] selftests/sched: Test SCHED_DEADLINE bandwidth across a root domain rebuild Mathieu Desnoyers
2026-11-19 20:28 ` sashiko-bot
2026-11-19 20:15 ` [PATCH v8 06/33] selftests/sched: Test the root domain rebuild in deadline_bw_test Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 07/33] sched/deadline: Move a task's bandwidth only where room was made Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 08/33] cgroup/cpuset: Wait for an attach before rebuilding the sched domains Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 09/33] sched: Make deadline policy and affinity changes wait for a cpuset attach Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 10/33] cgroup/cpuset: Give back the bandwidth an attach did not move Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 11/33] cgroup/cpuset: Reserve the bandwidth in the root domain a task moves to Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 12/33] selftests/sched: Test cpuset moves in deadline_bw_test Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 13/33] sched/deadline: Make a rebuild count a task in the root domain it runs in Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 14/33] sched/deadline: Move a task's bandwidth to " Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 15/33] sched/deadline: Keep a task in the root domain that counts its bandwidth Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 16/33] sched/deadline: Keep the last CPU a task has in its root domain Mathieu Desnoyers
2026-11-19 20:22 ` Mathieu Desnoyers
2026-11-19 20:48 ` sashiko-bot
2026-11-19 20:15 ` [PATCH v8 17/33] cgroup/cpuset: Refuse to take a deadline task out of " Mathieu Desnoyers
2026-11-19 20:43 ` sashiko-bot [this message]
2026-11-19 20:15 ` [PATCH v8 18/33] selftests/sched: Test the root domain of a task in deadline_bw_test Mathieu Desnoyers
2026-11-19 20:27 ` sashiko-bot
2026-11-19 20:15 ` [PATCH v8 19/33] sched/deadline: Count only active CPUs when spreading extra_bw Mathieu Desnoyers
2026-11-19 20:15 ` [PATCH v8 20/33] rtmutex: Continue the chain walk when a waiter's deadline donor changes Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 21/33] rtmutex: Continue the walk when the owner's top waiter changes lock Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 22/33] selftests/sched: Test the rtmutex chain walk in deadline_bw_test Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 23/33] sched/deadline: Reset the donor's runtime at a deboost in the class Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 24/33] sched/deadline: Replenish a throttled task boosted while asleep Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 25/33] sched/deadline: Count the bandwidth a boosted task is given Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 26/33] sched/deadline: Start a period for a task that enters the class blocked Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 27/33] sched/deadline: Start a period at a deboost out of the class Mathieu Desnoyers
2026-11-19 20:47 ` sashiko-bot
2026-11-19 20:16 ` [PATCH v8 28/33] selftests/sched: Test deadline boosts in deadline_bw_test Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 29/33] sched/deadline: Cancel the replenishment timer with the parameters Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 30/33] sched/deadline: Cap the runtime left of a constrained task at dl_runtime Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 31/33] sched/deadline: Check the runtime of a task that comes back runnable Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 32/33] sched/deadline: Check the runtime of a task whose parameters change Mathieu Desnoyers
2026-11-19 20:16 ` [PATCH v8 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-224041@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