Re: [PATCH] cpufreq: fix race between hotplug and suspend
From: Rafael J. Wysocki
Date: Wed Apr 08 2026 - 06:33:38 EST
On Wed, Apr 8, 2026 at 3:46 AM Tianxiang Chen <nanmu@xxxxxxxxxx> wrote:
>
> 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)
Which needs to be mentioned in the patch changelog.
> 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.
That's correct.
> 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.
Which would be a bug in the kernel thread in question. So not really.
> So I added cpus_read_lock()/cpus_read_unlock() to block CPU hotplug
> while resume is in progress.
Please resend the patch with a changelog actually mentioning the
failure that you have observed.
Thanks!