Re: [PATCH] cpufreq: fix race between hotplug and suspend

From: Tianxiang Chen

Date: Tue Apr 07 2026 - 21:46:59 EST


On Tue, 7 Apr 2026, Rafael J. Wysocki wrote:
> So how exactly would CPU hotplug be started during a system suspend or resume?

Hi Rafael,

Thank you for your question. Let me explain the two scenarios:

1. cpufreq_suspend() During Reboot (Confirmed Issue)

The real and reproducible race I encountered occurs during system reboot.

Call chain:
kernel_restart() -> kernel_restart_prepare()
-> device_shutdown() -> cpufreq_suspend()

Different from the regular suspend path, the reboot path does NOT call
freeze_processes() at all.

All userspace processes, drivers and kernel threads are
still running when cpufreq_suspend() executes. This allows CPU hotplug
(offline/online) operations to run concurrently with cpufreq_suspend().

2. System suspend/resume (Less Likely but Possible)

CPU hotplug is less likely during system suspend/resume. However,
non-freezable kernel threads may keep running throughout the entire
process, which may still trigger CPU hotplug in theory.

So I added cpus_read_lock()/cpus_read_unlock() to block CPU hotplug
while resume is in progress.


--
Thx and BRs,
Tianxiang Chen