All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guopeng Zhang <guopeng.zhang@linux.dev>
To: longman@redhat.com, cgroups@vger.kernel.org
Cc: ridong.chen@linux.dev, tj@kernel.org, hannes@cmpxchg.org,
	mkoutny@suse.com, shuah@kernel.org,
	linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
	Guopeng Zhang <zhangguopeng@kylinos.cn>
Subject: [PATCH 09/17] selftests/cgroup: Test rejected partition type changes
Date: Thu, 20 Aug 2026 20:41:54 +0800	[thread overview]
Message-ID: <20260820124202.517160-10-guopeng.zhang@linux.dev> (raw)
In-Reply-To: <20260820124202.517160-1-guopeng.zhang@linux.dev>

From: Guopeng Zhang <zhangguopeng@kylinos.cn>

Exercise housekeeping rejection for local and remote partition type
changes. Check the invalid state, the CPUs returned to the top cpuset and
the boot-time isolation state of those CPUs.

Signed-off-by: Guopeng Zhang <zhangguopeng@kylinos.cn>
---
 .../selftests/cgroup/test_cpuset_prs.sh       | 93 +++++++++++++++++++
 1 file changed, 93 insertions(+)

diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index bc8dbb724d5c..35c19738aaa4 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -1260,6 +1260,97 @@ test_owned_cpus_housekeeping()
 	echo "$TEST_NAME test PASSED."
 }
 
+#
+# A local type change rejected by the boot housekeeping constraint must release
+# the partition CPUs and preserve their boot-isolated state.
+#
+test_partition_type_failure()
+{
+	TEST_NAME="Rejected local partition type change"
+	get_boot_isolated_cpu "$TEST_NAME" || return 0
+	echo "Running $TEST_NAME test ..."
+
+	cd $CGROUP2/test
+	echo member > cpuset.cpus.partition
+	echo $BOOT_CPU > cpuset.cpus
+	[[ $(cat cpuset.cpus.effective) = "$BOOT_CPU" ]] || {
+		echo "$TEST_NAME test SKIPPED: CPU $BOOT_CPU is unavailable"
+		echo "" > cpuset.cpus
+		cd $CGROUP2
+		return 0
+	}
+	test_partition isolated
+	echo root > cpuset.cpus.partition
+	grep -q '^root invalid (partition config conflicts with housekeeping setup)$' \
+		cpuset.cpus.partition || {
+		echo "Partition type failure did not produce the expected state"
+		exit 1
+	}
+	[[ $(cat $CGROUP2/cpuset.cpus.effective) = "$CPULIST" ]] || {
+		echo "Partition type failure did not release CPU $BOOT_CPU"
+		exit 1
+	}
+	check_isolcpus "." || {
+		echo "Partition type failure lost boot-isolated CPU $BOOT_CPU"
+		exit 1
+	}
+	echo member > cpuset.cpus.partition
+	echo "" > cpuset.cpus
+	cd $CGROUP2
+	echo "$TEST_NAME test PASSED."
+}
+
+#
+# Exercise the same rejected type change for a remote partition.
+#
+test_remote_partition_type_failure()
+{
+	TEST_NAME="Rejected remote partition 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 $BOOT_CPU > cpuset.cpus
+	echo $BOOT_CPU > cpuset.cpus.exclusive
+	[[ $(cat cpuset.cpus.effective) = "$BOOT_CPU" ]] || {
+		echo "$TEST_NAME test SKIPPED: CPU $BOOT_CPU is unavailable"
+		echo "" > cpuset.cpus.exclusive
+		echo "" > cpuset.cpus
+		cd $CGROUP2
+		return 0
+	}
+	mkdir A1
+	cd A1
+	echo $BOOT_CPU > cpuset.cpus
+	echo $BOOT_CPU > cpuset.cpus.exclusive
+	test_partition isolated
+	echo root > cpuset.cpus.partition
+	grep -q '^root invalid (partition config conflicts with housekeeping setup)$' \
+		cpuset.cpus.partition || {
+		echo "Remote type failure did not produce the expected state"
+		exit 1
+	}
+	[[ $(cat $CGROUP2/cpuset.cpus.effective) = "$CPULIST" ]] || {
+		echo "Remote type failure did not release CPU $BOOT_CPU"
+		exit 1
+	}
+	check_isolcpus "." || {
+		echo "Remote type failure lost boot-isolated CPU $BOOT_CPU"
+		exit 1
+	}
+	echo member > cpuset.cpus.partition
+	echo "" > cpuset.cpus.exclusive
+	echo "" > cpuset.cpus
+	cd ..
+	rmdir A1
+	echo "" > cpuset.cpus.exclusive
+	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
@@ -1333,5 +1424,7 @@ run_remote_state_test REMOTE_TEST_MATRIX
 test_isolated
 test_boot_isolated
 test_owned_cpus_housekeeping
+test_partition_type_failure
+test_remote_partition_type_failure
 test_inotify
 echo "All tests PASSED."
-- 
2.43.0


  parent reply	other threads:[~2026-08-20 12:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-20 12:41 [PATCH 00/17] cgroup/cpuset: Fix partition CPU ownership and isolation accounting Guopeng Zhang
2026-08-20 12:41 ` [PATCH 01/17] selftests/cgroup: Drop invalid boot isolation comparison Guopeng Zhang
2026-08-20 12:41 ` [PATCH 02/17] cgroup/cpuset: Preserve boot-isolated CPUs on partition release Guopeng Zhang
2026-08-20 12:41 ` [PATCH 03/17] selftests/cgroup: Test boot-isolated CPU " Guopeng Zhang
2026-08-20 12:41 ` [PATCH 04/17] cgroup/cpuset: Limit type-change accounting to owned CPUs Guopeng Zhang
2026-08-20 12:41 ` [PATCH 05/17] selftests/cgroup: Test isolated CPU accounting on type changes Guopeng Zhang
2026-08-20 12:41 ` [PATCH 06/17] cgroup/cpuset: Validate type changes against owned CPUs Guopeng Zhang
2026-08-20 12:41 ` [PATCH 07/17] selftests/cgroup: Test type-change validation with child-owned CPUs Guopeng Zhang
2026-08-20 12:41 ` [PATCH 08/17] cgroup/cpuset: Release CPUs when a type change is rejected Guopeng Zhang
2026-08-20 12:41 ` Guopeng Zhang [this message]
2026-08-20 12:41 ` [PATCH 10/17] cgroup/cpuset: Fix isolated accounting on direct child invalidation Guopeng Zhang
2026-08-20 12:41 ` [PATCH 11/17] selftests/cgroup: Test isolation " Guopeng Zhang
2026-08-20 12:41 ` [PATCH 12/17] cgroup/cpuset: Invalidate children outside the new CPU mask Guopeng Zhang
2026-08-20 12:41 ` [PATCH 13/17] selftests/cgroup: Test child invalidation after shrinking cpuset.cpus Guopeng Zhang
2026-08-20 12:41 ` [PATCH 14/17] cgroup/cpuset: Publish cpus_allowed before partition updates Guopeng Zhang
2026-08-20 12:42 ` [PATCH 15/17] selftests/cgroup: Test shrinking cpuset.cpus in a remote partition Guopeng Zhang
2026-08-20 12:42 ` [PATCH 16/17] cgroup/cpuset: Fix isolated accounting on propagated invalidation Guopeng Zhang
2026-08-20 12:42 ` [PATCH 17/17] selftests/cgroup: Test isolation " Guopeng Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260820124202.517160-10-guopeng.zhang@linux.dev \
    --to=guopeng.zhang@linux.dev \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mkoutny@suse.com \
    --cc=ridong.chen@linux.dev \
    --cc=shuah@kernel.org \
    --cc=tj@kernel.org \
    --cc=zhangguopeng@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.