Re: [PATCH] PM: hibernate: call preallocate_image after freeze prepare

From: Matthew Leach

Date: Tue Mar 24 2026 - 05:33:58 EST


YoungJun Park <youngjun.park@xxxxxxx> writes:

> On Sat, Mar 21, 2026 at 08:51:31AM +0000, Matthew Leach wrote:
>
> Hi Matthew,

Hi Youngjun,

Thanks for the review.

>> + /* Preallocate image memory before shutting down devices. */
>> + error = hibernate_preallocate_memory();
>
> The shrink_shmem_memory() below is also intended to run after
> dpm_prepare(), and the motivation is the same. Since
> hibernate_preallocate_memory() already does shrinking internally,
> how about pulling out the shrink-related parts and consolidating
> them together?

Agreed. I'll remove shrink_shmem_memory() completely since
hibernate_preallocate_memory() will have swapped out as many pages as is
required to construct the image in system RAM. There's no point doing
another reclaim.

>> + if (error)
>> + goto Thaw;
>
> Don't we need to call dpm_complete(PMSG_RECOVER) in this error path?

Yes, good catch.

Regards,
--
Matt