Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftest/cgroup: Make test_cpuset_prs.sh deal with pre-isolated CPUs

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 <longman@redhat.com>
Signed-off-by: Tejun Heo <tj@kernel.org>

authored by

Waiman Long and committed by
Tejun Heo
43a17fcf c188f33c

+33 -11
+33 -11
tools/testing/selftests/cgroup/test_cpuset_prs.sh
··· 84 84 echo "" > test/cpuset.cpus 85 85 [[ $RESULT -eq 0 ]] && skip_test "Child cgroups are using cpuset!" 86 86 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 87 101 cleanup() 88 102 { 89 103 online_cpus ··· 656 642 # Note that isolated CPUs from the sched/domains context include offline 657 643 # CPUs as well as CPUs in non-isolated 1-CPU partition. Those CPUs may 658 644 # not be included in the cpuset.cpus.isolated control file which contains 659 - # only CPUs in isolated partitions. 645 + # only CPUs in isolated partitions as well as those that are isolated at 646 + # boot time. 660 647 # 661 648 # $1 - expected isolated cpu list(s) <isolcpus1>{,<isolcpus2>} 662 649 # <isolcpus1> - expected sched/domains value ··· 684 669 fi 685 670 686 671 # 687 - # Check the debug isolated cpumask, if present 672 + # Check cpuset.cpus.isolated cpumask 688 673 # 689 - [[ -f $ISCPUS ]] && { 674 + if [[ -z "$BOOT_ISOLCPUS" ]] 675 + then 690 676 ISOLCPUS=$(cat $ISCPUS) 691 - [[ "$EXPECT_VAL2" != "$ISOLCPUS" ]] && { 692 - # Take a 50ms pause and try again 693 - pause 0.05 694 - ISOLCPUS=$(cat $ISCPUS) 695 - } 696 - [[ "$EXPECT_VAL2" != "$ISOLCPUS" ]] && return 1 697 - ISOLCPUS= 677 + else 678 + ISOLCPUS=$(cat $ISCPUS | sed -e "s/,*$BOOT_ISOLCPUS//") 679 + fi 680 + [[ "$EXPECT_VAL2" != "$ISOLCPUS" ]] && { 681 + # Take a 50ms pause and try again 682 + pause 0.05 683 + ISOLCPUS=$(cat $ISCPUS) 698 684 } 685 + [[ "$EXPECT_VAL2" != "$ISOLCPUS" ]] && return 1 686 + ISOLCPUS= 699 687 700 688 # 701 689 # Use the sched domain in debugfs to check isolated CPUs, if available ··· 731 713 fi 732 714 done 733 715 [[ "$ISOLCPUS" = *- ]] && ISOLCPUS=${ISOLCPUS}$LASTISOLCPU 716 + [[ -n "BOOT_ISOLCPUS" ]] && 717 + ISOLCPUS=$(echo $ISOLCPUS | sed -e "s/,*$BOOT_ISOLCPUS//") 718 + 734 719 [[ "$EXPECT_VAL" = "$ISOLCPUS" ]] 735 720 } 736 721 ··· 751 730 } 752 731 753 732 # 754 - # Check to see if there are unexpected isolated CPUs left 733 + # Check to see if there are unexpected isolated CPUs left beyond the boot 734 + # time isolated ones. 755 735 # 756 736 null_isolcpus_check() 757 737 {