From: Waiman Long <longman@redhat.com>
To: "Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Ridong Chen" <ridong.chen@linux.dev>,
"Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Juri Lelli" <juri.lelli@redhat.com>,
"Vincent Guittot" <vincent.guittot@linaro.org>,
"Dietmar Eggemann" <dietmar.eggemann@arm.com>,
"Steven Rostedt" <rostedt@goodmis.org>,
"Ben Segall" <bsegall@google.com>, "Mel Gorman" <mgorman@suse.de>,
"Valentin Schneider" <vschneid@redhat.com>,
"K Prateek Nayak" <kprateek.nayak@amd.com>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Thomas Gleixner" <tglx@kernel.org>
Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
Guopeng Zhang <guopeng.zhang@linux.dev>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Waiman Long <longman@redhat.com>
Subject: [PATCH-next 3/3] cgroup/cpuset: Disallow CPU 0 from being used in isolated partition
Date: Fri, 20 Nov 2026 22:13:29 -0500 [thread overview]
Message-ID: <20261121031329.240177-4-longman@redhat.com> (raw)
In-Reply-To: <20261121031329.240177-1-longman@redhat.com>
Domain isolating CPU 0 can be problematic and may even cause panic in
some cases. So it is better to disable its use in an isolated partition.
Add a new partition error code to indicate to the users that CPU 0
cannot be used in an isolated partition.
Some existing test cases in test_cpuset_prs.sh are modified to remove
the use of CPU 0 in isolated partition setup and explicit new test cases
are added to test that. The NOHZ_FULL test cases also modified to run if
the "nohz_full" parameters includes all the CPUs except CPU 1-7 instead
of 0-7. Though it is not recommended to put CPU 0 in the nohz_full boot
parameter, it is the only way we can test that the cpuset code is able to
correctly disallow isolating the last nohz_full/domain housekeeping CPU.
With CPU 0 likely not allowed in the nohz_full list and with CPU 0 also
disallowed from being domain isolated and offline, we will likely have CPU
0 being an always present online housekeeping CPU for most kernels. For
those kernels, we will not be able to trigger partition invalidation due
to using up the last nohz_full/domain housekeeping CPU in an isolated
partition and the NOHZ_FULL test cases in test_cpuset_prs.sh will not
be run.
The cgroup-v2.rst documentation file is also modified to indicate that
CPU 0 cannot be used in an isolated partition.
Signed-off-by: Waiman Long <longman@redhat.com>
---
Documentation/admin-guide/cgroup-v2.rst | 1 +
kernel/cgroup/cpuset-internal.h | 1 +
kernel/cgroup/cpuset.c | 6 +++
.../selftests/cgroup/test_cpuset_prs.sh | 43 ++++++++++++-------
4 files changed, 36 insertions(+), 15 deletions(-)
diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index 9e3c67b02ae2..2f792ff29425 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -2771,6 +2771,7 @@ Cpuset Interface Files
and excluded from the unbound workqueues. Tasks placed in such
a partition with multiple CPUs should be carefully distributed
and bound to each of the individual CPUs for optimal performance.
+ The boot CPU (CPU 0) cannot be used in an isolated partition.
A partition root ("root" or "isolated") can be in one of the
two possible states - valid or invalid. An invalid partition
diff --git a/kernel/cgroup/cpuset-internal.h b/kernel/cgroup/cpuset-internal.h
index 1ba94ffaff9d..505682493d81 100644
--- a/kernel/cgroup/cpuset-internal.h
+++ b/kernel/cgroup/cpuset-internal.h
@@ -36,6 +36,7 @@ enum prs_errcode {
PERR_ACCESS,
PERR_REMOTE,
PERR_ISOPARENT,
+ PERR_ISOLCPU0,
};
/* bits in struct cpuset flags field */
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 30af9531acdd..68d104d0bdf5 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -61,6 +61,7 @@ static const char * const perr_strings[] = {
[PERR_ACCESS] = "Enable partition not permitted",
[PERR_REMOTE] = "Have remote partition underneath",
[PERR_ISOPARENT] = "Root partition is not allowed with isolated parent",
+ [PERR_ISOLCPU0] = "Boot CPU (cpu 0) cannot be isolated",
};
/*
@@ -1453,6 +1454,9 @@ static enum prs_errcode validate_partition(struct cpuset *cs,
if (tasks_nocpu_error(parent, cs, new_excpus))
return PERR_NOCPUS;
+ if ((new_prs == PRS_ISOLATED) && cpumask_test_cpu(0, new_excpus))
+ return PERR_ISOLCPU0;
+
return PERR_NONE;
}
@@ -3002,6 +3006,8 @@ static int update_prstate(struct cpuset *cs, int new_prs)
err = PERR_HKEEPING;
else if (parent_prs == PRS_ISOLATED)
err = PERR_ISOPARENT; /* old_prs should be isolated */
+ else if ((new_prs == PRS_ISOLATED) && cpumask_test_cpu(0, cs->effective_xcpus))
+ err = PERR_ISOLCPU0;
if (err) {
disable_partition = true;
diff --git a/tools/testing/selftests/cgroup/test_cpuset_prs.sh b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
index 1397ec428c46..735d515ffc10 100755
--- a/tools/testing/selftests/cgroup/test_cpuset_prs.sh
+++ b/tools/testing/selftests/cgroup/test_cpuset_prs.sh
@@ -110,8 +110,8 @@ echo "" > test/cpuset.cpus
#
# 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 in a single range
+# CPUs 1-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 1-7 in a single range
# <first>-<last>, we can run a special set of housekeeping CPUs exhaustion
# tests to see if the cpuset code will reject them.
#
@@ -123,14 +123,22 @@ NOHZ_FULL_CPUS=
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/,.*//;s/.*[-]//")
+ if [[ $(expr $NOHZ_FULL_CPUS : "^0,") -gt 0 ]]
+ then
+ NOHZ_CPU0=1
+ NOHZ_CPUS=$(echo $NOHZ_FULL_CPUS | sed -e "s/^0,//")
+ else
+ NOHZ_CPUS=$NOHZ_FULL_CPUS
+ fi
+ FIRST_NOHZ_FULL_CPU=$(echo $NOHZ_CPUS | sed -e "s/[,-].*//")
+ LAST_NOHZ_FULL_CPU=$(echo $NOHZ_CPUS | sed -e "s/,.*//;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 &&
+ -n "$NOHZ_CPU0" &&
"$LAST_NOHZ_FULL_CPU" = $LAST_PRESENT_CPU ]] && RUN_NOHZ_FULL_TESTS=1
#
@@ -394,8 +402,8 @@ TEST_MATRIX=(
# Invalid to valid local partition direct transition tests
" C1-3:P2 X4:P2 . . . . . . 0 A1:1-3|XA1:1-3|A2:1-3:XA2: A1:P2|A2:P-2 1-3"
" C1-3:P2 X4:P2 . . . X3:P2 . . 0 A1:1-2|XA1:1-3|A2:3:XA2:3 A1:P2|A2:P2 1-3"
- " C0-3:P2 . . C4-6 C0-4 . . . 0 A1:0-4|B1:5-6 A1:P2|B1:P0"
- " C0-3:P2 . . C4-6 C0-4:C0-3 . . . 0 A1:0-3|B1:4-6 A1:P2|B1:P0 0-3"
+ " C1-3:P2 . . C4-6 C1-4 . . . 0 A1:1-4|B1:5-6 A1:P2|B1:P0"
+ " C1-3:P2 . . C4-6 C1-4:C1-3 . . . 0 A1:1-3|B1:4-6 A1:P2|B1:P0 1-3"
# Local partition invalidation tests
" C0-3:X1-3:P2 C1-3:X2-3:P2 C2-3:X3:P2 \
@@ -506,6 +514,11 @@ TEST_MATRIX=(
" CX1-4 CX2-4:P2 . C5-6 . . . P1:C3-6 0 A1:1|A2:2-4|B1:5-6 \
A1:P0|A2:P2:B1:P-1 2-4"
+ # CPU 0 cannot be used in an isolated partition
+ " CX0-4 . . . P2 . . . 0 A1:0-4 A1:P-2"
+ " CX0-4 C0-2:P1 . . . P2 . . 0 A1:0-4:A2:0-2 A2:P-2"
+ " CX0-4 C3-4:P2 . . . C0-2 . . 0 A1:0-4:A2:0-2 A2:P-2"
+
# When multiple partitions with conflicting cpuset.cpus are created, the
# latter created ones will only get what are left of the available exclusive
# CPUs.
@@ -525,8 +538,8 @@ TEST_MATRIX=(
# A middle isolated parent shrunk below coverage: the released CPUs of
# an invalidated child stay isolated as a higher ancestor still covers them.
- " CX0-4:P2 CX2-4:P2 CX3-4:P2 . . X2 . . 0 A1:0-1,3-4|A2:2|A3:2 \
- A1:P2|A2:P2|A3:P-2 0-4"
+ " CX1-4:P2 CX2-4:P2 CX3-4:P2 . . X2 . . 0 A1:1,3-4|A2:2|A3:2 \
+ A1:P2|A2:P2|A3:P-2 1-4"
# When an isolated partition child with root partition parent is invalidated,
# its effective xcpus will be removed from isolated_cpus.
@@ -618,20 +631,20 @@ 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
+# Test matrix to be run when boot time nohz_full CPUs cover all CPUs except CPUs 1-7
# This also means that CPU 8 is available and is a nohz_full CPU.
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"
+ " C1-7 . . . P2 . . . 0 A1:1-7 A1:P-2 ."
+ " C2-7:P2 . . . C1-4 . . . 0 A1:1-4 A1:P2 1-4"
+ " C2-7:P2 C5-7:P2 . . . . . C1:P2 0 A1:2-4|A2:5-7|B1:1
+ A1:P2|A2:P2|B1:P-2 2-7"
# An isolated child partition cannot grow to take over the last
# housekeeping CPU when its parent expands the exclusive CPUs.
- " C0-8:X1-8:P1 CX0-8:P2 . . X0-7 . . . 0 A1:0-7|A2:0-7 A1:P1|A2:P-2 ."
- " C0-8:X0-6:P1 CX0-8:P2 . . X2-8 . . . 0 A1:|A2:2-8 A1:P1|A2:P2 2-8"
+ " C1-8:X1-8:P1 CX1-8:P2 . . X1-7 . . . 0 A1:0-7|A2:0-7 A1:P1|A2:P-2 ."
+ " C1-8:X0-6:P1 CX1-8:P2 . . X2-8 . . . 0 A1:|A2:2-8 A1:P1|A2:P2 2-8"
)
#
--
2.56.1
prev parent reply other threads:[~2026-11-21 3:14 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-21 3:13 [PATCH-next 0/3] Skip boot CPU or don't allow it from being used in isolcpus and isolated partitions Waiman Long
2026-11-21 3:13 ` [PATCH-next 1/3] tick/sched: Make tick_nohz_full_mask and HK_TYPE_KERNEL_NOISE cpumask consistent Waiman Long
2026-11-21 3:13 ` [PATCH-next 2/3] sched/isolation: Forbid the boot CPU from being isolated Waiman Long
2026-11-21 3:13 ` Waiman Long [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261121031329.240177-4-longman@redhat.com \
--to=longman@redhat.com \
--cc=anna-maria@linutronix.de \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=corbet@lwn.net \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=guopeng.zhang@linux.dev \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=peterz@infradead.org \
--cc=rdunlap@infradead.org \
--cc=ridong.chen@linux.dev \
--cc=rostedt@goodmis.org \
--cc=skhan@linuxfoundation.org \
--cc=tglx@kernel.org \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.