[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <921ab4b4-0713-4c33-9c11-eac234ab9d39@huaweicloud.com>
Date: Mon, 24 Nov 2025 19:33:54 +0800
From: Chen Ridong <chenridong@...weicloud.com>
To: Sun Shaojie <sunshaojie@...inos.cn>
Cc: cgroups@...r.kernel.org, hannes@...xchg.org,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
llong@...hat.com, mkoutny@...e.com, shuah@...nel.org, tj@...nel.org
Subject: Re: [PATCH v5] cpuset: Avoid invalidating sibling partitions on
cpuset.cpus conflict.
On 2025/11/24 18:20, Sun Shaojie wrote:
> Hi, Ridong,
>
> On Sat, 22 Nov 2025 09:33:34, Chen Ridong wrote:
>> On 2025/11/21 18:32, Sun Shaojie wrote:
>>> Hi, Ridong,
>>>
>>> On Thu, 20 Nov 2025 21:45:16, Chen Ridong wrote:
>>>> On 2025/11/20 21:07, Sun Shaojie wrote:
>>>>> I have carefully considered the scenario where parent effective CPUs are
>>>>> empty, which corresponds to the following two cases. (After apply this patch).
>>>>>
>>>>> root cgroup
>>>>> |
>>>>> A1
>>>>> / \
>>>>> A2 A3
>>>>>
>>>>> Case 1:
>>>>> Step:
>>>>> #1> echo "0-1" > A1/cpuset.cpus
>>>>> #2> echo "root" > A1/cpuset.cpus.partition
>>>>> #3> echo "0-1" > A2/cpuset.cpus
>>>>> #4> echo "root" > A2/cpuset.cpus.partition
>>>>>
>>>>> After step #4,
>>>>>
>>>>> | A1 | A2 | A3 |
>>>>> cpus_allowed | 0-1 | 0-1 | |
>>>>> effective_cpus | | 0-1 | |
>>>>> prstate | root | root | member |
>>>>>
>>>>> After step #4, A3's effective CPUs is empty.
>>>>>
>>>>
>>>> That may be a corner case is unexpected.
>>>>
>>>>> #5> echo "0-1" > A3/cpuset.cpus
>>>>>
>>>>
>>>> If we create subdirectories (e.g., A4, A5, ...) under the A1 cpuset and then configure cpuset.cpus
>>>> for A1 (a common usage scenario), processes can no longer be migrated into these subdirectories (A4,
>>>> A5, ...) afterward. However, prior to your patch, this migration was allowed.
>>>
>>> Are you referring to creating subdirectories (A4, A5, ...) after step #4?
>>> And what parameters should be configured for A1's cpuset.cpus?
>>> Could you provide a specific example?
>>>
>>
>> #1> echo "0-1" > A1/cpuset.cpus
>> #2> echo "root" > A1/cpuset.cpus.partition
>> #3> echo "0-1" > A2/cpuset.cpus
>> #4> echo "root" > A2/cpuset.cpus.partition
>> mkdir A4
>> mkdir A5
>> echo "0" > A4/cpuset.cpus
>> echo $$ > A4/cgroup.procs
>> echo "1" > A5/cpuset.cpus
>> echo $$ > A5/cgroup.procs
>>
>> You might be going to argue that we haven't set the cpus for A4/A5..., yeah, maybe a corner case.
>>
>> However, it’s common practice to configure a cpuset’s cpus first and then migrate processes—this is
>> a typical usage scenario.
>>
>
> I'm sorry, I didn't quite understand the point you were trying to make with this example.
>
> If that's the case
>
> root cgroup
> |
> A1
> / / \ \
> A2 A3 A4 A5
>
> #1> echo "0-1" > A1/cpuset.cpus
> #2> echo "root" > A1/cpuset.cpus.partition
> #3> echo "0-1" > A2/cpuset.cpus
> #4> echo "root" > A2/cpuset.cpus.partition
> mkdir A4
> mkdir A5
> echo "0" > A4/cpuset.cpus
If we don't apply your patch, A2 will be invalidated.
> echo $$ > A4/cgroup.procs ->This will return an error because A4's effective CPUs are empty.
> echo "1" > A5/cpuset.cpus
> echo $$ > A5/cgroup.procs ->This will return an error because A5's effective CPUs are empty.
>
> Even with this patch applied, this result will not change.
>
You can have a try, the result I got:
# mkdir A1
# echo "0-1" > A1/cpuset.cpus
# echo "root" > A1/cpuset.cpus.partition
# cd A1/
# mkdir A2
# mkdir A4
# mkdir A5
# echo "0-1" > A2/cpuset.cpus
# echo "root" > A2/cpuset.cpus.partition
#
# echo "0" > A4/cpuset.cpus
# cat A2/cpuset.cpus
0-1
# cat A2/cpuset.cpus.partition
root invalid
# cat A4/cpuset.cpus.effective
0
>>
>>> Additionally, processes cannot be migrated into a cgroup whose
>>> cpuset.cpus.effective is empty. However, this patch does not modify this behavior.
>>>
>>> So why does applying this patch enable such migration?
>
> Thanks,
> Sun Shaojie
--
Best regards,
Ridong
Powered by blists - more mailing lists