Skip to content

Instantly share code, notes, and snippets.

@bmaupin
Last active July 25, 2023 15:13
Show Gist options
  • Save bmaupin/3f194ab3220c95adf7de70fb3ba5d2cc to your computer and use it in GitHub Desktop.
Save bmaupin/3f194ab3220c95adf7de70fb3ba5d2cc to your computer and use it in GitHub Desktop.
Notes on laptop sleep

Summary

  • Older laptops support hardware (S3) sleep, which uses little to no battery power.
  • Newer laptops only support software (S0ix) sleep, which will gradually drain the battery over a period of a few days (although it can be less than a day in extreme cases).
  • If you have an older laptop (made before ~2020), your laptop may still support S3 sleep. See below for more information.
  • If your laptop doesn't support S3 sleep:
    • Limit usage of sleep to short periods of time; otherwise, power off instead.
    • Using the latest Linux kernel possible will provide benefits to sleep functionality as operating system support for S0ix sleep improves.
    • Power off your laptop before putting it in a bag; laptops in S0ix sleep can get hot and the fan can even turn on.

Check if your laptop supports S3 sleep

cat /var/log/kern.log* | grep ACPI | grep support

or

sudo dmesg | grep ACPI | grep support

Sample output for a laptop which does not support S3 sleep:

$ cat /var/log/kern.log* | grep ACPI | grep support
Jul 24 08:30:45 newer-laptop kernel: [    0.238436] ACPI: PM: (supports S0 S4 S5)

$ cat /sys/power/mem_sleep
[s2idle]

Sample output for a laptop which does support S3 sleep:

$ cat /var/log/kern.log* | grep ACPI | grep support
Jul 24 10:29:59 older-laptop kernel: [    0.293063] ACPI: PM: (supports S0 S3 S4 S5)

$ cat /sys/power/mem_sleep
[s2idle] deep

Enable S3 sleep

Source: https://askubuntu.com/a/1455363/18665

Temporarily enable S3 sleep:

  1. Confirm S3 sleep is supported but not enabled

    $ cat /sys/power/mem_sleep 
    [s2idle] deep
    
  2. Enable S3 sleep

    sudo sh -c "echo 'deep' > /sys/power/mem_sleep"
    
  3. Confirm S3 sleep is enabled

    $ cat /sys/power/mem_sleep 
    s2idle [deep]
    

Enable S3 sleep permanently:

  1. Edit /etc/default/grub

  2. Append mem_sleep_default=deep to the line starting with GRUB_CMDLINE_LINUX_DEFAULT, e.g.

    GRUB_CMDLINE_LINUX_DEFAULT="quiet splash mem_sleep_default=deep"
    
  3. Update Grub

    sudo update-grub
    
  4. Reboot

More information

Laptops used to have hardware (S3) suspend, which would use very little power.

Unfortunately, Microsoft wanted to be able to do things in the background during sleep (like install updates) and so they pushed for S0ix, which they call Modern Standby. As a result, modern laptop manufacturers (like Dell) have removed S3 sleep support altogether from the BIOS. It seems that S3 sleep has also been removed from Intel CPUs starting from the 11th generation (Tiger Lake); Intel's documentation indicates that it's still supported but this comment indicates otherwise.

The downside to S0ix is that because the system can do things in the background, this can use a lot more power than S3 and so the battery can drain very quickly. Additionally, since the CPU can be active this can generate heat, even causing the fan to turn on, which is problematic particularly if the laptop is in a bag.

Hibernate is another option, but it increases the wear of the disk (especially concerning for SSDs).

Thankfully S0ix behaviour and efficiency is gradually improving, although it still doesn't seem ideal.

Since modern laptops power off and boot up very quicly, it's probably best to use sleep only for short periods when the laptop isn't going to be put in a bag. Otherwise, powering off is probably the best option.

Notes

Suspend levels

Other options:

  • Hybrid sleep: The system saves contents of RAM to disk in case of power loss, and then sleeps. If no power loss occurs, the system can resume more quickly.
  • Suspend-then-hibernate: The system initially goes to sleep and after a certain time, it hibernates. This can help reduce disk wear in situations where sleep is only needed for a short period of time.

Sleep modes compared

  • S0ix sleep
    • Pros
      • Near instant resume (typically less than 1 second)
      • No need to store memory to disk
    • Cons
      • Can drain the battery very quickly in some cases
      • Parts of the system can wake up during S0ix sleep, causing the fan to turn on
  • S3 sleep
    • Pros
      • Very fast resume (typically a few seconds)
      • No need to store memory to disk
      • Little to no battery usage
    • Cons
      • Not all devices always behave properly after waking (e.g. wifi)
  • Hibernate
    • Pros
      • No battery usage; system is powered off with RAM contents saved to disk
    • Cons
      • Additional wear to disk, particularly for SSDs which often have a shorter lifespan
      • Can be slower to hibernate and resume

Manually patching BIOS to enable S3

Fix suspend issues on Dell 7405 2-in-1

References

Testing

S0ix sleep on Latitude 5420

Specs:

  • CPU: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
  • OS: Ubuntu 22.04.2
  • Kernel: 5.19.0-46
  • S3 sleep: not supported
  • Battery capacity (energy-full as reported by upower -i /org/freedesktop/UPower/devices/battery_BAT0): 41.5872 Wh

Steps:

  1. Powered on and logged in
    • Bluetooth enabled, power profile set to Balanced
    • Dropbox and Gnome system-monitor extension running in background (I'm not sure if this matters)
  2. Closed the lid for 12 hours

Results:

  • 14% battery loss in 12 hours
  • battery would last approximately 85 hours in S0ix sleep

S0ix sleep on Latitude 5400

Specs:

  • CPU: 8th Gen Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz
  • OS: Ubuntu 22.04.2
  • Kernel: 5.19.0-46
  • S3 sleep: supported
  • Battery capacity (energy-full as reported by upower -i /org/freedesktop/UPower/devices/battery_BAT0): 64.1136 Wh

Steps: same as above

Results:

  • 5% battery loss in 12 hours
  • battery would last approximately 240 hours in S0ix sleep
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment