我如何才能更好地了解我的笔记本电脑所处的睡眠状态?

我如何才能更好地了解我的笔记本电脑所处的睡眠状态?

我知道理论上有很多种睡眠状态,但无论出于什么原因,大多数睡眠状态在特定的笔记本电脑上不起作用或不可用。

我的笔记本电脑设置为混合睡眠模式;即挂起 2 小时,然后休眠。效果很好。有时它能正常工作。但有时它不起作用;电池会完全耗尽。

我不太清楚内核日志中哪些内容表示睡眠状态成功。我该如何找到答案?我怀疑我的笔记本电脑没有正确执行“挂起到内存”,而是只执行“待机”

我很难在配置文件之间(见下文)翻译正在使用的单词,这篇关于 ACPI 的维基百科文章和内核日志。

  • freeze我认为这是 S0 睡眠,Suspend-To-Idle,s2idle
  • standby我认为这是 S1 睡眠,又称浅睡眠,开机挂起?
  • mem思考这是指 S3 睡眠,又称深度休眠到 RAM
  • hibernate我很确定这是 S4 睡眠、挂起到磁盘/休眠状态。

我的配置

/etc/systemd/logind.conf有:

[Login]
HandleSuspendKey=suspend-then-hibernate                                                                                                                                                                                                                 
HandleLidSwitch=suspend-then-hibernate
HandleLidSwitchExternalPower=suspend-then-hibernate

并且/etc/systemd/sleep.conf

[Sleep]
HibernateDelaySec=120min
SuspendMode=suspend
SuspendState=mem standby freeze

内存,我相信应该是好的 - 暂停到 RAM,S3。

/etc/UPower/UPower.conf有:

CriticalPowerAction=HybridSleep

/etc/default/acpi-support有很多关于hibernate的评论:

# Comment the next line to disable ACPI suspend to RAM
ACPI_SLEEP=true

# Comment the next line to disable suspend to disk
ACPI_HIBERNATE=true

# Change the following to "standby" to use ACPI S1 sleep, rather than S3.
# This will save less power, but may work on more machines
ACPI_SLEEP_MODE=mem

...

# If you specify dbus or pm-utils, the result will normally be the same as when
# you suspend from your desktop environment. If you specify "hibernate" or
# "acpi-support", be aware that this probably does not match what your desktop
# environment would do (unless you have managed to configure something so that
# the DBUS power management interfaces call the hibernate package).
#
#
# Please specify a space separated list of options. The recommended value is
# "dbus pm-utils"
#
SUSPEND_METHODS="dbus-pm dbus-hal pm-utils"


# Set the following to "platform" if you want to use ACPI to shut down
# your machine on hibernation
HIBERNATE_MODE=shutdown

我的系统日志

Jan 10 18:20:48 dove systemd[1]: Reached target Sleep.
Jan 10 18:20:48 dove systemd[1]: Starting Record successful boot for GRUB...
Jan 10 18:20:48 dove systemd[1]: Starting Suspend; Hibernate if not used for a period of time...
Jan 10 18:20:48 dove systemd[1]: grub-common.service: Deactivated successfully.
Jan 10 18:20:48 dove systemd[1]: Finished Record successful boot for GRUB.
Jan 10 18:20:48 dove systemd[1]: Starting GRUB failed boot detection...
Jan 10 18:20:48 dove kernel: [31933.640758] PM: suspend entry (s2idle)
Jan 10 18:20:48 dove systemd-sleep[102558]: Entering sleep state 'suspend'...
Jan 10 18:20:48 dove systemd[1]: grub-initrd-fallback.service: Deactivated successfully.
Jan 10 18:20:48 dove systemd[1]: Finished GRUB failed boot detection.
Jan 10 18:20:48 dove kernel: [31933.647185] Filesystems sync: 0.006 seconds
  • s2idle或者suspend-那么那是 ACPI S0 吗?(因为 s2idle 中的 2 是“to”的缩写,而不是 ACPI 状态中的“S2”?)如果是这样,为什么在将 S3 配置为首选项时它没有管理 S3?我希望得到一些关于为什么选择该状态的通知?
  • 为什么我在关机/睡眠时会出现“启动检测失败”的情况?
  • 我认为sync最后的结果很有意义——数据刷新到磁盘。

那么下一行必须是唤醒

Jan 10 18:21:43 dove kernel: [31933.780334] Freezing user space processes ... (elapsed 0.003 seconds) done.
Jan 10 18:21:43 dove kernel: [31933.784219] OOM killer disabled.
Jan 10 18:21:43 dove kernel: [31933.784221] Freezing remaining freezable tasks ... (elapsed 6.113 seconds) done.
Jan 10 18:21:43 dove kernel: [31939.898171] printk: Suspending console(s) (use no_console_suspend to debug)
Jan 10 18:21:43 dove kernel: [31940.839037] ACPI: EC: interrupt blocked
Jan 10 18:21:43 dove kernel: [31988.103447] ACPI: EC: interrupt unblocked
Jan 10 18:21:43 dove kernel: [31989.258313] OOM killer enabled.
Jan 10 18:21:43 dove kernel: [31989.258318] Restarting tasks ... 
Jan 10 18:21:43 dove kernel: [31989.267532] done.
Jan 10 18:21:43 dove kernel: [31989.267553] random: crng reseeded on system resumption
Jan 10 18:21:43 dove systemd-resolved[1561]: Clock change detected. Flushing caches.
Jan 10 18:21:43 dove rtkit-daemon[2366]: The canary thread is apparently starving. Taking action.
Jan 10 18:21:43 dove rtkit-daemon[2366]: Demoting known real-time threads.
...
Jan 10 18:21:43 dove rtkit-daemon[2366]: Demoted 4 threads.
Jan 10 18:21:43 dove kernel: [31989.292406] PM: suspend exit
  • 奇怪的是,它一开始就说“冻结剩余的可冻结任务”——这些任务肯定已经冻结了?与暂停终端相同。这些听起来应该发生在暂停而不是唤醒时?
  • 最后,suspend exit没有给出有关达到何种睡眠状态的线索。

问题澄清

我知道,为了提出我的问题,我必须提供很多细节,表达很多困惑,这可能会因为太模糊而导致投票失败。总结如下:

  • 我的笔记本电脑是否只能“实现” S0 状态(s2idle),而不能实现 S3 状态(deep/suspend-to-ram)?
  • 我该怎么做才能调查/配置它以实际使用 S3 状态?

除了这些关键问题之外,任何关于如何可靠地从日志中获取此信息的提示,或在无法睡眠的情况下要查找的内容,或对上述任何内容的解释都将有所帮助。


  • 2023 年 4 月 18 日编辑,添加以下信息内核文档- 感谢@MattNordhoff 提供链接。

答案1

了解设备进入睡眠状态的最佳方法是查看/sys/power并参考相关文档。例如,这些选项的作用如下所述https://www.kernel.org/doc/Documentation/power/states.txt

不幸的是,如果你有一个 nvidia 芯片组,事情就没那么简单了,尤其是使用 s2idle 的时候。

https://download.nvidia.com/XFree86/Linux-x86_64/495.44/README/powermanagement.html https://download.nvidia.com/XFree86/Linux-x86_64/495.44/README/dynamicpowermanagement.html

如果你正在与 Nvidia 的高功耗作斗争,那么我建议你从头开始,然后

  1. 添加至/etc/modprobe.d/nvidia.conf:
options nvidia NVreg_DynamicPowerManagement=0x02
options nvidia NVreg_EnableS0ixPowerManagement=1
  1. 在 /etc/systemd/sleep.conf 中:
SuspendState=freeze

(这个答案是为一个没有账户的朋友发布的。他们应该为事实付出代价,而我则要为任何错别字负责。)

相关内容