Skip to content

Some other stuff I've found about Ryzen CPUs

So, I've been poking around with my Ryzen 5 3500U CPU a bit more, and I've discovered that Linux appears to have relatively poor integration with Ryzen CPUs. The native cpupower application and cpufreq drivers (acpi-cpufreq) are not able to accurately ascertain the C states, boost states, core performance boost functionality, and cpu frequency. I can't exactly figure out why.

This isn't just the case with cpupower. Another (highly useful, 10/10 would recommend) application for monitoring and tweaking CPU performance, Corefreq, to look at my CPU. It is able to correctly read processor frequency, and detect the presence of various technologies, including core performance boost. But, it is not able to utilise its cpufreq and cpuidle driver settings, in a similar matter to the cpufreq drivers (acpi-cpufreq).

I've also come to the conclusion that the current amdgpu driver has a degree of instability. occasionally when starting up, my CPU (with integrated GPU) will run very hot, and then when shutting down, display an error reading "Failed to write reg XXXX wait reg XXXX" (where X designates a character), and then fail to terminate some processes, and even enter kernel panic. All these problems clear up upon rebooting, and there is no apparent rhyme or reason for these errors occurring.

if you have anything to say about these two above issues, or know anything about them, or whatever, please tell me.

An issue with the AUR: The AUR lists the current version of Corefreq as 1.72, but github lists it as 1.71. Whenever I try to build the dkms corefreqk module, it fails because it can't find the appropriate file (corefreqk_1.71) in the appropriate directory. When checking that directory, there is a file called "corefreqk_1.72" (lining up with an AUR version). I think this mismatch is a problem with the mismatch in Corefreq versions between the build files, and package label. If theres a way to fix this, or my stuffs all wrong, please tell me.

Finally, an update on my earlier post: I haven't received any news regarding my bug. If there's a way to bring more attention to it, I'd like to know how.

52 points29 comments
Open on Reddit
About this post
Posted
Archived
Score
52 · 100% up
Kind
Text
ID
em1mlb

Author

3
posts
16
comments
0
media
View profile

30 comments

EDIT: I made a big mistake in this post here: I was using the alternative kernel "linux-ck" instead of the normal Arch kernel. Everything I report here is actually running fine when using the normal kernel. There's a bug in linux-ck that breaks the 'schedutil' frequency governor.


Here's the situation I see on a Ryzen 7 2700X desktop CPU, and same as you, I also see the same problem in the acpi-cpufreq driver:

When I use "schedutil" as the frequency governor, it seems that it does absolutely nothing. It behaves exactly like "performance" and just keeps the CPU stuck in the P0 P-state. Looking at sudo watch -n.5 cpupower frequency-info, it never switches to the P1 and P2 states it has available.

I looked at sudo turbostat next, and it also always reports the P0 state MHz number in the "TSC_MHz" column, no matter how low the CPU load is. From what I understood, the turbostat program gets its data by reading MSR registers of the CPU so it should know what's really happening on the CPU. Its output should be comparable to that "corefreq" tool you found.

With my motherboard here, I can get a reading of the Vcore voltage of the VRM in the output of sensors. It uses a pretty high Vcore voltage basically all the time. This would again be a sign that the CPU is never leaving P0 state.

About the boost speeds, I don't see anything about that through cpupower but the CPU definitely boosts correctly. I can see it running faster than its base clock in turbostat when I put some constant load on it. Are the boost speeds supposed to show up in cpupower's output? The boost on Zen+ CPUs isn't a set of fixed values like with Intel, so I guess it could be normal that it doesn't show up anywhere. At least with the 2700X there's pretty fine-grained changes to the speed happening with different temperature and power usage, and the exact result also seem to be a bit unique to each CPU.

About the frequency governor problem, I guess the situation here for me still ends up fine because the CPU's own power saving at idle behavior seems to work correctly. In turbostat's output I get something like 0.1 Watt recorded for cores that aren't in use and something like 3.0 Watt for one or two of the cores while I'm typing this here. Thinking about this some more, the problem will perhaps show up more on the outside of the CPU: because of the fixed P0-state, the board's VRM will be set to supply a high voltage all the time, and maybe that's where heat and power will get lost unnecessarily.

7 points

The boost on Zen+ CPUs isn't a set of fixed values like with Intel

It isn't? I've seen alot of documentation to the counter, but if so, that's awesome! Intel speedstep was suppose to implement a similar thing. Speedstep also requires a special driver for cpufreq, so maybe something similar will be needed for Zen+. Overall, my experience is similar to yours.

1 points

From what I understood, that "SpeedStep" thing is about the P-states and about the OS being able to limit the speed. I'm imagining the rules that the OS is supposed to use are something like: "if there's no core that's at more than 20% usage, reduce speed".

SpeedStep is basically the fancy name for the different P-states, and is what the acpi-cpufreq driver is for.

Boost is about what the hardware is doing in P0. Instead of using its fixed base clock, it has rules about how to run at different, higher speeds. The CPU does that by itself.

On the Intel CPUs I've seen, the rules were kind of simple. There is one speed value for number of cores that are in use. For example with a quad-core, it would be something like this:

  • 1 core running + 3 cores asleep = use 38 * 100 MHz
  • 2 cores running + 2 cores asleep = use 37 * 100 MHz
  • 3 cores running + 1 core asleep = use 35 * 100 MHz
  • 4 cores running + no core asleep = use 35 * 100 MHz

It's always trying to use those same speed factors, no matter what kind of load it is.

Then there are some additional rules that are added on top. There's a limit for power usage and temperature, if that gets hit it drops down to its base clock. On the newer Intel CPUs, they get very hot if software uses "AVX" instructions. Those CPUs then introduced an offset for AVX that gets subtracted from the speed factor.

On my R7 2700X, it appears there's not really any fixed value it tries to hit. It can change speed in 25 MHz steps, and it looks out for a set of limits that it isn't allowed to go over. The limits are about voltages and temperatures.

What's interesting is that the cooling will change what speed it uses. This happens even if it's still a good bit away from where its thermal limit is. While experimenting in Windows, I could see that power usage for the same stress test is changing with rising temperatures, and that can then make it change speed because of its current and power limits instead of the thermal limit.

2 points
unknown author

Deleted before we saved it.

1 points

Last time I gave a look into the AMD specs, the C-States MSR registers, if those exist in the Zen architecture, were still not published. However, looking at the frequency driver for Linux, source code reveals that idle states, probably ratios, are used from ACPI memory table(s)

The standard Target P-State exists if you will to lower and maintain the Frequency FID; perhaps the voltage VID. You may have to unload or blacklist the cpufreq driver to keep your MSR value persistent.

I also left as experimental the ability to write the P0, P1, P2 MSR. In CoreFreq UI, go to the Settings menu to enable the Experimental mode, next in the Processor window, open the frequencies selector, facing the Max item.

Feel free to fill me a GitHub issue if you want we progress on the 3200U https://github.com/cyring/CoreFreq/issues

CyrIng

3 points

Woah. Didn't expect to get attention from the top.

First of, thanks for making corefreq. Its a really good tool, and hopefully will someday replace the lame cpupower mechanic that comes with arch. If you'd like any information on my Ryzen 3500U that can help you expand support to AMD, I'll do my best to provide it.

Also, just so you know, I'm currently unable to compile the dkms kernel module for the latest version of your application. The reasons I think this is the case are listed above, but I figured I'd let you know, just in case.

I'm total fanboy of both Arch Linux and AMD. It's a shame that there seems to be so little attention to AMD + Linux in general. Is there anyway we can get AMD to give your project a little attention?

1 points

DKMS package fixed. Thank you for letting me know.

I had posted into the AMD community forum but no word from them.
Ryzen Master probably.

I'm progressing on this Architecture through the help of beta testers who impact experimental code directly into the sources and then provide me outputs, screenshots and debug values.

Recently I have updated the Zen CPUID references. Among them is the "AMD Ryzen 5 3500U" which should be decoded as the PINNACLE RIDGE architecture revision.
AMD says that this is a locked processor: if you notice it is in fact unlocked ? we will have to change lines of CoreFreq code to unleash the P-State change.

Working from sources means:

1- Clone CoreFreq from the GitHub
git clone https://github.com/cyring/CoreFreq.git

2- Build straight from this working directory
cd CoreFreq && make clean all

3- Start as root the Driver and the Daemon, explicitly from this directory
su
insmod corefreqk.ko
./corefreqd -d

4- Open another Terminal, go back to the working directory then start as a standard user the Client
./corefreq-cli

Editing the source code will involve to:

1- Stop CoreFreq in that order
a- stop the Client [CTRL]+[x] or [CTRL]+[c]
b- stop the Daemon [CTRL]+[c]
c- unload the Driver
rmmod corefreqk.ko

2- Change the source code through my instructions (provided in a GitHub issue)

3- Fully rebuild CoreFreq
make clean all

4- Save your files; flush your FS in case of a crash into Driver:
sync

5- Start CoreFreq, Test, and make screenshot of results

To avoid confusion between versions, it will be better to uninstall the AUR corefreq-git package from your system, then run CoreFreq from the working directory

At any time, you'll be able to update from the GitHub repo with:
make clean
git pull

Regards
CyrIng

1 points

I can relate: with my AMD 2600 CPU I had sudden shutdowns, which were solved by disabling the CSTATE option in the bios setup of my motherboard (an MSI B250M MORTAR)

3 points

I had a similar issue (would hard lock up) and the same solution solved it.

1 points

Ryzen 3600, I have freezes constantly that I need to shutdown the PC(3 seconds power button) because I can't do anything after. Journalctl doesn't appear nothing after. When I shutdown the pc normally a lot of errors appears.

1 points

Try disabling the C-STATE option in the bios setup

1 points

Hello, thanks for your suggestion. I have been having this problems from months I already try that and a lot of things too, nothing works, soon or later it freezes.

1 points

I have the same processor laying on the desk just waiting to be installed. Are these problems common? Should I expect abnormalities and take some precausions?

1 points

To be honest, I don't know if is my RAM(DDR4-3733MHz), motherboard(ATX MSI X570-A Pro), NVIDIA or the CPU(Ryzen 3600), I started using a NVME instead of SSD too. The freeze are constants so I can't even use the PC. From time to time I play in it just to see if the freezes are gone. I have run memtest and no problem was found and have put it on stress too, and not freeze happen during does.

I have read people that had problems like mine just changed the motherboard and all was good.

Before I had the Ryzen 1600, B350 Motherboard and RAM 3000MHz I didn't have a single problem.

Other than the freezes I didn't have any problems like data corruption or anything like that if thats what you are asking.

I have tried to use in Windows too and what happens is blue screens, I had 3 different types of errors.

2 points

update on AMDGPU situation. There may be something wierd with the amdgpu driver. got this in bootup:

amdgpu 0000:03:00.0: [drm:amdgpu_ib_ring_tests [amdgpu]] *ERROR* IB test failed on comp_1.2.1 (-110).

Apparently, this isn't the first time this error has plagued users. happened as well for earlier kernels. might want to look for a patch.

1 points

Like this?

1 points

Maybe? I get recursive fault errors sometimes when I try to shutdown after booting into an environment affected by this bug. I don't know enough about to see what could be the big issue. For a while, I thought that maybe I had accidentally damaged my hardware in some small way. Its somewhat comforting to know that others are dealing with this problem.

1 points

Thanks for doing this investigation. I have a Thinkpad x395 with the same CPU and I have the same problem with amdgpu. After starting X, the system is so slow it is unusable. Sometimes I am able to drop to a TTY and do a reboot, but it will often kernel panic or halt completely, and then I have to do a hard reset. When I can do a soft reboot I get the same "Failed to write reg XXXX wait reg XXXX" messages.

This only happens intermittently. Many times it will boot normally and run fine.

My system is also unable to wake from suspend, which I think is the same as this bug.

1 points

With the exception of the 'suspend' bug, you're describing my situation exactly. These bugs are really starting to get on my nerves. I've had to reboot up to 9 time in a row.

1 points

I saw those "failed to write reg XXX ..." on my 3750h, but only occured when I was using a ck kernel, and every process got strangely slow, adding "iommu=soft" to kernel boot cmd line made that message disappear .

1 points

I have similar problems with the Ryzen 5 2500U in my notebook.

1 points

I made a terrible mistake in my earlier post. I was using an alternative kernel named "linux-ck" when I was experimenting. That was causing the acpi-cpufreq the problems I reported. With the normal Arch kernel everything behaves fine.

That "linux-ck" kernel is using a different task scheduler "MuQSS" from https://ck-hack.blogspot.com/. The acpi-cpufreq's "schedutil" governor seems to be completely broken in it and behaves like "performance".

With the normal Linux task scheduler, "schedutil" does fine. When I do boring stuff like typing here and have watch -n.5 sudo cpupower frequency-info open in another window, I can see it uses P1 and P2 states most of the time. The Vcore voltage that this board here can report in sensors does drop as well to 0.8V. That low voltage should mean that the P-state is actually changing in the hardware.

I also noticed I can watch something on Youtube in Firefox with schedutil keeping the CPU in P2 state. That's perhaps interesting because Firefox has no video decode GPU acceleration in Linux so the CPU is doing the decoding. The video stream I looked at was 1080p 60fps.

That sudo turbostat output I tried to use earlier, I made another mistake there. I had thought that the "TSC_MHz" column would change with different P-states but that's not the case. It always stays at the 3700MHz base clock of the 2700X CPU.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.