I had this problem before with Fedora 28: sudden system freeze whenever the CPU usage hit a certain threshold and usually very low threshold. It was very easily reproducible too: I just had to leave the system not doing anything for the night, and the next day I would not be able to move the mouse cursor anymore.
I made bios updates, carefully took notes about the kernel, and some other things too but to no avail. I made a change by switching to Ubuntu Bionic and the problem had since disappeared… well, until today. The thought that some kernel version caused the problem now cemented in my core belief.
In the process of figuring out what actually went wrong, I found a lot of mentions in quite a number of places where this was tightly related to the first generation Ryzen processors. I am currently running on the first generation R5 1400 Ryzen. The actual problem was related to the processor C6 power/sleep state.
There is a thread on the Manjaro Linux forum that describes the bug in a relatively easier language to understand. Also, the original thread poster posted a quick tutorial on how to fix the problem by activating a kernel module
msr and using a python script
zenstates.py to remedy the problem, which seemed to work for me on 2 separate tests that I did.
To attempt a fix at this, I tried using the
zenstates.py, which is available on GitHub. First, download it to somewhere, for example, the
cd ~/Downloads git clone https://github.com/r4m0n/ZenStates-Linux.git
Then, move the
zenstates.py to the location where binaries usually go, the
/usr/local/bin on most linux distributions.
sudo cp ZenStates-Linux/zenstates.py /usr/local/bin/
The next step is to enable
zenstates.py at startup, which means, letting the
systemd to manage it. The first thing that I did was to figure out where the usual location for
systemd unit files, and to do that, I used the
mlocate tool. I installed
docker in the past so I knew for sure there was a
systemd unit file for
mlocate .service | grep docker
Which returned me the following output:
mlocate is one of those useful tools that you should know how to use it and now we have the information where
systemd unit files should reside in.
Then, I proceeded with making a new file called
ryzen-c6.service inside the
/lib/systemd/system/ directory with the following content:
[Unit] Description=Disable C6 power state on Ryzen CPUs DefaultDependencies=no After=sysinit.target local-fs.target Before=basic.target [Service] Type=oneshot ExecStart=/usr/local/bin/zenstates.py --c6-disable [Install] WantedBy=basic.target
Then, I enabled this service by invoking this command:
sudo systemctl enable ryzen-c6.service
Looks like by enabling the service (at boot) and not starting it like normal daemon fixes the issue. I rebooted my machine, opened a tab on Firefox, let it sit idle for > 3 hours, and no lockup happened (yet). I will report if lockup happened in the future.