[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251120130557.1554118-1-sunshaojie@kylinos.cn>
Date: Thu, 20 Nov 2025 21:05:57 +0800
From: Sun Shaojie <sunshaojie@...inos.cn>
To: mkoutny@...e.com
Cc: cgroups@...r.kernel.org,
chenridong@...weicloud.com,
hannes@...xchg.org,
linux-kernel@...r.kernel.org,
linux-kselftest@...r.kernel.org,
llong@...hat.com,
shuah@...nel.org,
sunshaojie@...inos.cn,
tj@...nel.org
Subject: Re: [PATCH v5] cpuset: Avoid invalidating sibling partitions on cpuset.cpus conflict.
Hi, Michal,
On Wed, 19 Nov 2025 14:20:25, Michal Koutný wrote:
>On Wed, Nov 19, 2025 at 06:57:49PM +0800, Sun Shaojie <sunshaojie@...inos.cn> wrote:
>> Currently, when setting a cpuset's cpuset.cpus to a value that conflicts
>> with its sibling partition, the sibling's partition state becomes invalid.
>> However, this invalidation is often unnecessary. If the cpuset being
>> modified is exclusive, it should invalidate itself upon conflict.
>>
>> This patch applies only to the following two cases:
>>
>> Assume the machine has 4 CPUs (0-3).
>>
>> root cgroup
>> / \
>> A1 B1
>>
>> Case 1: A1 is exclusive, B1 is non-exclusive, set B1's cpuset.cpus
>>
>> Table 1.1: Before applying this patch
>> Step | A1's prstate | B1's prstate |
>> #1> echo "0-1" > A1/cpuset.cpus | member | member |
>> #2> echo "root" > A1/cpuset.cpus.partition | root | member |
>> #3> echo "0" > B1/cpuset.cpus | root invalid | member |
>>
>> After step #3, A1 changes from "root" to "root invalid" because its CPUs
>> (0-1) overlap with those requested by B1 (0). However, B1 can actually
>> use CPUs 2-3(from B1's parent), so it would be more reasonable for A1 to
>> remain as "root."
>>
>> Table 1.2: After applying this patch
>> Step | A1's prstate | B1's prstate |
>> #1> echo "0-1" > A1/cpuset.cpus | member | member |
>> #2> echo "root" > A1/cpuset.cpus.partition | root | member |
>> #3> echo "0" > B1/cpuset.cpus | root | member |
>>
>> Case 2: Both A1 and B1 are exclusive, set B1's cpuset.cpus
>
>(Thanks for working this out, Shaojie.)
>
>>
>> Table 2.1: Before applying this patch
>> Step | A1's prstate | B1's prstate |
>> #1> echo "0-1" > A1/cpuset.cpus | member | member |
>> #2> echo "root" > A1/cpuset.cpus.partition | root | member |
>> #3> echo "2" > B1/cpuset.cpus | root | member |
>> #4> echo "root" > B1/cpuset.cpus.partition | root | root |
>> #5> echo "1-2" > B1/cpuset.cpus | root invalid | root invalid |
>>
>> After step #4, B1 can exclusively use CPU 2. Therefore, at step #5,
>> regardless of what conflicting value B1 writes to cpuset.cpus, it will
>> always have at least CPU 2 available. This makes it unnecessary to mark
>> A1 as "root invalid".
>>
>> Table 2.2: After applying this patch
>> Step | A1's prstate | B1's prstate |
>> #1> echo "0-1" > A1/cpuset.cpus | member | member |
>> #2> echo "root" > A1/cpuset.cpus.partition | root | member |
>> #3> echo "2" > B1/cpuset.cpus | root | member |
>> #4> echo "root" > B1/cpuset.cpus.partition | root | root |
>> #5> echo "1-2" > B1/cpuset.cpus | root | root invalid |
>>
>> In summary, regardless of how B1 configures its cpuset.cpus, there will
>> always be available CPUs in B1's cpuset.cpus.effective. Therefore, there
>> is no need to change A1 from "root" to "root invalid".
>
>Admittedly, I don't like this change because it relies on implicit
>preference ordering between siblings (here first comes, first served)
>and so the effective config cannot be derived just from the applied
>values :-/
>
>Do you actually want to achieve this or is it an implementation
>side-effect of the Case 1 scenario that you want to achieve?
Yes, this is indeed the functionality I intended to achieve, as I find it
follows the same logic as Case 1.
However, I didn't fully understand what you meant by "implicit preference
ordering between siblings (here first comes, first served)."
Could you provide an example?
As for your point that "the effective config cannot be derived just from
the applied values," even before this patch, we couldn't derive the final
effective configuration solely from the applied values.
For example, consider the following scenario: (not apply this patch)
Table 1:
Step | A1's prstate | B1's prstate |
#1> echo "0-1" > A1/cpuset.cpus | member | member |
#2> echo "root" > A1/cpuset.cpus.partition | root | member |
#3> echo "1-2" > B1/cpuset.cpus | root invalid | member |
Table 2:
Step | A1's prstate | B1's prstate |
#1> echo "1-2" > B1/cpuset.cpus | member | member |
#2> echo "root" > A1/cpuset.cpus.partition | root invalid | member |
#3> echo "0-1" > A1/cpuset.cpus | root | member |
After step #3, both Table 1 and Table 2 have identical value settings,
yet A1's partition state differs between them.
Thanks,
Sun Shaojie
Powered by blists - more mailing lists