Skip to content

Commit 8dd2c70

Browse files
committed
selftest/cgroup: Make test_cpuset_prs.sh deal with pre-isolated CPUs
jira NONE_AUTOMATION Rebuild_History Non-Buildable kernel-5.14.0-570.17.1.el9_6 commit-author Waiman Long <[email protected]> commit 43a17fc Since isolated CPUs can be reserved at boot time via the "isolcpus" boot command line option, these pre-isolated CPUs may interfere with testing done by test_cpuset_prs.sh. With the previous commit that incorporates those boot time isolated CPUs into "cpuset.cpus.isolated", we can check for those before testing is started to make sure that there will be no interference. Otherwise, this test will be skipped if incorrect test failure can happen. As "cpuset.cpus.isolated" is now available in a non cgroup_debug kernel, we don't need to check for its existence anymore. Signed-off-by: Waiman Long <[email protected]> Signed-off-by: Tejun Heo <[email protected]> (cherry picked from commit 43a17fc) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 703ac29 commit 8dd2c70

File tree

1 file changed

+33
-11
lines changed

1 file changed

+33
-11
lines changed

tools/testing/selftests/cgroup/test_cpuset_prs.sh

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ echo member > test/cpuset.cpus.partition
8484
echo "" > test/cpuset.cpus
8585
[[ $RESULT -eq 0 ]] && skip_test "Child cgroups are using cpuset!"
8686

87+
#
88+
# If isolated CPUs have been reserved at boot time (as shown in
89+
# cpuset.cpus.isolated), these isolated CPUs should be outside of CPUs 0-7
90+
# that will be used by this script for testing purpose. If not, some of
91+
# the tests may fail incorrectly. These isolated CPUs will also be removed
92+
# before being compared with the expected results.
93+
#
94+
BOOT_ISOLCPUS=$(cat $CGROUP2/cpuset.cpus.isolated)
95+
if [[ -n "$BOOT_ISOLCPUS" ]]
96+
then
97+
[[ $(echo $BOOT_ISOLCPUS | sed -e "s/[,-].*//") -le 7 ]] &&
98+
skip_test "Pre-isolated CPUs ($BOOT_ISOLCPUS) overlap CPUs to be tested"
99+
echo "Pre-isolated CPUs: $BOOT_ISOLCPUS"
100+
fi
87101
cleanup()
88102
{
89103
online_cpus
@@ -642,7 +656,8 @@ check_cgroup_states()
642656
# Note that isolated CPUs from the sched/domains context include offline
643657
# CPUs as well as CPUs in non-isolated 1-CPU partition. Those CPUs may
644658
# not be included in the cpuset.cpus.isolated control file which contains
645-
# only CPUs in isolated partitions.
659+
# only CPUs in isolated partitions as well as those that are isolated at
660+
# boot time.
646661
#
647662
# $1 - expected isolated cpu list(s) <isolcpus1>{,<isolcpus2>}
648663
# <isolcpus1> - expected sched/domains value
@@ -669,18 +684,21 @@ check_isolcpus()
669684
fi
670685
671686
#
672-
# Check the debug isolated cpumask, if present
687+
# Check cpuset.cpus.isolated cpumask
673688
#
674-
[[ -f $ISCPUS ]] && {
689+
if [[ -z "$BOOT_ISOLCPUS" ]]
690+
then
691+
ISOLCPUS=$(cat $ISCPUS)
692+
else
693+
ISOLCPUS=$(cat $ISCPUS | sed -e "s/,*$BOOT_ISOLCPUS//")
694+
fi
695+
[[ "$EXPECT_VAL2" != "$ISOLCPUS" ]] && {
696+
# Take a 50ms pause and try again
697+
pause 0.05
675698
ISOLCPUS=$(cat $ISCPUS)
676-
[[ "$EXPECT_VAL2" != "$ISOLCPUS" ]] && {
677-
# Take a 50ms pause and try again
678-
pause 0.05
679-
ISOLCPUS=$(cat $ISCPUS)
680-
}
681-
[[ "$EXPECT_VAL2" != "$ISOLCPUS" ]] && return 1
682-
ISOLCPUS=
683699
}
700+
[[ "$EXPECT_VAL2" != "$ISOLCPUS" ]] && return 1
701+
ISOLCPUS=
684702
685703
#
686704
# Use the sched domain in debugfs to check isolated CPUs, if available
@@ -713,6 +731,9 @@ check_isolcpus()
713731
fi
714732
done
715733
[[ "$ISOLCPUS" = *- ]] && ISOLCPUS=${ISOLCPUS}$LASTISOLCPU
734+
[[ -n "BOOT_ISOLCPUS" ]] &&
735+
ISOLCPUS=$(echo $ISOLCPUS | sed -e "s/,*$BOOT_ISOLCPUS//")
736+
716737
[[ "$EXPECT_VAL" = "$ISOLCPUS" ]]
717738
}
718739

@@ -730,7 +751,8 @@ test_fail()
730751
}
731752

732753
#
733-
# Check to see if there are unexpected isolated CPUs left
754+
# Check to see if there are unexpected isolated CPUs left beyond the boot
755+
# time isolated ones.
734756
#
735757
null_isolcpus_check()
736758
{

0 commit comments

Comments
 (0)