2

Kubuntu 20.04 on Macbook Air suspends fine but takes too much time to wake up each time, about 20 seconds.

It seems to be a case of normal suspend/ sleep, not hibernation, given systemctl suspend triggers the same behavior.

running that, waking and then running

journalctl -b --since "1min ago"

I get this (on Pastebin). there is no hibernation mentioned there.

As for memory and swap, I think there is enough RAM:

~$ free -h
               total        used        free      shared  buff/cache   available
Mem:           3,8Gi       703Mi       1,7Gi       162Mi       1,4Gi       2,7Gi
Swap:          2,0Gi       440Mi       1,6Gi
cipricus
  • 3,444
  • 2
  • 34
  • 85

1 Answers1

2

Short answer:

In 22.04:

echo deep | sudo tee -a /sys/power/mem_sleep

If the above doesn't work in 22.04 or if this happens in 22.10, 23.04 or later:

echo s2idle | sudo tee -a /sys/power/mem_sleep

The solution may stop working after kernel updates, and even after reboots, so a script with the needed command can be run at reboot.

The first part is a bit contradictory, because deep should always trigger the long wake-up and s2idle the short one, as said here. Probably something buggy was about in my 22.04 where at least apparently the opposite was sometimes the case.


Long answer:

Very soon after having posted this question I have stumbled upon a solution that seemed to work: on ubuntuforums here, with more advice in reply to that, here.

I don't really understand how this worked, a bug might be involved. That post says that the solution is to switch /sys/power/mem_sleep from s2idle to deep. That was unclear to me because looking up that file it contained this single line:

s2idle [deep]

which means that deep was already selected (!!) ­— not to mention that, as said above, the opposite behavior was to be expected. —

I have understood what the command does that after asking about it here.

As instructed in the initial ubuntuforums comments , I haven't tried to change that file as such, but I have used the command (based also on the second comment):

echo deep | sudo tee -a /sys/power/mem_sleep

Looking again at that file it seemed unchanged though. Even after restart it was still s2idle [deep], but at that point the wake from suspend was instantaneous! (Which, as far as I know in retrospective was, as said, the opposite of what was expected: deep should mean long wake-up!)

It seems that the file was not changed by that command, but something was changed - related to that file or not.

Changing that to [s2idle] deep with a corresponding command echo s2idle | sudo tee -a /sys/power/mem_sleep (in order to investigate this a bit, as discussed in comments related with the linked question) the 20-second long time waking problem did not re-appear.

Maybe some bug that I cannot track was at play.

After some kernel update the initial problem re-appeared and was fixed in the same way. (Indeed the file /sys/power/mem_sleep was already in the form that the command is supposed to trigger, but the latter is needed nonetheless.)


Update (24 Oct. 2022):

After a new update the above solution didn't work anymore - but the opposite solution did: echo s2idle | sudo tee -a /sys/power/mem_sleep, which amounts to doing the contrary to what my sources prompted me to do.

That seemed bizarre to me at that moment, but now I understand that in fact this was the expected behavior all along: what happened before was odd and buggy, and the new update had fixed that; s2idle is supposed to proved the quick wake up.

After updating to the "normal" 22.10 release, the problem seemed fixed for a while, while the file /sys/power/mem_sleep looked reset to deep. But the 20-sec wake-up delay problem re-appeared, and was fixed as said above under Update 2. Again confirmed after a clean installation of Kubuntu 22.10: after tolerating the problem for a month (just to see if this might be fixed otherwise), the first command didn't help, the second did (February 2023).


Because this problem continues (e.g. in 23.04 - and reappears rather frequently between updates) I have set up a more rapid procedure to run that command from the Application Launcher creating a script file fix_suspend of the form:

#!/bin/sh
echo s2idle | sudo tee -a /sys/power/mem_sleep

and a file ~/.local/share/applications/Fix suspend.desktop containing the line (adapted for Plasma):

Exec=pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY KDE_SESSION_VERSION=5 KDE_FULL_SESSION=true /path/to/fix_suspend

After a while the solution stopped working after reboot, so I had to make the script run at reboot as indicated in the short answer at the beginning.

cipricus
  • 3,444
  • 2
  • 34
  • 85