Re: [PATCH 1/3] cgroup/cpuset: Protect is_in_v2_mode() in cpuset_num_cpus()
From: Peter Zijlstra
Date: Tue Sep 29 2026 - 15:10:07 EST
On Tue, Sep 29, 2026 at 02:10:40PM -0400, Waiman Long wrote:
> On 9/29/26 1:35 PM, Andrea Righi wrote:
> > > I think it is simpler to just change is_in_v2_mode() to cpuset_v2(). Almost
> > > 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().
> > The comment says that, outside cgroup v2, cpuset_num_cpus() falls back to
> > 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?
> I will let Peter decide if he wants to support the cpuset_v2_mode mount
> 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.
So I was not aware of this weird mount option at all. That said, ideally
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.