Live data from Hacker News

I helped fix sleep-wake hangs on Linux with AMD GPUs

nyanpasu64.gitlab.io

151–160 of 218 posts

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#151
I have a problem similar to what OP faced but with an NVIDIA GPU (RTX 4080). When I wake the computer from suspend, the computer will usually wake up, show me the timestamp changing on the lock screen. But sometimes randomly, the timestamp will not change the the screen will freeze on the old timestamp. After this, it is either REISUB or hard reset.

@nyanpasu64, do you think enabling nvidia-suspend/nvidia-resume services will do the trick? I didn't go through the codefix in the above post in detail, but it looks like the fix is to raise a relevant notification to all listeners in the suspend_prepare() method for amdgpus, not nvidia.

Running Ubuntu 24.10.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#152
post #3

> Through some digging, I found that when a desktop enters S3 sleep, the system cuts power to PCIe GPUs I am not sure how correct this assumption is. S3 is supposed to cut power to everything but RAM, but for example Gigabyte Aorus motherboards are notorious for an NVMe SSD sleep bug that randomly prevents the system from properly sleeping or waking. This is fixed by adding the following udev rule: # Generic PCIe fix…

sigh, I have been struggling with this issue for a while, but this did not seem to work either. I have documented it here: https://bbs.archlinux.org/viewtopic.php?id=302440 Any further insight you might have on these Aorus wakeup issues? In particular, it seems the wakeup in my case is coming from `.../devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:45/wakeup/wakeup6` which does not really mean anything to me.

I had this issue and this MB for years I eventually solved it by physically removing a crappy USB C PCIE card I'd bought because my case didn't have any USBC ports.

(Additionally I also previously disabled PCI wakeup buses and haven't touched it again since it's working)

hope that info helps.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#153
post #14

I have an Nvidia GPU and a sporadic crash (black screen) with no logs on Linux. I suspect it's a driver issue too. Going to try some of these tips to enable the debug shell, but I'm not sure if they'll be effective. Anyone have other tips for this type of thing? I did try upgrading drivers/kernels already

Run a memtest. Graphics cards usually crash badly when given invalid data, which can happen sporadically if you have bad RAM. If memtest shows a specific memory region as failing, swap out sticks to check which it is, and buy a new one. (Or if you're on a tight budget, you can disable that region with kernel boot options.) If memtest gives errors in lots of places, might be a bad overclock. Loosen timings or give it…

Thanks, I'll try it!

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#154

I have an Nvidia GPU and a sporadic crash (black screen) with no logs on Linux. I suspect it's a driver issue too. Going to try some of these tips to enable the debug shell, but I'm not sure if they'll be effective. Anyone have other tips for this type of thing? I did try upgrading drivers/kernels already

Does `sudo systemctl enable nvidia-suspend` help?

Hey, great article :)

I'll try it.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#155

Earlier quoted context omitted.

I mean I totally get it. At the end of the day I have a billion tabs open and 14 instances of notepad. But after getting burned by sleep failing enough times, you gotta change your habits.

Firefox preserves opened tabs on close/re-open, and so does Notepad++/Sublime (and for those, it works even for tabs you've never saved as files). And let's be honest, losing most of those browser is inconsequential. So while I get the "I just want sleep to work, dangit" attitude (it really should just work, to be honest) the fact is that it barely does work. Seriously, it took this long to realize that VRAM contents…

That won't restore my 3+ neovim instances, including loaded buffers, associated undo trees, tabs, and splits. Neither will it restore the various PDFs I have open, the file browser instances pointed at specific locations, nor the containing window and desktop layouts for all of that.

It's pretty unbelievable when you think about it. The majority of mainstream progress on application state management has taken place in mobile operating systems and essentially amounts to the expectation that you won't lose data if and when your process is unexpectedly forced to terminate without user interaction. Forget actually picking up exactly where you left off.

And as long as I'm complaining. All of my sshfs mounts tend to break if I sleep-wake as well. Remounting them generally doesn't fix programs that were using them (for obvious reasons) - I usually have to manually close and reopen all of that.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#156
post #3

> Through some digging, I found that when a desktop enters S3 sleep, the system cuts power to PCIe GPUs I am not sure how correct this assumption is. S3 is supposed to cut power to everything but RAM, but for example Gigabyte Aorus motherboards are notorious for an NVMe SSD sleep bug that randomly prevents the system from properly sleeping or waking. This is fixed by adding the following udev rule: # Generic PCIe fix…

Are these fixes, or workarounds?

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#157

Earlier quoted context omitted.

Even Apple struggled to get it working perfectly in my experience across several models in the PPC/x86 era. Yes they are better(-ish) but when I had Apple laptops I'd still see weird sleep/wake issues in around 1 in every ~50 sleep/wake cycles. I also had one Apple laptop which had its battery going from 100% to 0% overnight during sleep requiring a cold start in the morning on a regular basis despite it being put to…

Even now on ARM it's not perfect. my M1 Mini will wake from sleep to a greenscreen and then crash/reboot ~once every few months, irrespective of uptime. My work mac (M1 Pro) occasionally locks up and reboots when waking from sleep too, at about the same frequency. Always wondered why this was such a difficult problem to solve, seemingly irrespective of operating system. (Linux has never been acceptable or reliable in…

I've never had an issue with wake/sleep on any of my M1/2/4 devices. The only issue I can ever recall with sleep was the 2019 16" Intel (which had a host of issues).

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#158

I have a problem similar to what OP faced but with an NVIDIA GPU (RTX 4080). When I wake the computer from suspend, the computer will usually wake up, show me the timestamp changing on the lock screen. But sometimes randomly, the timestamp will not change the the screen will freeze on the old timestamp. After this, it is either REISUB or hard reset. @nyanpasu64, do you think enabling nvidia-suspend/nvidia-resume serv…

I have encountered this running Ubuntu with an nvidia gpu. Have you tried adding button.lid_init_state=open as a kernel boot parameter? That is what solved it for me.

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#159

Props to you for this. I am not clever/experienced enough to solve my own issues with sleep-wake hangs on Linux at work. I’ve instead opted to work around it. I use Firefox, Obsidian, and Tmux with Neovim for all my work. Tmux has resurrect and a plugin that saves my entire terminal state automatically every few minutes. I also have a command that automatically sets up my i3wm/regolith windows exactly how I like. Bas…

Could you link to your i3wm/regolith window setup code? I'd like to set up something similar!

Re: I helped fix sleep-wake hangs on Linux with AMD GPUs

#160
post #77

Earlier quoted context omitted.

I’ve had good luck containing ooms with cgroups. I’m not sure if there is a state of the art for handling oom conditions beyond what Linux does. If anyone knows and can recommend some reading I would appreciate it.

There's really two problems as I understand it: - Overcommit. Linux will "overcommit" memory: allocations will succeed when there's no memory, and then hang when the page is actually mapped if no physical pages are available (to my understanding.) Windows NT doesn't do this. Not sure exactly how macOS/XNU handles it. - The OOM killer. Because allocations don't fail, to actually recover from an OOM situation the kerne…

> two problems ... overcommit

Is there any other sensible way to do this though? It would be quite inefficient to constantly call mmap for additional small(ish) pieces of memory. In effect overcommit just means that until the page is actually written to it hasn't really been allocated. (Aside: I believe a malloc implementation that zero'd out blocks on allocation would fail abruptly rather than later in case that happens to be what bugs you about it.)

Additionally how do you suppose fork should be implemented efficiently? Currently it performs copy-on-write. At minimum you'd need a way to mark pages as "never going to write to these, don't reserve space for a copy". Except such an API is either very awkward to use in practice or else leaves you with some very awkward edge cases to deal with in your program logic.

> You can disable overcommit, but some software will not function very well

Yeah about that.

Chromium runs (AFAIK) 1 PID namespace per tab. On my machine right now it reports 1.1 TiB virtual memory with a little over 100 MiB resident per tab. 1.1 TiB mapped PER TAB. Of the resident I have no idea how much is actually unique (ie written to following the initial fork).

Firefox is much more reasonable at a mere 18 GiB mapped per PID.

Post reply on HN