Suspend-then-hibernate sometimes doesn't start hibernation
systemd version the issue has been seen with
255.17
Used distribution
Gentoo
Linux kernel version used
6.15.4-gentoo-x86_64
CPU architectures issue was seen on
x86_64
Component
systemd-logind
Expected behaviour you didn't see
System should hibernate after HibernateDelaySec.
Unexpected behaviour you saw
System correctly wake up after HibernateDelaySec but won't start hibernation. Sometimes. Sometimes it does. No log messages. I've turned on debug logs and it seems that it fails due to this part of code:
In my case when hibernation fails woken_by_timer is set to 0, which means that logind thinks that system was woken by user and won't start hibernating. After some digging around seems to me that issue is in zero timeout in ppoll function call:
r = fd_wait_for_event(tfd, POLLIN, 0);
I've changed it to 500ms:
r = fd_wait_for_event(tfd, POLLIN, 500*1000);
and since that time it works good.
This issue occur on my Framework 13 laptop (last generation, AMD AI). There were half a year ago same issue (but finally closed by reporter) also with Framework laptops. I'm not sure how linux timers are supposed to work. Maybe it can be some rounding error in Framework firmware that laptop is actually woken by timer a little bit earlier so this code executes before the timer set by logind actually send POLLIN event?
Steps to reproduce the problem
- Execute loginctl suspend-then-hibernate and wait more then configured HibernateDelaySec interval.
Additional program output to the terminal or log subsystem illustrating the issue
Source: systemd/systemd