Re: [PATCH 1/3] cgroup/cpuset: Protect is_in_v2_mode() in cpuset_num_cpus()
From: Waiman Long
Date: Tue Sep 29 2026 - 15:46:44 EST
On 9/29/26 3:08 PM, Peter Zijlstra wrote:
On Tue, Sep 29, 2026 at 02:10:40PM -0400, Waiman Long wrote:
On 9/29/26 1:35 PM, Andrea Righi wrote:So I was not aware of this weird mount option at all. That said, ideally
I will let Peter decide if he wants to support the cpuset_v2_mode mountI think it is simpler to just change is_in_v2_mode() to cpuset_v2(). AlmostThe comment says that, outside cgroup v2, cpuset_num_cpus() falls back to
all the cpuset functions should either take the callback_lock with interrupt
disabled (which is a RCU read-side critical section) or with rcu_read_lock()
and cpuset_mutex() acquired. This cpuset_num_cpus() function is an
exception. Given what is said in the comment, this function is not supposed
to be used with v1 mounted. We should change it to cpuset_v2().
num_online_cpus(). However, on v1 with cpu and cpuset mounted together using
cpuset_v2_mode, it returns the group's effective cpuset count and fair.c uses
that count in the default "concur" group share calculation and in "max" mode.
So replacing is_in_v2_mode() with cpuset_v2() would change scheduler behavior
for that setup. I guess we could either preserve the current behavior, fix the
comment and protect the root lookup with RCU; or make the code follow the
documented v2-only behavior. Which one would you prefer?
option of cgroup v1 since he is the original author of cpuset_num_cpus(). If
this is supported, we have to update the function comment as well.
it would work in the widest possible setting.
The main constraint is going from a cpu-cgroup to a cpuset-cgroup. It
was my understanding that this transition only works in v2, but if that
mount option is sufficient to make that cross-cgroup transition
meaningful, then yay I suppose.
The cpuset_v2_mode mount option is only for making the cpuset.cpus and cpuset.mems behave like in v2. The cpu-cgroup and cpuset-cgroup can still be in separate hierarchies. If cross-cgroup transition is the main point, it won't work with the cpuset_v2_mode mount option. We should switch to use cpuset_v2().
Cheers,
Longman