Re: [PATCH v14 16/39] cgroup/cpuset: Wait for an attach before rebuilding the sched domains

From: sashiko-bot

Date: Thu Dec 03 2026 - 11:22:28 EST


Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Low] cgroup/cpuset: duplicated cpuset_full_lock() in cpuset write
handlers
- [Low] cgroup/cpuset: commit message inaccurately claims CPU hotplug
never waits
--

commit e516c72d81ecf2f1dd9c839b6545bc2ce4e858aa
Author: Mathieu Desnoyers <mathieu.desnoyers@xxxxxxxxxxxx>

cgroup/cpuset: Wait for an attach before rebuilding the sched domains

This commit updates cpuset_full_lock() and
rebuild_sched_domains_cpuslocked() to call wait_attach_done_lock()
instead of mutex_lock(&cpuset_mutex), preventing sched domain rebuilds
from dropping deadline bandwidth reservations made during a cpuset
attach.

> Fix this by waiting for an attach in progress in
> rebuild_sched_domains_cpuslocked() and in cpuset_full_lock(). The
> latter then takes its locks in the order of the writes of cpus and
> cpus.partition. Two kinds of callers never wait:
> - a rebuild from CPU hotplug finds no attach in progress;

[Severity: Low]
Is the claim that a rebuild from CPU hotplug never waits accurate?

cpuset_can_fork() also increments attach_ctx.in_progress on
CLONE_INTO_CGROUP without holding cpus_read_lock(). CPU hotplug
reaching rebuild_sched_domains_cpuslocked() can therefore wait for
cpuset_fork() or cpuset_cancel_fork() to finish.

Memory hotplug via cpuset_track_online_nodes() also calls
cpuset_handle_hotplug() under cpus_read_lock(), so it can wait on
regular attach migrations when subpartitions_cpus is non-empty.

[ ... ]

> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 194a438e25c31..51b6be4607946 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -296,17 +296,20 @@ void lockdep_assert_cpuset_lock_held(void)
> lockdep_assert_held(&cpuset_mutex);
> }
>
> +static void wait_attach_done_lock(void) __acquires(&cpuset_mutex);
> +
> /**
> * cpuset_full_lock - Acquire full protection for cpuset modification
> *
> * Takes both CPU hotplug read lock (cpus_read_lock()) and cpuset mutex
> - * to safely modify cpuset data.
> + * to safely modify cpuset data. Waits for an attach in progress before
> + * it takes cpuset mutex.
> */
> void cpuset_full_lock(void)
> {
> mutex_lock(&cpuset_top_mutex);
> cpus_read_lock();
> - mutex_lock(&cpuset_mutex);
> + wait_attach_done_lock();
> }

[Severity: Low]
Now that cpuset_full_lock() runs this three-step sequence, can
cpuset_write_resmask() and cpuset_partition_write() call it instead of
open-coding the same locks? Duplicating the sequence risks future
divergence if the cpuset full-locking order changes.

--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796296313.git.mathieu.desnoyers@xxxxxxxxxxxx?part=16