r4m0n/ZenStates-Linux

zenstates.py fails when msr module is built into kernel

spyder0080 opened this issue · 15 comments

Hello,
My current setup is Fedora 28 x64 running kernel 4.18.11-200. My machine is a HP Envy x360 running Ryzen 5 2500U APU. In Fedora at least, the msr module is built into the kernel. I ran the following:

cat /boot/config-$(uname -r) | grep CONFIG_X86_MSR

and the following result came up:

CONFIG_X86_MSR=y

Which means that the msr module is built in. Running zenstates.py --c6-disable fails with the following output:
File "./zenstates.py", line 112, in
writemsr(0xC0010292, readmsr(0xC0010292) & ~(1 << 32))
File "./zenstates.py", line 23, in writemsr
raise OSError("msr module not loaded (run modprobe msr)")
OSError: msr module not loaded (run modprobe msr)

Maybe you can add the above check as well?

The same error happens if Secure boot is on or off.

The script does not check for the MSR module, just for the device and access to it. Are you running the script as root?

Yes, I was running it as root. Attached is a screenshot
zenstates_msr_error

That error implies that the script cannot open the /dev/cpu/[0-9]*/msr device. Can you check if these exist?

If they don't exist your MSR module is not being loaded properly.

They do exist

dev_cpu

Try changing [0-9]* to %d if you have less than 10 cores.
That got it to run for me (Ryzen 2500U [8 cores]), although I'm still having issues actually disabling the c6 state.

@AD-Wright can you show me what you mean?

ghtux commented

Ryzen 1700x with 8 cores here. You must load msr first! Manual sudo modprobe msr.

For automatic loading of module insert in modprobe conf.
Have a look here:
https://forum.manjaro.org/t/amd-ryzen-problems-and-fixes/55533

@spyder0080 - so really the change I mention makes it so the command to disable c6 executes, but it doesn't actually do anything. So that's not a fix.
@ghtux - with modprobe not loaded, can you still read the p-states (zenstates.py -l)? That works fine on my system, and lsmod | grep msr returns the msr module. It seems that there is an issue with writing to the registers. Perhaps changing the registers is not possible on mobile processors. (2500U) The folders for the processors exist, and have msr files inside, and reading seems to go fine, but writing errors out.

Duplicate of #6.

Just as an update, I was able to successfully run python zenstates.py --c6-disable as root using the latest version of the script. My C6 state is now disabled. You can close this issue.

FYI I am running kernel 5.1.7 on Fedora 30.

@spyder0080 Hey dude, i have a Ryzen 5 2500U and i have followed this repo https://github.com/jfredrickson/disable-c6 but it says that the msr module is not loaded but indeed it is! Same problem as you had, but you said that you were successfully:

Just as an update, I was able to successfully run python zenstates.py --c6-disable as root using the latest version of the script. My C6 state is now disabled. You can close this issue.

But in my case it stil says that the msr module cant be found... What is so special with Ryzen 2500U?

@spyder0080 Hey dude, i have a Ryzen 5 2500U and i have followed this repo https://github.com/jfredrickson/disable-c6 but it says that the msr module is not loaded but indeed it is! Same problem as you had, but you said that you were successfully:

Just as an update, I was able to successfully run python zenstates.py --c6-disable as root using the latest version of the script. My C6 state is now disabled. You can close this issue.

But in my case it stil says that the msr module cant be found... What is so special with Ryzen 2500U?

Hello @angelhodar ,

I have not ran the script from the repo that you mentioned ( https://github.com/jfredrickson/disable-c6), but I did run the script from this repo. I downloaded the latest version and ran it again successfully.

For me the issue was that I didn't run as root.