Re: [PATCH -next] cpuset: add cpuset1_online_css helper for v1-specific operations

From: Chen Ridong

Date: Tue Dec 16 2025 - 07:26:28 EST




On 2025/12/16 17:51, Michal Koutný wrote:
> On Tue, Dec 16, 2025 at 01:28:45AM +0000, Chen Ridong <chenridong@xxxxxxxxxxxxxxx> wrote:
>> From: Chen Ridong <chenridong@xxxxxxxxxx>
>>
>> This commit introduces the cpuset1_online_css helper to centralize
>> v1-specific handling during cpuset online. It performs operations such as
>> updating the CS_SPREAD_PAGE, CS_SPREAD_SLAB, and CGRP_CPUSET_CLONE_CHILDREN
>> flags, which are unique to the cpuset v1 control group interface.
>>
>> The helper is now placed in cpuset-v1.c to maintain clear separation
>> between v1 and v2 logic.
>
> It makes sense to me.
>
>> +/* v1-specific operation — caller must hold cpuset_full_lock. */
>> +void cpuset1_online_css(struct cgroup_subsys_state *css)
>> +{
>> + struct cpuset *tmp_cs;
>> + struct cgroup_subsys_state *pos_css;
>> + struct cpuset *cs = css_cs(css);
>> + struct cpuset *parent = parent_cs(cs);
>> +
>
> + lockdep_assert_held(&cpuset_mutex);
> + lockdep_assert_cpus_held();
>

Thanks for the feedback, Michal.

Regarding the lock assertions: cpuset_mutex is defined in cpuset.c and is not visible in
cpuset-v1.c. Given that cpuset v1 is deprecated, would you prefer that we add a helper to assert
cpuset_mutex is locked? Is that worth?

> When it's carved out from under cpuset_full_lock().
>
>
>> @@ -3636,39 +3630,8 @@ static int cpuset_css_online(struct cgroup_subsys_state *css)
>> cs->effective_mems = parent->effective_mems;
>> }
>> spin_unlock_irq(&callback_lock);
>> + cpuset1_online_css(css);
>
> guard with !is_in_v2mode()
>

Should we guard with !cpuset_v2() or !is_in_v2mode()?

In cgroup v1, if the cpuset is operating in v2 mode, are these flags still valid?

--
Best regards,
Ridong