I'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://gitlab.freedesktop.org/drm/amd/-/issues/2362" rel="nofollow">https://gitlab.freedesktop.org/drm/amd/-/issues/2362</a>). Along the way, I discovered that you can hibernate <i>both</i> through /sys/power/disk, and the userland snapshot/hibernate/suspend interface (<a href="https://docs.kernel.org/power/userland-swsusp.html" rel="nofollow">https://docs.kernel.org/power/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'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'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't reliably backup VRAM either without being informed by systemd prior to the kernel initiating suspend (<a href="https://download.nvidia.com/XFree86/Linux-x86_64/560.35.03/README/powermanagement.html" rel="nofollow">https://download.nvidia.com/XFree86/Linux-x86_64/560.35.03/R...</a>).
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's Linux-related or a problem of my particular hardware.
I just read the first few lines so far. They play around a lot with strings, compared to the fact that it's not about word processing but power management.<p>I'm not a developer on this system level of things. When you usually try to write 'nice' code, you are somewhat surprised about concerns like "convert the last space to a newline" 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'm not used to it. Maybe it'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'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.