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 16/33] sched/deadline: Keep the last CPU a task has in its root domain
Date: Fri, 20 Nov 2026 14:31:43 +0000 [thread overview]
Message-ID: <sashiko-outbox-225376@kernel.org> (raw)
In-Reply-To: <05ebb23f175aca8ebb3b93eeb2621f07a0a352a5.1795181240.git.mathieu.desnoyers@efficios.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] cgroup/cpuset: cpuset_offline_moves_dl() misses empty parent
partition
--
commit a61be9d5e1d2e372e16191df4de9a790c2bf73c9
Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
sched/deadline: Keep the last CPU a task has in its root domain
This commit refuses to take a CPU offline when doing so would leave a
deadline task with no runnable CPU in its admitting root domain, or when
invalidating a cpuset partition would move a deadline task into another
root domain.
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 7bdb9e21a7edb..ef95c730853e0 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
[ ... ]
> @@ -4312,6 +4334,233 @@ void cpuset_cpus_allowed(struct task_struct *tsk, struct cpumask *pmask)
> spin_unlock_irqrestore(&callback_lock, flags);
> }
>
> +/*
> + * Return true if @cs holds a task, or one of its cpusets that is not a
> + * valid partition root does. This is partition_is_populated() for the
> + * offline path, which holds the CPU hotplug lock for writing instead of
> + * cpuset_mutex. That lock keeps tasks from moving to another cgroup:
> + * cgroup_attach_lock() takes it. The caller holds rcu_read_lock().
> + */
> +static bool partition_populated_offline(struct cpuset *cs)
> +{
> + struct cgroup_subsys_state *pos_css;
> + struct cpuset *cp;
> +
> + if (cgroup_has_tasks(cs->css.cgroup))
> + return true;
> + cpuset_for_each_descendant_pre(cp, pos_css, cs) {
> + if (cp == cs)
> + continue;
> + if (is_partition_valid(cp)) {
> + pos_css = css_rightmost_descendant(pos_css);
> + continue;
> + }
> + if (cgroup_is_populated(cp->css.cgroup))
> + return true;
> + }
> + return false;
> +}
[ ... ]
> +bool cpuset_cpus_allowed_without(struct task_struct *tsk, int cpu,
> + struct cpumask *pmask)
> +{
> + const struct cpumask *possible = task_cpu_possible_mask(tsk);
> + struct cpuset *cs = task_cs(tsk), *from;
> +
> + guard(rcu)();
> + if (!is_in_v2_mode()) {
[ ... ]
> + } else {
> + /*
> + * cgroup v2 works out the CPUs of each cpuset from the top
> + * down. A cpuset keeps those of its parent that cpuset.cpus
> + * holds, or takes all of them if there are none. Start from
> + * the nearest partition root that keeps an active CPU, or from
> + * the top cpuset. A partition root left with no CPU of its own
> + * can take those of a child partition.
> + */
> + for (from = cs; ; from = parent_cs(from)) {
> + if (from != &top_cpuset && !is_partition_valid(from))
> + continue;
> + cpumask_and(pmask, from->effective_cpus, cpu_active_mask);
> + cpumask_clear_cpu(cpu, pmask);
> + if (cpumask_empty(pmask) && from != &top_cpuset &&
> + !partition_child_lost(from, cpu, pmask))
> + cpumask_clear(pmask);
> + if (!cpumask_empty(pmask) || from == &top_cpuset)
> + break;
> + }
> + effective_cpus_below(cs, from, pmask);
> + }
[ ... ]
> +bool cpuset_offline_moves_dl(int cpu)
> +{
> + struct cgroup_subsys_state *pos_css;
> + struct cpuset *cp, *a, *p = &top_cpuset, *lost = NULL;
> + bool found = false;
> +
> + if (!is_in_v2_mode())
> + return false;
> + rcu_read_lock();
> + cpuset_for_each_descendant_pre(cp, pos_css, &top_cpuset) {
> + if (cp != &top_cpuset && is_partition_valid(cp) &&
> + cpumask_test_cpu(cpu, cp->effective_cpus)) {
> + p = cp;
> + break;
> + }
> + }
> + if (p != &top_cpuset) {
> + lost = partition_child_lost(p, cpu, &dl_offline_cpus);
> + } else {
[Severity: Medium]
Can cpuset_offline_moves_dl() and cpuset_cpus_allowed_without() miss the
invalidation of a sibling partition when an unpopulated parent partition
delegates all of its active CPUs to child partitions?
Suppose an unpopulated partition parent_p with effective_xcpus {1, 2}
delegates CPU 1 to a populated child partition c1 and CPU 2 to a sibling
partition c2 created after c1, leaving parent_p->effective_cpus empty.
When CPU 1 goes offline, the pre-order walk in cpuset_handle_hotplug()
first invalidates c1 because it has no active CPUs left; c1 then counts
as populating parent_p, so visiting c2 next triggers
tasks_nocpu_error(parent_p, c2, &new_cpus) in
cpuset_hotplug_update_tasks() and invalidates c2 as well, giving CPU 2 to
parent_p and c1.
Before hotplug runs, cpuset_offline_moves_dl(1) finds p = c1, sees
partition_child_lost(c1, 1, &dl_offline_cpus) == NULL, and returns false
without checking whether invalidating c1 causes parent_p to invalidate c2.
Similarly, in cpuset_cpus_allowed_without() for a task in c1, walking up
to from = parent_p calls partition_populated_offline(parent_p), which
skips c1 because is_partition_valid(c1) is still true, causing
partition_child_lost(parent_p, 1, pmask) to return NULL and the loop to
walk past parent_p to top_cpuset. As a result, dl_bw_deactivate() can
accept an offline that moves deadline tasks in c1 or c2 into parent_p's
root domain without admission control.
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795181240.git.mathieu.desnoyers@efficios.com?part=16
next prev parent reply other threads:[~2026-11-20 14:31 UTC|newest]
Thread overview: 42+ 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 [this message]
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
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 14:58 ` sashiko-bot
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-225376@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.