CLOCK_MONOTONIC advancing while in s2idle state

From: Yuri D'Elia
Date: Wed Jul 18 2018 - 10:15:19 EST


Hi everyone. What should be the intended behavior of CLOCK_MONOTONIC
during the s2idle state? Should the clock pause during s2idle, like it
does in s3?

On my current hardware, it is not.

I randomly discovered that the Lenovo X1 Yoga (3rd gen) and the X1
Carbon (6th gen) do not advertise S3 anymore [0], probably to force S0i3
in Windows. Buggy bios aside, this causes this laptop to sleep in s2idle
mode instead.

When waking up from s2idle though CLOCK_MONOTONIC includes the slept
time. This causes the systemd watchdog to kill journald [1] as it
detects no activity during the slept time. According to systemd authors,
this is not the intended behavior in _any_ sleep state and thus it's a
kernel bug.

I verified this behavior from kernels 4.16 up to 4.18-rc4 (debian
packages). Is this a bug in the implementation of s2idle?

Thanks

[0] https://forums.lenovo.com/t5/Linux-Discussion/X1-Carbon-Gen-6-cannot-enter-deep-sleep-S3-state-aka-Suspend-to/td-p/3998182
[1] https://github.com/systemd/systemd/issues/9538