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

cgroup/cpuset: Expose cpuset.cpus.isolated

The root-only cpuset.cpus.isolated control file shows the current set
of isolated CPUs in isolated partitions. This control file is currently
exposed only with the cgroup_debug boot command line option which also
adds the ".__DEBUG__." prefix. This is actually a useful control file if
users want to find out which CPUs are currently in an isolated state by
the cpuset controller. Remove CFTYPE_DEBUG flag for this control file and
make it available by default without any prefix.

The test_cpuset_prs.sh test script and the cgroup-v2.rst documentation
file are also updated accordingly. Minor code change is also made in
test_cpuset_prs.sh to avoid false test failure when running on debug
kernel.

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
877c737d 20259566

+26 -15
+7
Documentation/admin-guide/cgroup-v2.rst
··· 2316 2316 treated to have an implicit value of "cpuset.cpus" in the 2317 2317 formation of local partition. 2318 2318 2319 + cpuset.cpus.isolated 2320 + A read-only and root cgroup only multiple values file. 2321 + 2322 + This file shows the set of all isolated CPUs used in existing 2323 + isolated partitions. It will be empty if no isolated partition 2324 + is created. 2325 + 2319 2326 cpuset.cpus.partition 2320 2327 A read-write single value file which exists on non-root 2321 2328 cpuset-enabled cgroups. This flag is owned by the parent cgroup
+1 -1
kernel/cgroup/cpuset.c
··· 3974 3974 .name = "cpus.isolated", 3975 3975 .seq_show = cpuset_common_seq_show, 3976 3976 .private = FILE_ISOLATED_CPULIST, 3977 - .flags = CFTYPE_ONLY_ON_ROOT | CFTYPE_DEBUG, 3977 + .flags = CFTYPE_ONLY_ON_ROOT, 3978 3978 }, 3979 3979 3980 3980 { } /* terminate */
+18 -14
tools/testing/selftests/cgroup/test_cpuset_prs.sh
··· 508 508 XECPUS=$DIR/cpuset.cpus.exclusive.effective 509 509 PRS=$DIR/cpuset.cpus.partition 510 510 PCPUS=$DIR/.__DEBUG__.cpuset.cpus.subpartitions 511 - ISCPUS=$DIR/.__DEBUG__.cpuset.cpus.isolated 511 + ISCPUS=$DIR/cpuset.cpus.isolated 512 512 [[ -e $CPUS ]] && echo "$CPUS: $(cat $CPUS)" 513 513 [[ -e $XCPUS ]] && echo "$XCPUS: $(cat $XCPUS)" 514 514 [[ -e $ECPUS ]] && echo "$ECPUS: $(cat $ECPUS)" ··· 593 593 594 594 # 595 595 # Get isolated (including offline) CPUs by looking at 596 - # /sys/kernel/debug/sched/domains and *cpuset.cpus.isolated control file, 596 + # /sys/kernel/debug/sched/domains and cpuset.cpus.isolated control file, 597 597 # if available, and compare that with the expected value. 598 598 # 599 599 # Note that isolated CPUs from the sched/domains context include offline 600 600 # CPUs as well as CPUs in non-isolated 1-CPU partition. Those CPUs may 601 - # not be included in the *cpuset.cpus.isolated control file which contains 601 + # not be included in the cpuset.cpus.isolated control file which contains 602 602 # only CPUs in isolated partitions. 603 603 # 604 604 # $1 - expected isolated cpu list(s) <isolcpus1>{,<isolcpus2>} 605 605 # <isolcpus1> - expected sched/domains value 606 - # <isolcpus2> - *cpuset.cpus.isolated value = <isolcpus1> if not defined 606 + # <isolcpus2> - cpuset.cpus.isolated value = <isolcpus1> if not defined 607 607 # 608 608 check_isolcpus() 609 609 { ··· 611 611 ISOLCPUS= 612 612 LASTISOLCPU= 613 613 SCHED_DOMAINS=/sys/kernel/debug/sched/domains 614 - ISCPUS=${CGROUP2}/.__DEBUG__.cpuset.cpus.isolated 614 + ISCPUS=${CGROUP2}/cpuset.cpus.isolated 615 615 if [[ $EXPECT_VAL = . ]] 616 616 then 617 617 EXPECT_VAL= ··· 692 692 null_isolcpus_check() 693 693 { 694 694 [[ $VERBOSE -gt 0 ]] || return 0 695 - pause 0.02 696 - check_isolcpus "." 697 - if [[ $? -ne 0 ]] 698 - then 699 - echo "Unexpected isolated CPUs: $ISOLCPUS" 700 - dump_states 701 - exit 1 702 - fi 695 + # Retry a few times before printing error 696 + RETRY=0 697 + while [[ $RETRY -lt 5 ]] 698 + do 699 + pause 0.01 700 + check_isolcpus "." 701 + [[ $? -eq 0 ]] && return 0 702 + ((RETRY++)) 703 + done 704 + echo "Unexpected isolated CPUs: $ISOLCPUS" 705 + dump_states 706 + exit 1 703 707 } 704 708 705 709 # ··· 780 776 # 781 777 NEWLIST=$(cat cpuset.cpus.effective) 782 778 RETRY=0 783 - while [[ $NEWLIST != $CPULIST && $RETRY -lt 5 ]] 779 + while [[ $NEWLIST != $CPULIST && $RETRY -lt 8 ]] 784 780 do 785 781 # Wait a bit longer & recheck a few times 786 782 pause 0.01