Currently on Linux if you are putting the system into hibernation, there isn’t a way to interrupt it and cancel it if you change your mind, even with most systems taking a number of seconds to successfully hibernate. But a new patch series sent out this weekend would introduce that capability.
Muhammad Usama Anjum of Collabora sent out a patch series this weekend to allow hibernation cancellation support. Basically for cancelling an ongoing hibernation process should you change your mind and not want to wait for the system to first successfully hibernate.
The patch series was sent out as a Request For Comments (RFC) and explained as:
“On a normal laptop/PC, the hibernation takes 15-20 seconds which is considerable time. Once hibernation is triggered from command line or by some GUI option, the hibernation cannot be cancelled until completed. Its not a blocker, but poor user experience.
When power button is pressed during hibernation, it generates interrupt and then the event is routed to userspace. If systemd is being used, the logind handles these events and performs the specific action.
During hibernation, the first stage is to freeze the userspace. Hence even if the power button is pressed, it doesn’t aborts the hibernation as user space daemon is frozen.
My device takes ~19 seconds to hibernate. When I was testing hibernation using rtcwake with timeout of 10 seconds, I found out that hibernation gets canceled around 10 seconds mark when the interrupt fires.
In this series, the idea is to find a way to cancel the hibernation. With this series applied, the hibernation gets cancelled gracefully.”
Adding this cancellation support amounts to just around two dozen lines of code. In turn this work has also led to some fixes by AMD’s Mario Limonciello being sent out that exposed a bug in the AMDGPU handling for skipping the thaw step.
We’ll see what more comes about with this proposed hibernation cancellation support for Linux.