FS#69817 - [linux] /proc/cpuinfo misreporting frequency

Attached to Project: Arch Linux
Opened by Daniel (weker01) - Saturday, 27 February 2021, 19:37 GMT
Last edited by Jan Alexander Steffens (heftig) - Tuesday, 09 March 2021, 22:21 GMT
Task Type Bug Report
Category Kernel
Status Closed
Assigned To Jan Alexander Steffens (heftig)
Architecture x86_64
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

Description:
I sometimes monitor my cpu freqs of my Ryzen 9 3900X with:

`watch -n0.4 'grep MHz /proc/cpuinfo | sort -nr'`

After the 5.11.1 kernel update I compiled something large and was bored so went and looked at what my cpu was doing. To my suprise it magically boosted to 6078 MHz with one core!
While all other cores where @ 2200 MHz without moving....

This can't be right normally my cpu only boosted to 4.5 GHz max and only for a few ms....

I think it maybe is related to the new [Frequency Invariance Support](https://www.phoronix.com/scan.php?page=news_item&px=AMD-Freq-Invariance-Linux-5.11)?

I created a [reddit thread](https://www.reddit.com/r/archlinux/comments/lrnyki/proccpuinfo_reporting_bogus_frequencies_on_zen2/) where this bug was also confirmed for zen3 cpus and someone that reported that gentoo linux 5.11.1 doesn't have this problem.

It is worth mentioning that changing the cpufreq scaling_governor does not fix the misreporting as setting:
`echo performance > /sys/devices/system/cpu/cpufreq/policy*/scaling_governor`
leads to multiple cores going >5GHz.

Attached you will find a cpuinfo snapshot with cpufreq scaling_governor performance that exhibits this behavior.


Additional info:
* package version(s):
linux 5.11.1.arch1-1
linux 5.11.2.arch1-1


Steps to reproduce:
Execute `watch -n0.4 'grep MHz /proc/cpuinfo | sort -nr'` and observe extreme overclocking frequencies.
   cpuinfo (35.4 KiB)
This task depends upon

Closed by  Jan Alexander Steffens (heftig)
Tuesday, 09 March 2021, 22:21 GMT
Reason for closing:  Fixed
Additional comments about closing:  linux 5.11.3.arch1-1
Comment by loqs (loqs) - Saturday, 27 February 2021, 20:31 GMT
Have you tried applying [1]? Your symptoms do not match but it does fix a bug in the same subsystem so it might have an effect.
Edit:
Upstream bug report [2].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=538b0188da4653b9f4511a114f014354fb6fb7a5
[2] https://bugzilla.kernel.org/show_bug.cgi?id=211791
Comment by Daniel (weker01) - Saturday, 27 February 2021, 21:59 GMT
Ahh ok I did not think this was an upstream bug as someone on reddit reported that gentoos kernel did not exhibit it but the same sources with archlinux's config.

I am afraid I do not currently know how to safely patch & build the linux kernel with arch's buildsystem, so no I did not try the recommended patch...
but will try later today hopefully. (My kernel building skills are a bit rusty, long time no gentoo ;)
Comment by Daniel (weker01) - Saturday, 27 February 2021, 23:14 GMT
Ok this was easier than I thought!

I think I can confirm that [1] which is the latest patch in the upstream bug report [2] works!
Although the behavior is rather strange as the frequencies don't jump around anymore like they did on <5.10 but I guess this is expected as there was some work done on the freq subsystem around Zen but no strange > 6GHz spikes!

[1] https://bugzilla.kernel.org/attachment.cgi?id=295295&action=diff
[2] https://bugzilla.kernel.org/show_bug.cgi?id=211305
Comment by loqs (loqs) - Wednesday, 03 March 2021, 21:20 GMT Comment by Daniel (weker01) - Tuesday, 09 March 2021, 21:49 GMT
I can confirm fixed with package 5.11.4-arch1-1