Re: [PATCH v2 3/3] PM: hibernate: log the task that initiated the power down
Bradley Morgan <[email protected]> Thu, 23 Jul 2026 16:38:09 +0100
| Newsgroups | org.infradead.lists.kexec,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pm |
|---|---|
| Message-ID | <[email protected]> |
On July 23, 2026 3:55:10 PM GMT+01:00, "Rafael J. Wysocki (Intel)" <[email protected]> wrote: >On Thu, Jul 23, 2026 at 4:46 PM Bradley Morgan <[email protected]> wrote: >> >> On July 23, 2026 2:55:41 PM GMT+01:00, "Rafael J. Wysocki (Intel)" >> <[email protected]> wrote: >> >On Tue, Jul 21, 2026 at 5:14 PM Bradley Morgan <[email protected]> >wrote: >> >> >> >> Give the hibernation power down the same treatment as the reboot >> >> syscall commands. >> > >> >Why? >> >> 1: Andrew suggested it [1] >> 2: because going down for hibernation is the same as "Wait, who the hell >took the box down?!" > >No, it is not the same unless the system doesn't resume. > >> > >> >> hibernate() runs in the context of the task that >> >> asked for it, whether through the reboot syscall or a write to >> > >> >It doesn't use the reboot syscall. >> >> Hmmm.... I may embarrass myself here, but it *could* (wink) >> >> See kernel/reboot.c: >> >> #ifdef CONFIG_HIBERNATION >> case LINUX_REBOOT_CMD_SW_SUSPEND: >> ret = hibernate(); >> break; >> #endif > >Ah, I'm wondering if anyone actually uses this, but fair enough. > >> >> /sys/power/disk, >> >> I'm wrong: /sys/power/state >> >> so when power_down() runs current is still the >> >> initiating task. >> >> >> >> Log it once the image has been written and the machine is committed >> >> to going down: >> >> >> >> reboot: initiated by systemd-sleep[812] >> >> reboot: Power down >> >> >> >> The line comes from kernel/reboot.c so it keeps the "reboot:" prefix >> >> and sits right next to the final "Restarting system", "Power down" >> >> or "System halted" line, same as a plain reboot. >> >> >> >> The one exception is platform mode rolling back on a pending wakeup >> >> event after the line has been printed. The existing "Wakeup event >> >> detected during hibernation, rolling back." line follows immediately >> >> in that case, so the log stays real about what happened. >> > >> >(a) Why is this information in the log useful? >> >> when the box just randomly goes down, some people prefer to know >> "And what process did this? Or what did this?", say >> >> "Was it systemd-sleep? Or some random power daemon?? Or some stray >> reboot(SW_SUSPEND)??" >> >> Userspace logging can't really do this... > >But it doesn't really go down in the case of hibernation. It's more >like suspend in that respect. > >> There is software out there which can do this, but it's not the >greatest. >> [2] >> >> Hence, this series! >> >> >(b) Do you realize that it only appears in the log when hibernation >> >fails or it may appear on a serial console or similar? >> >> yeah. The image is written when the line prints, so after a successful >> hibernate and resume dmesg won't have it. >> >> Thats exactly the >> same visibility as the final "Power down" / "Restarting system" line it >> sits next to >> >> Well, if you want it, please say. >> >> >> [1]: >> >https://lore.kernel.org/all/[email protected]/ >> >> [2]: https://docs.memfault.com/docs/linux/reboot-reason-tracking >> >> >> (oh and btw, if you don't buy in, it's ok, just say.. any questions, >ask) >> :) > >Yeah, I'm not convinced. > ack, dropped. btw. I wasn't the surest anyway abt swusp, don't worry. thanks for the review and sorry for wasting your time Thanks!