Manjaro Freezes on AM4, C6 States and Idle

For my first couple of weeks on Manjaro, back at the start of 2022, I had a lot of freezes. While there are a lot of things that can cause freezes, on my specific hardware it was easy to track down the issue.

I found a post about it on the archived Manjaro forum, which no longer exists.
🪦 RIP archived manjaro forum

It appears to be isolated to the AM4 platform, specifically earlier generation AMD CPUs are affected.
Since then I already upgraded to a newer 5600X.

At the time I had the following system:

  • Ryzen 1600X
  • MSI PC Mate B350
  • GTX 1080

The Problem is that the linux kernel, under low CPU load, sends the CPU into a power saving state: C6. With Ryzen CPUs it was a gamble, whether it would or would not freeze the entire OS.

Symptoms

Most of the time, my system would freeze while I was away from my computer. This meant the system was most likely ideling, and wanted to go into a lower power state. Rarely would it freeze during use.

The lock ups would almost certainly happen every single day, or close to it.

When frozen, the system would not let me switch ttys, or execute a clean shutdown with REISUB. The Displays would show the last thing that happened.

Solution

  1. In BIOS/UEFI set Idle Current to Typical Idle Current
  2. Set a kernel boot parameter idle=nomwait
  3. Install a service to disable C6 states with Zenstates.py

1. Idle Current

In your BIOS or UEFI, there is an option called Power Supply Idle Control or similar. It is usually located in some of the CPU features or overclocking settings. Set it from auto or Low Idle Current to Typical Idle Current

2. Kernel Boot Parameter

Edit /etc/default/grub and add the idle=nomwait flag to your current list of parameters:

GRUB_CMDLINE_LINUX_DEFAULT="<current params> idle=nomwait"

Save the file and run sudo update-grub to re-generate the initramfs.

3. Zenstates.py

  1. Install zenstates-git from AUR
  2. The kernel module msr is needed for Zenstates. To load this module every boot, add msr to the file /etc/modules-load.d/modules.conf.
  3. To disable C6 states permanently, create a systemd unit.
  4. create a file in /etc/systemd/system/ called something like disable_c6.service.
  5. add the folowing contents to the file:
[Unit]
Description=Ryzen Disable C6
DefaultDependencies=no
After=sysinit.target local-fs.target
Before=basic.target

[Service]
Type=oneshot
ExecStart=/usr/bin/zenstates --c6-disable

[Install]
WantedBy=basic.target
  1. Run sudo systemctl enable disable_c6.service to enable the system.d unit.
  2. Reboot.
  3. Run lsmod | grep msr to check if msr has been loaded.
  4. Check if Zenstates has disabled C6: sudo zenstates -l:
roman@pc~: sudo zenstates -l
...
C6 State - Package - Disabled
C6 State - Core - Disabled

roman's lab

Technology and Engineering Blog


Experiencing freezes on linux with AMD hardware?

By Roman Hayn
7 March 2023

[~] ls
-r-x Linux
-r-x Manjaro
-r-x Ryzen