* [PATCH] cgroup/cpuset: Add test for partition root invalidation returning wrong CPUs
@ 2026-08-07 8:59 Shaojie Sun
2026-08-10 17:58 ` Waiman Long
0 siblings, 1 reply; 5+ messages in thread
From: Shaojie Sun @ 2026-08-07 8:59 UTC (permalink / raw)
To: Waiman Long, Tejun Heo, Johannes Weiner, Michal Koutný,
Shuah Khan, Ridong Chen
Cc: cgroups, linux-kselftest, linux-kernel, Shaojie Sun
Add a test case covering the bug fixed by
commit 345f40166694 ("cgroup/cpuset: Return only actually allocated
CPUs during partition invalidation"). The test verifies that when a
sibling partition root changes its cpuset.cpus to overlap with another
partition root, only actually allocated CPUs (effective_xcpus) are
returned to the parent, not all CPUs in cpus_allowed.
Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn>
---
tools/testing/selftests/cgroup/test_cpuset_prs.sh | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index 0d41aa0d343d..a44e92c94081 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -393,6 +393,12 @@ TEST_MATRIX=(
" C0-1:P1 . . P1:C2-3 C0-2 . . . 0 A1:0-1|XA1:0-1|B1:2-3 A1:P1|B1:P1"
" C0-1 . . P1:C2-3 C0-2 . . . 0 A1:0-1|B1:2-3 A1:P0|B1:P1"
+ # However, a partition root changing its own cpuset.cpus to overlap with
+ # a sibling partition root will invalidate itself. Only actually allocated
+ # CPUs (effective_xcpus) should be returned to the parent, not all CPUs
+ # in cpus_allowed. The root cgroup effective CPUs must remain unchanged.
+ " C0-1:P1 . . C1-2:P1 . . . C0-1 0 A1:0-1 A1:P1|B1:P-1"
+
# cpuset.cpus can overlap with sibling cpuset.cpus.exclusive but not subsumed by it
" C0-3 . . C4-5 X5 . . . 0 A1:0-3|B1:4-5"
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] cgroup/cpuset: Add test for partition root invalidation returning wrong CPUs
2026-08-07 8:59 [PATCH] cgroup/cpuset: Add test for partition root invalidation returning wrong CPUs Shaojie Sun
@ 2026-08-10 17:58 ` Waiman Long
2026-08-11 9:58 ` [PATCH v2] " Shaojie Sun
0 siblings, 1 reply; 5+ messages in thread
From: Waiman Long @ 2026-08-10 17:58 UTC (permalink / raw)
To: Shaojie Sun, Tejun Heo, Johannes Weiner, Michal Koutný,
Shuah Khan, Ridong Chen
Cc: cgroups, linux-kselftest, linux-kernel
On 8/7/26 4:59 AM, Shaojie Sun wrote:
> Add a test case covering the bug fixed by
> commit 345f40166694 ("cgroup/cpuset: Return only actually allocated
> CPUs during partition invalidation"). The test verifies that when a
> sibling partition root changes its cpuset.cpus to overlap with another
> partition root, only actually allocated CPUs (effective_xcpus) are
> returned to the parent, not all CPUs in cpus_allowed.
>
> Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn>
> ---
> tools/testing/selftests/cgroup/test_cpuset_prs.sh | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> index 0d41aa0d343d..a44e92c94081 100755
> --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> @@ -393,6 +393,12 @@ TEST_MATRIX=(
> " C0-1:P1 . . P1:C2-3 C0-2 . . . 0 A1:0-1|XA1:0-1|B1:2-3 A1:P1|B1:P1"
> " C0-1 . . P1:C2-3 C0-2 . . . 0 A1:0-1|B1:2-3 A1:P0|B1:P1"
>
> + # However, a partition root changing its own cpuset.cpus to overlap with
> + # a sibling partition root will invalidate itself. Only actually allocated
> + # CPUs (effective_xcpus) should be returned to the parent, not all CPUs
> + # in cpus_allowed. The root cgroup effective CPUs must remain unchanged.
> + " C0-1:P1 . . C1-2:P1 . . . C0-1 0 A1:0-1 A1:P1|B1:P-1"
> +
The cgroup hierarchy used by TEST_MATRIX may not suitable for doing this
kind of test as you can't easily check the state of the parent cgroup. I
would suggest you use the REMOTE_TEST_MATRIX hierarchy with p1, c11,
c12. After making c12 conflicts with c11, you can check p1 to see if it
has the right state.
Cheers,
Longman
> # cpuset.cpus can overlap with sibling cpuset.cpus.exclusive but not subsumed by it
> " C0-3 . . C4-5 X5 . . . 0 A1:0-3|B1:4-5"
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] cgroup/cpuset: Add test for partition root invalidation returning wrong CPUs
2026-08-10 17:58 ` Waiman Long
@ 2026-08-11 9:58 ` Shaojie Sun
2026-08-11 18:33 ` Waiman Long
2026-08-12 2:26 ` Tejun Heo
0 siblings, 2 replies; 5+ messages in thread
From: Shaojie Sun @ 2026-08-11 9:58 UTC (permalink / raw)
To: longman
Cc: cgroups, hannes, linux-kernel, linux-kselftest, mkoutny,
ridong.chen, shuah, sunshaojie, tj
Add a test case to REMOTE_TEST_MATRIX covering the bug fixed by
commit 345f40166694 ("cgroup/cpuset: Return only actually allocated
CPUs during partition invalidation"). The test verifies that when a
sibling partition root changes its cpuset.cpus to overlap with another
partition root, only actually allocated CPUs (effective_xcpus) are
returned to the parent, not all CPUs in cpus_allowed.
Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn>
---
tools/testing/selftests/cgroup/test_cpuset_prs.sh | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index 0d41aa0d343d..236cb1b38178 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -502,6 +502,12 @@ REMOTE_TEST_MATRIX=(
" C1-4:P1 . C1-2:P1 C1-3:P2 . . \
. . P0 C2-3 . . p1:1,4|c11:1|c12:2-3 \
p1:P1|c11:P0|c12:P2 2-3"
+ # Changing a sibling partition's cpuset.cpus to overlap with another
+ # sibling partition should invalidate itself and return only actually
+ # allocated CPUs (effective_xcpus) to the parent.
+ " C1-4:P1 . C1-2:P1 C2-4:P2 . . \
+ . . . C1-2 . . p1:3-4|c11:1-2|c12:3-4 \
+ p1:P1|c11:P1|c12:P-2"
)
#
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] cgroup/cpuset: Add test for partition root invalidation returning wrong CPUs
2026-08-11 9:58 ` [PATCH v2] " Shaojie Sun
@ 2026-08-11 18:33 ` Waiman Long
2026-08-12 2:26 ` Tejun Heo
1 sibling, 0 replies; 5+ messages in thread
From: Waiman Long @ 2026-08-11 18:33 UTC (permalink / raw)
To: Shaojie Sun
Cc: cgroups, hannes, linux-kernel, linux-kselftest, mkoutny,
ridong.chen, shuah, tj
On 8/11/26 5:58 AM, Shaojie Sun wrote:
> Add a test case to REMOTE_TEST_MATRIX covering the bug fixed by
> commit 345f40166694 ("cgroup/cpuset: Return only actually allocated
> CPUs during partition invalidation"). The test verifies that when a
> sibling partition root changes its cpuset.cpus to overlap with another
> partition root, only actually allocated CPUs (effective_xcpus) are
> returned to the parent, not all CPUs in cpus_allowed.
>
> Signed-off-by: Shaojie Sun <sunshaojie@kylinos.cn>
> ---
> tools/testing/selftests/cgroup/test_cpuset_prs.sh | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> index 0d41aa0d343d..236cb1b38178 100755
> --- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> +++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
> @@ -502,6 +502,12 @@ REMOTE_TEST_MATRIX=(
> " C1-4:P1 . C1-2:P1 C1-3:P2 . . \
> . . P0 C2-3 . . p1:1,4|c11:1|c12:2-3 \
> p1:P1|c11:P0|c12:P2 2-3"
> + # Changing a sibling partition's cpuset.cpus to overlap with another
> + # sibling partition should invalidate itself and return only actually
> + # allocated CPUs (effective_xcpus) to the parent.
> + " C1-4:P1 . C1-2:P1 C2-4:P2 . . \
> + . . . C1-2 . . p1:3-4|c11:1-2|c12:3-4 \
> + p1:P1|c11:P1|c12:P-2"
> )
>
> #
Reviewed-by: Waiman Long <longman@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] cgroup/cpuset: Add test for partition root invalidation returning wrong CPUs
2026-08-11 9:58 ` [PATCH v2] " Shaojie Sun
2026-08-11 18:33 ` Waiman Long
@ 2026-08-12 2:26 ` Tejun Heo
1 sibling, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2026-08-12 2:26 UTC (permalink / raw)
To: Shaojie Sun
Cc: longman, cgroups, hannes, linux-kernel, linux-kselftest, mkoutny,
ridong.chen, shuah
Applied to cgroup/for-7.3.
The patch was generated against a base which predates 866f587e9c70
("cgroup/cpuset: Avoid unnecessary cpus & mems update in
cpuset_hotplug_update_tasks()") and no longer applied, so I moved the
new entry to keep it with the other sibling-exclusion cases and matched
the current column alignment. The applied change follows:
diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index 8e21e9fc439c..8380fd9d76bd 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -502,6 +502,12 @@ REMOTE_TEST_MATRIX=(
" C1-4:P1 . C1-2:P1 C1-3:P2 . . \
. . P0 C2-3 . . p1:1,4|c11:1|c12:2-3 \
p1:P1|c11:P0|c12:P2 2-3"
+ # Changing a sibling partition's cpuset.cpus to overlap with another
+ # sibling partition should invalidate itself and return only actually
+ # allocated CPUs (effective_xcpus) to the parent.
+ " C1-4:P1 . C1-2:P1 C2-4:P2 . . \
+ . . . C1-2 . . p1:3-4|c11:1-2|c12:3-4 \
+ p1:P1|c11:P1|c12:P-2"
# Cpusets with empty cpuset.cpus should inherit parent's effective_cpus
" C1-4:P1 C5-6 C1-2 . C5 . \
. P1 P1 . . . p1:3-4|p2:5-6|c11:1-2|c12:3-4|c21:5|c22:5-6 \
Thanks.
--
tejun
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-12 2:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-07 8:59 [PATCH] cgroup/cpuset: Add test for partition root invalidation returning wrong CPUs Shaojie Sun
2026-08-10 17:58 ` Waiman Long
2026-08-11 9:58 ` [PATCH v2] " Shaojie Sun
2026-08-11 18:33 ` Waiman Long
2026-08-12 2:26 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox