Re: [PATCH 2/2] selftests/cgroup: Preserve CPU hotplug write errors

From: Ridong Chen

Date: Sun Aug 09 2026 - 23:22:51 EST




On 8/9/2026 4:21 PM, Rui Qi wrote:
The cpuset partition root state selftest checks several CPU hotplug
transitions. If writing to a CPU online file fails, the helper still
runs pause afterwards and returns the status of pause instead of the
failed write.

This hides the real hotplug failure and can make later checks run
against expectations for a transition that never happened. Move the
write before the bookkeeping and return when it fails, so callers can
observe the hotplug error and the test does not record a CPU as offline
unless the offline operation actually succeeded.

Fixes: a8c52eba880a ("kselftest/cgroup: Add cpuset v2 partition root state test")
Signed-off-by: Rui Qi <qirui.001@xxxxxxxxxxxxx>
---
tools/testing/selftests/cgroup/test_cpuset_prs.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index 16c38eb11e63..a2f7208633bc 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -412,6 +412,7 @@ write_cpu_online()
CPU=${1%=*}
VAL=${1#*=}
CPUFILE=//sys/devices/system/cpu/cpu${CPU}/online
+ echo $VAL > $CPUFILE || return 1
if [[ $VAL -eq 0 ]]
then
OFFLINE_CPUS="$OFFLINE_CPUS $CPU"
@@ -421,7 +422,6 @@ write_cpu_online()
sort | uniq -u)
}
fi
- echo $VAL > $CPUFILE
pause 0.05
}
@@ -493,6 +493,7 @@ set_ctrl_state()
eval $COMM $REDIRECT
;;
O*) VAL=${CMD#?}
+ COMM="write_cpu_online $VAL"
write_cpu_online $VAL
;;
T*) COMM="echo 0 > $TFILE"

LGTM.

Reviewed-by: Ridong Chen <ridong.chen@xxxxxxxxx>

--
Best regards
Ridong