RE: [PATCH] PM: hibernate: Freeze kernel threads in software_resume()

From: Dexuan Cui
Date: Sun Apr 26 2020 - 20:59:01 EST


> From: Bart Van Assche <bvanassche@xxxxxxx>
> Sent: Sunday, April 26, 2020 11:34 AM
> To: Rafael J. Wysocki <rjw@xxxxxxxxxxxxx>; Dexuan Cui <decui@xxxxxxxxxxxxx>
> >> --- a/kernel/power/hibernate.c
> >> +++ b/kernel/power/hibernate.c
> >> @@ -898,6 +898,13 @@ static int software_resume(void)
> >> error = freeze_processes();
> >> if (error)
> >> goto Close_Finish;
> >> +
> >> + error = freeze_kernel_threads();
> >> + if (error) {
> >> + thaw_processes();
> >> + goto Close_Finish;
> >> + }
> >> +
> >> error = load_image_and_restore();
> >> thaw_processes();
> >> Finish:
> >
> > Applied as a fix for 5.7-rc4, thanks!
>
> Hi Rafael,
>
> What is not clear to me is how kernel threads are thawed after
> load_image_and_restore() has finished? Should a comment perhaps be added
> above the freeze_kernel_threads() call that explains how
> thaw_kernel_threads() is invoked after load_image_and_restore() has
> finished?
>
> Bart.

Hi Bart, Rafael, I would suggest the below comment:

If load_image_and_restore() succeeds, it won't return, and the
execution will be restored from the 'old' kernel's hibernate() ->
hibernation_snapshot() -> create_image() -> swsusp_arch_suspend(),
and later hibernate() -> thaw_processes() will thaw every frozen
kernel process and userspace process of the 'old' kernel.

Thanks,
-- Dexuan