[PATCH 07/17] selftests/cgroup: Test type-change validation with child-owned CPUs
From: Guopeng Zhang
Date: Thu Aug 20 2026 - 08:44:03 EST
From: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
Create an isolated child which owns a CPU isolated at boot, then change
its parent from isolated to root. Check that the change succeeds without
altering the child or its isolated CPU.
Signed-off-by: Guopeng Zhang <zhangguopeng@xxxxxxxxxx>
---
.../selftests/cgroup/test_cpuset_prs.sh | 47 +++++++++++++++++++
1 file changed, 47 insertions(+)
diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index 9a1cce4807b4..bc8dbb724d5c 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -1214,6 +1214,52 @@ test_boot_isolated()
echo "$TEST_NAME test PASSED."
}
+#
+# A parent's type change must validate only CPUs owned directly by the parent,
+# not a boot-isolated CPU owned by a valid isolated child partition.
+#
+test_owned_cpus_housekeeping()
+{
+ TEST_NAME="Child-owned CPU type change"
+ get_boot_isolated_cpu "$TEST_NAME" || return 0
+ echo "Running $TEST_NAME test ..."
+
+ cd $CGROUP2/test
+ echo member > cpuset.cpus.partition
+ echo +cpuset > cgroup.subtree_control
+ echo 2,$BOOT_CPU > cpuset.cpus
+ [[ $(cat cpuset.cpus.effective) = "2,$BOOT_CPU" ]] || {
+ echo "$TEST_NAME test SKIPPED: CPUs 2,$BOOT_CPU are unavailable"
+ echo "" > cpuset.cpus
+ cd $CGROUP2
+ return 0
+ }
+ test_partition isolated
+ mkdir A1
+ cd A1
+ echo $BOOT_CPU > cpuset.cpus
+ test_partition isolated
+ cd ..
+ test_effective_cpus 2
+ test_partition root
+ [[ $(cat A1/cpuset.cpus.partition) = isolated ]] || {
+ echo "Child partition changed during parent type change"
+ exit 1
+ }
+ check_isolcpus "." || {
+ echo "Parent type change corrupted child isolation"
+ exit 1
+ }
+ cd A1
+ test_partition member
+ cd ..
+ rmdir A1
+ test_partition member
+ echo "" > cpuset.cpus
+ cd $CGROUP2
+ echo "$TEST_NAME test PASSED."
+}
+
#
# Wait for inotify event for the given file and read it
# $1: cgroup file to wait for
@@ -1286,5 +1332,6 @@ run_state_test TEST_MATRIX
run_remote_state_test REMOTE_TEST_MATRIX
test_isolated
test_boot_isolated
+test_owned_cpus_housekeeping
test_inotify
echo "All tests PASSED."
--
2.43.0