[PATCH] PM: Restrict swap use to later in the suspend sequence

Baoquan He bhe at redhat.com
Sun Jun 22 20:23:43 PDT 2025


On 06/13/25 at 04:43pm, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello at amd.com>
> 
> Currently swap is restricted before drivers have had a chance to do their
> prepare() PM callbacks. Restricting swap this early means that if a driver
> needs to evict some content from memory into sawp in it's prepare callback
> it won't be able to.
> 
> On AMD dGPUs this can lead to failed suspends under memory pressure
> situations as all VRAM must be evicted to system memory or swap.
> 
> Move the swap restriction to right after all devices have had a chance to
> do the prepare() callback.  If there is any problem with the sequence,
> restore swap in the appropriate dpm resume callbacks or error handling
> paths.
> 
> Closes: https://github.com/ROCm/ROCK-Kernel-Driver/issues/174
> Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/2362
> Signed-off-by: Mario Limonciello <mario.limonciello at amd.com>
> ---
>  drivers/base/power/main.c | 5 ++++-
>  include/linux/suspend.h   | 5 +++++
>  kernel/kexec_core.c       | 1 +
>  kernel/power/hibernate.c  | 3 ---
>  kernel/power/power.h      | 5 -----
>  kernel/power/suspend.c    | 3 +--
>  6 files changed, 11 insertions(+), 11 deletions(-)
> 
......snip...
> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> index 9c59fa480b0b6..3a9a9f240dbc9 100644
> --- a/kernel/kexec_core.c
> +++ b/kernel/kexec_core.c
> @@ -1136,6 +1136,7 @@ int kernel_kexec(void)
>   Resume_devices:
>  		dpm_resume_end(PMSG_RESTORE);
>   Resume_console:
> +		pm_restore_gfp_mask();
>  		console_resume_all();
>  		thaw_processes();
>   Restore_console:

This change is inside KEXEC_JUMP scope, let David know this because he
ever tested and made change for KEXEC_JUMP.
......




More information about the kexec mailing list