Skip to content

Commit 877c737

Browse files
Waiman-Longhtejun
authored andcommitted
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 <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 2025956 commit 877c737

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

Documentation/admin-guide/cgroup-v2.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,6 +2316,13 @@ Cpuset Interface Files
23162316
treated to have an implicit value of "cpuset.cpus" in the
23172317
formation of local partition.
23182318

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+
23192326
cpuset.cpus.partition
23202327
A read-write single value file which exists on non-root
23212328
cpuset-enabled cgroups. This flag is owned by the parent cgroup

kernel/cgroup/cpuset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3974,7 +3974,7 @@ static struct cftype dfl_files[] = {
39743974
.name = "cpus.isolated",
39753975
.seq_show = cpuset_common_seq_show,
39763976
.private = FILE_ISOLATED_CPULIST,
3977-
.flags = CFTYPE_ONLY_ON_ROOT | CFTYPE_DEBUG,
3977+
.flags = CFTYPE_ONLY_ON_ROOT,
39783978
},
39793979

39803980
{ } /* terminate */

tools/testing/selftests/cgroup/test_cpuset_prs.sh

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ dump_states()
508508
XECPUS=$DIR/cpuset.cpus.exclusive.effective
509509
PRS=$DIR/cpuset.cpus.partition
510510
PCPUS=$DIR/.__DEBUG__.cpuset.cpus.subpartitions
511-
ISCPUS=$DIR/.__DEBUG__.cpuset.cpus.isolated
511+
ISCPUS=$DIR/cpuset.cpus.isolated
512512
[[ -e $CPUS ]] && echo "$CPUS: $(cat $CPUS)"
513513
[[ -e $XCPUS ]] && echo "$XCPUS: $(cat $XCPUS)"
514514
[[ -e $ECPUS ]] && echo "$ECPUS: $(cat $ECPUS)"
@@ -593,25 +593,25 @@ check_cgroup_states()
593593
594594
#
595595
# 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,
597597
# if available, and compare that with the expected value.
598598
#
599599
# Note that isolated CPUs from the sched/domains context include offline
600600
# 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
602602
# only CPUs in isolated partitions.
603603
#
604604
# $1 - expected isolated cpu list(s) <isolcpus1>{,<isolcpus2>}
605605
# <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
607607
#
608608
check_isolcpus()
609609
{
610610
EXPECT_VAL=$1
611611
ISOLCPUS=
612612
LASTISOLCPU=
613613
SCHED_DOMAINS=/sys/kernel/debug/sched/domains
614-
ISCPUS=${CGROUP2}/.__DEBUG__.cpuset.cpus.isolated
614+
ISCPUS=${CGROUP2}/cpuset.cpus.isolated
615615
if [[ $EXPECT_VAL = . ]]
616616
then
617617
EXPECT_VAL=
@@ -692,14 +692,18 @@ test_fail()
692692
null_isolcpus_check()
693693
{
694694
[[ $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
703707
}
704708

705709
#
@@ -776,7 +780,7 @@ run_state_test()
776780
#
777781
NEWLIST=$(cat cpuset.cpus.effective)
778782
RETRY=0
779-
while [[ $NEWLIST != $CPULIST && $RETRY -lt 5 ]]
783+
while [[ $NEWLIST != $CPULIST && $RETRY -lt 8 ]]
780784
do
781785
# Wait a bit longer & recheck a few times
782786
pause 0.01

0 commit comments

Comments
 (0)