TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Linux's Bedtime Routine

206 pointsby JNRowe8 months ago

4 comments

nyanpasu648 months ago
I&#x27;ve done some digging in Linux power management a while ago, while debugging a (not-fully-fixed) Linux AMDGPU dGPU crash on low memory (<a href="https:&#x2F;&#x2F;gitlab.freedesktop.org&#x2F;drm&#x2F;amd&#x2F;-&#x2F;issues&#x2F;2362" rel="nofollow">https:&#x2F;&#x2F;gitlab.freedesktop.org&#x2F;drm&#x2F;amd&#x2F;-&#x2F;issues&#x2F;2362</a>). Along the way, I discovered that you can hibernate <i>both</i> through &#x2F;sys&#x2F;power&#x2F;disk, and the userland snapshot&#x2F;hibernate&#x2F;suspend interface (<a href="https:&#x2F;&#x2F;docs.kernel.org&#x2F;power&#x2F;userland-swsusp.html" rel="nofollow">https:&#x2F;&#x2F;docs.kernel.org&#x2F;power&#x2F;userland-swsusp.html</a>, snapshot_ioctl()). IIRC these two mechanisms go along quite different codepaths internally.<p>The specific crash bug I encountered was because Linux calls pm_restrict_gfp_mask() to prevent swapping to disk, <i>before</i> dpm_prepare() (the first opportunity for a GPU driver to backup VRAM to system RAM before the PCIe GPU is shut down and VRAM is lost). So if you don&#x27;t have enough free system RAM to hold all VRAM, the sleep is aborted midway through (waking the system) or produces a failed memory allocation later during sleep or resume (often resulting in undefined system state, halted network or USB controllers, or worst yet a halted NVMe controller resulting in the system running around like a headless chicken unable to load data from disk or <i>even log data to the journal</i>). I&#x27;m wondering if this was a deliberate decision or an unforeseen interaction between suspend-time GFP masks and GPU drivers.<p>It seems Nvidia can&#x27;t reliably backup VRAM either without being informed by systemd prior to the kernel initiating suspend (<a href="https:&#x2F;&#x2F;download.nvidia.com&#x2F;XFree86&#x2F;Linux-x86_64&#x2F;560.35.03&#x2F;README&#x2F;powermanagement.html" rel="nofollow">https:&#x2F;&#x2F;download.nvidia.com&#x2F;XFree86&#x2F;Linux-x86_64&#x2F;560.35.03&#x2F;R...</a>).
评论 #41486256 未加载
amelius8 months ago
I suspend my Linux box every night. However, I notice that after some 30-50 times the machine freezes at a random point when using the machine (even the num-lock led stops working). Curious if others have the same experience, and if it&#x27;s Linux-related or a problem of my particular hardware.
评论 #41490468 未加载
评论 #41487695 未加载
评论 #41505681 未加载
评论 #41490222 未加载
heavyset_go8 months ago
This is a great write up that goes deeper than I expected it to. Glad to have seen it.
pino828 months ago
I just read the first few lines so far. They play around a lot with strings, compared to the fact that it&#x27;s not about word processing but power management.<p>I&#x27;m not a developer on this system level of things. When you usually try to write &#x27;nice&#x27; code, you are somewhat surprised about concerns like &quot;convert the last space to a newline&quot; there.<p>Yes, I know, everything is a file, and this is just the other side of this odd ancient paradigm.<p>To me it looks tedious. But, well, could be that this is just for me, because I&#x27;m not used to it. Maybe it&#x27;s not a problem at all once you are deeper inside it.<p>But even from a logical perspective, it is funny: There is a file that contains all available sleep modes. Once you write a particular one into the same file (let&#x27;s say you open it in a text editor and remove all states but one and then save), the system goes into that sleep mode.<p>Yes, I know, operating systems are different from a tiny web service in Python (and even there you start tricking around with weird http concepts instead)... It was just an observation.
评论 #41485158 未加载
评论 #41488394 未加载
评论 #41485140 未加载
评论 #41487036 未加载