From: Guopeng Zhang <guopeng.zhang@linux.dev>
To: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>, Thomas Gleixner <tglx@kernel.org>,
Waiman Long <longman@redhat.com>
Cc: "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>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Ridong Chen" <ridong.chen@linux.dev>,
"Tejun Heo" <tj@kernel.org>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Michal Koutný" <mkoutny@suse.com>,
"Srivatsa S . Bhat" <srivatsa.bhat@linux.vnet.ibm.com>,
"Guopeng Zhang" <guopeng.zhang@linux.dev>,
cgroups@vger.kernel.org, linux-kernel@vger.kernel.org,
"Guopeng Zhang" <zhangguopeng@kylinos.cn>
Subject: [RFC PATCH 0/3] sched: Handle CPU freeze without active domain housekeeping CPUs
Date: Wed, 22 Jul 2026 19:52:35 +0800 [thread overview]
Message-ID: <20260722115238.351821-1-guopeng.zhang@linux.dev> (raw)
From: Guopeng Zhang <zhangguopeng@kylinos.cn>
During suspend, freeze_secondary_cpus() takes every CPU except the
primary offline. With domain isolation, the primary CPU can be excluded
from HK_TYPE_DOMAIN. Offlining the last domain housekeeping CPU then
leaves the frozen hotplug path without an active CPU in that mask.
This exposes three related problems. The frozen cpuset callback asks for
one fallback scheduler domain even though its span is empty. A user task
restricted to the CPUs being frozen can exhaust select_fallback_rq()
because the normal fallback mask has no active CPU. Finally, forcing such
a task onto a temporary CPU clears user_cpus_ptr, so the temporary
affinity can survive after the CPUs are brought back online.
This series preserves and restores user affinity across the frozen CPU
fallback, permits an isolated but task-capable active CPU as a temporary
last resort, and explicitly tears down scheduler domains while no active
HK_TYPE_DOMAIN CPU exists.
I am sending this as an RFC because the first patch adds scheduler state
for the freeze transaction and collects affected tasks during thaw. In
particular, feedback would be useful on the task tracking and restore
scheme, the use of task_cpu_possible_mask() as the temporary fallback,
and the explicit zero-domain request passed to
partition_sched_domains().
Reproduction
============
The problem was reproduced on a 32-CPU x86 physical machine booted with:
isolcpus=domain,0,3-31
This leaves CPUs 1 and 2 in HK_TYPE_DOMAIN while the suspend primary is
CPU0. On an unpatched 7.2.0-rc3-next-20260716 kernel, with
panic_on_warn=0 and warn_limit=0, the following processor-stage suspend
test crashed the machine:
echo deep > /sys/power/mem_sleep
echo processors > /sys/power/pm_test
echo mem > /sys/power/state
After CPU2 had been taken offline, rebuilding the scheduler domains for
CPU1 produced an empty span warning, followed by a general protection
fault in build_perf_domains():
smpboot: CPU 2 is now offline
------------[ cut here ]------------
WARNING: kernel/sched/topology.c:3093 at build_sched_domains+0x443/0xa60
...
Call Trace:
partition_sched_domains_locked+0x2dd/0x710
partition_sched_domains+0x30/0x40
cpuset_reset_sched_domains+0x25/0x40
sched_cpu_deactivate+0x2f2/0x300
...
Oops: general protection fault, probably for non-canonical address ...
RIP: 0010:build_perf_domains+0x40/0x230
Call Trace:
partition_sched_domains_locked+0x3d9/0x710
partition_sched_domains+0x30/0x40
cpuset_reset_sched_domains+0x25/0x40
sched_cpu_deactivate+0x2f2/0x300
Kdump captured a vmcore after the fault. This was not a panic_on_warn
failure.
Testing
=======
With this series applied, the processor-stage test was repeated while
the shell was restricted to the two domain housekeeping CPUs:
taskset -pc 1,2 $$
echo deep > /sys/power/mem_sleep
echo processors > /sys/power/pm_test
echo mem > /sys/power/state
ret=$?
echo none > /sys/power/pm_test
echo "return=$ret"
taskset -pc $$
cat /sys/devices/system/cpu/online
The fallback path was exercised:
process 7271 (bash) no longer affine to cpu1
The test completed successfully and the requested affinity and online
CPU mask were restored:
return=0
pid 7271's current affinity list: 1,2
0-31
A real S3 cycle was then tested with:
echo deep > /sys/power/mem_sleep
echo none > /sys/power/pm_test
rtcwake -m no -s 10
echo mem > /sys/power/state
ret=$?
echo "return=$ret"
taskset -pc $$
cat /sys/devices/system/cpu/online
The machine entered S3, resumed, and brought CPUs 1-31 back online. The
result was again:
return=0
pid 7271's current affinity list: 1,2
0-31
Neither test produced a scheduler-domain warning, GPF, BUG, Oops, or
panic.
Each patch was build-tested in sequence with x86_64_defconfig. The final
series completed a full x86_64 build. The affected objects were also
build-tested with CONFIG_CPUSETS=n and CONFIG_CPU_ISOLATION=y.
Guopeng Zhang (3):
sched: Preserve user affinity across frozen CPU fallback
sched: Allow isolated CPUs as a last resort during CPU freeze
sched/topology: Tear down domains without active domain housekeeping
CPUs
include/linux/cpuset.h | 7 +-
include/linux/sched/hotplug.h | 2 +
kernel/cgroup/cpuset.c | 6 +-
kernel/cpu.c | 2 +
kernel/sched/core.c | 191 ++++++++++++++++++++++++++++++++--
kernel/sched/sched.h | 4 +-
kernel/sched/topology.c | 9 +-
7 files changed, 207 insertions(+), 14 deletions(-)
base-commit: 0718283ab28bc3907e10b61a6b4be6fefa1cbb2f
--
2.43.0
next reply other threads:[~2026-07-22 11:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 11:52 Guopeng Zhang [this message]
2026-07-22 11:52 ` [RFC PATCH 1/3] sched: Preserve user affinity across frozen CPU fallback Guopeng Zhang
2026-07-22 11:52 ` [RFC PATCH 2/3] sched: Allow isolated CPUs as a last resort during CPU freeze Guopeng Zhang
2026-07-22 11:52 ` [RFC PATCH 3/3] sched/topology: Tear down domains without active domain housekeeping CPUs Guopeng Zhang
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=20260722115238.351821-1-guopeng.zhang@linux.dev \
--to=guopeng.zhang@linux.dev \
--cc=bsegall@google.com \
--cc=cgroups@vger.kernel.org \
--cc=dietmar.eggemann@arm.com \
--cc=frederic@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=juri.lelli@redhat.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mkoutny@suse.com \
--cc=peterz@infradead.org \
--cc=ridong.chen@linux.dev \
--cc=rostedt@goodmis.org \
--cc=srivatsa.bhat@linux.vnet.ibm.com \
--cc=tglx@kernel.org \
--cc=tj@kernel.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=zhangguopeng@kylinos.cn \
/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.