Re: [PATCH] PM: hibernate: Freeze kernel threads after image preallocation

From: Thorsten Leemhuis

Date: Tue Sep 22 2026 - 01:11:15 EST


On 9/20/26 16:35, Florian Schmaus wrote:
> Commit 783c81098445 ("PM: hibernate: call preallocate_image() after freeze
> prepare") moved hibernate_preallocate_memory() after dpm_prepare() so
> that device drivers have the opportunity to release pinned/unswappable
> memory during their ->prepare() callback before memory is preallocated
> for the snapshot image.
>
> However, that commit also placed hibernate_preallocate_memory() after
> freeze_kernel_threads(). While it was assumed during review that swap
> I/O submitted via submit_bio() is synchronous and would not depend on
> frozen kernel threads, this does not hold in practice. Calling
> hibernate_preallocate_memory() with kernel threads frozen leads to
> intermittent deadlocks during hibernation.
> [...]
> Fixes: 783c81098445 ("PM: hibernate: call preallocate_image() after freeze prepare")
> Signed-off-by: Florian Schmaus <flo@xxxxxxxxxxxx>

TWIMC, there are two reports about hibernate problems that identified
the mentioned commit as culprit (in one case while a stable backport was
prepared that was dropped meanwhile). One of the reporters mentioned
that the quoted patch fixed things in 7.2.y (see the last of the
following links):

https://lore.kernel.org/all/CALjEBWT9wyBYtWPgtg8Xd_FxRU_XnatzQMcwMB9_P2Fdj83+cQ@xxxxxxxxxxxxxx/#t
https://lore.kernel.org/all/CALjEBWQo0-Sdimo+aRNKUQvgDGw=jBFCcfwCXaqVdtoPrHLAQA@xxxxxxxxxxxxxx/
https://lore.kernel.org/all/CAKp=m=DkRA3FQdJC+1AKDtn1X8ZuO0HRF5H7PJVf15uQyBuEbg@xxxxxxxxxxxxxx/


Adding a stable tag would likely a nice touch.

Ciao, Thorsten