Re: [PATCH v4] PM: hibernate: Log the hibernation mode on entry

From: Rafael J. Wysocki (Intel)

Date: Fri Nov 13 2026 - 13:26:58 EST


On Thu, Oct 15, 2026 at 10:17 AM Yongxin Yang <yangyongxin@xxxxxxxxxx> wrote:
>
> The hibernation flow is the only place where the kernel decides what
> to do after a successful image write: hand over to the platform
> firmware (ACPI S4), power the system off, reboot it, or resume from
> the image right away. That decision leaves no trace in the log. If the
> resume path later fails or hangs, the tester cannot tell which outcome
> was requested, so a report of "the system rebooted instead of powering
> off" cannot be attributed to configuration or to platform behavior.
>
> The mode is selected through /sys/power/disk and stored in
> hibernation_mode. Append its name to the existing "hibernation entry"
> message, so that the line reads "hibernation entry (platform)",
> "hibernation entry (shutdown)", "hibernation entry (reboot)",
> "hibernation entry (suspend)" or "hibernation entry (test_resume)"
> instead of a bare "hibernation entry".
>
> The name comes from hibernation_modes[], the same table that
> /sys/power/disk uses, looked up directly by mode index.
>
> No functional change.
>
> Signed-off-by: Yongxin Yang <yangyongxin@xxxxxxxxxx>
> ---
> kernel/power/hibernate.c | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> index e365e440cd52..2bbfd7ffafe5 100644
> --- a/kernel/power/hibernate.c
> +++ b/kernel/power/hibernate.c
> @@ -72,6 +72,16 @@ enum {
> #define HIBERNATION_MAX (__HIBERNATION_AFTER_LAST-1)
> #define HIBERNATION_FIRST (HIBERNATION_INVALID + 1)
>
> +static const char * const hibernation_modes[] = {
> + [HIBERNATION_PLATFORM] = "platform",
> + [HIBERNATION_SHUTDOWN] = "shutdown",
> + [HIBERNATION_REBOOT] = "reboot",
> +#ifdef CONFIG_SUSPEND
> + [HIBERNATION_SUSPEND] = "suspend",
> +#endif
> + [HIBERNATION_TEST_RESUME] = "test_resume",
> +};
> +
> static int hibernation_mode = HIBERNATION_SHUTDOWN;
>
> bool freezer_test_done;
> @@ -794,7 +804,8 @@ int hibernate(void)
> goto Unlock;
> }
>
> - pr_info("hibernation entry\n");
> + pr_info("hibernation entry (%s)\n",
> + hibernation_modes[hibernation_mode]);
> pm_prepare_console();
> error = pm_notifier_call_chain_robust(PM_HIBERNATION_PREPARE, PM_POST_HIBERNATION);
> if (error)
> @@ -1130,17 +1141,6 @@ static int __init software_resume_initcall(void)
> }
> late_initcall_sync(software_resume_initcall);
>
> -
> -static const char * const hibernation_modes[] = {
> - [HIBERNATION_PLATFORM] = "platform",
> - [HIBERNATION_SHUTDOWN] = "shutdown",
> - [HIBERNATION_REBOOT] = "reboot",
> -#ifdef CONFIG_SUSPEND
> - [HIBERNATION_SUSPEND] = "suspend",
> -#endif
> - [HIBERNATION_TEST_RESUME] = "test_resume",
> -};
> -
> /*
> * /sys/power/disk - Control hibernation mode.
> *
> --

Applied as 7.5 material, thanks!