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 <[email protected]>
---
  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"


Reply via email to