selftests/cgroup: Add tests for nohz_full housekeeping check

When a boot time nohz_full CPUs are present and they cover CPUs 0-7,
some of the test cases may fail.  So the test run will be skipped with
a warning message in this case. On the other hand, if the boot time
nohz_full CPUs cover all the CPUs except 0-7, a special set of nohz_full
specific housekeeping check related tests could be run to make sure the
housekeeping check are behaving properly. The test_cpuset_prs.sh test
script is now updated to do exactly that.

Signed-off-by: Waiman Long <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
This commit is contained in:
Waiman Long 2026-10-19 14:10:19 -04:00 committed by Tejun Heo
parent 1f14d20bf3
commit 989ca25c10

View File

@ -84,6 +84,31 @@ echo member > test/cpuset.cpus.partition
echo "" > test/cpuset.cpus
[[ $RESULT -eq 0 ]] && skip_test "Child cgroups are using cpuset!"
#
# If nohz_full CPUs have been reserved at boot time, they should not include
# CPUs 0-7 as that may fail some of the test cases. On the other hand if the
# set of nohz_full CPUs includes all the CPUs except 0-7, we can run a special
# set of housekeeping CPUs exhaustion tests to see if the cpuset code will
# reject them.
#
FIRST_NOHZ_FULL_CPU=
LAST_NOHZ_FULL_CPU=
RUN_NOHZ_FULL_TESTS=
NOHZ_FULL_CPUS=
[[ -f /sys/devices/system/cpu/nohz_full ]] &&
NOHZ_FULL_CPUS=$(cat /sys/devices/system/cpu/nohz_full)
LAST_PRESENT_CPU=$(cat /sys/devices/system/cpu/present | sed -e "s/.*[,-]//")
[[ -n "$NOHZ_FULL_CPUS" ]] && {
FIRST_NOHZ_FULL_CPU=$(echo $NOHZ_FULL_CPUS | sed -e "s/[,-].*//")
LAST_NOHZ_FULL_CPU=$(echo $NOHZ_FULL_CPUS | sed -e "s/.*[,-]//")
echo "Boot nohz_full CPUs: $NOHZ_FULL_CPUS"
}
[[ -n "$FIRST_NOHZ_FULL_CPU" && "$FIRST_NOHZ_FULL_CPU" -le 7 ]] &&
skip_test "Boot NOHZ_FULL CPUs overlap CPUs to be tested!"
[[ -n "$FIRST_NOHZ_FULL_CPU" && "$FIRST_NOHZ_FULL_CPU" = 8 &&
"$LAST_NOHZ_FULL_CPU" = $LAST_PRESENT_CPU ]] && RUN_NOHZ_FULL_TESTS=1
#
# If isolated CPUs have been reserved at boot time (as shown in
# /sys/devices/system/cpu/isolated), these isolated CPUs should be outside of
@ -500,6 +525,17 @@ ISOLCPUS_TEST_MATRIX=(
" CX1-2,I:X1,I:P1 . . . X1,2,I . . . 0 A1:1-2,I|XA1:1-2,I A1:P-1 ."
)
# Test matrix to be run when boot time nohz_full CPUs cover all CPUs except CPUs 0-7
NOHZ_FULL_TEST_MATRIX=(
# old-A1 old-A2 old-A3 old-B1 new-A1 new-A2 new-A3 new-B1 fail ECPUs Pstate ISOLCPUS
# ------ ------ ------ ------ ------ ------ ------ ------ ---- ----- ------ --------
# Using all the nohz_full HK CPUs 0-7 in isolated partition is not allowed
" C0-7 . . . P2 . . . 0 A1:0-7 A1:P-2 ."
" C2-7:P2 . . . C0-4 . . . 0 A1:0-4 A1:P2 0-4"
" C1-7:P2 C5-7:P2 . . . . . C0:P2 0 A1:1-4|A2:5-7|B1:0
A1:P2|A2:P2|B1:P-2 1-7"
)
#
# Cpuset controller remote partition test matrix.
#
@ -1365,6 +1401,7 @@ trap cleanup 0 2 3 6
run_state_test TEST_MATRIX
run_remote_state_test REMOTE_TEST_MATRIX
TEST_ISOLCPUS=1 run_state_test ISOLCPUS_TEST_MATRIX
[[ -n "$RUN_NOHZ_FULL_TESTS" ]] && run_state_test NOHZ_FULL_TEST_MATRIX
test_isolated
test_boot_isolated
test_inotify