uarch-bench icon indicating copy to clipboard operation
uarch-bench copied to clipboard

Disable turbo on AMD

Open travisdowns opened this issue 7 years ago • 6 comments

The current solution in uarch-bench.sh to disable turbo mode (write to msr regs) only works for Intel, but we should come up with a solution for AMD.

I didn't find anything obvious, but at least in pre-ZEN chips you could do it with the AMD overdrive software, and apparently also (on Windows) by tweaking the "maximum processor state" value in the advanced power settings. So maybe the same can be done through the cpufreq interface in Linux.

travisdowns avatar Jun 03 '17 03:06 travisdowns

Useful link:

https://www.realworldtech.com/forum/?threadid=176780&curpostid=176818

travisdowns avatar Jul 18 '18 20:07 travisdowns

AMD actually documents this: it's called CPB ("core performance boost"), its presence is testable via cpuid, and can be toggled via the HWCR MSR. It's documented in Zen PPR documents, and also appears in earlier models (e.g. in BKDG for fam15h model 7xh).

Tested in manually on Zen 2 and it appears to work as intended.

amonakov avatar Aug 09 '20 21:08 amonakov

AMD actually documents this: it's called CPB ("core performance boost"), its presence is testable via cpuid, and can be toggled via the HWCR MSR. It's documented in Zen PPR documents, and also appears in earlier models (e.g. in BKDG for fam15h model 7xh).

Tested in manually on Zen 2 and it appears to work as intended.

Thanks!

I plan to add support for this when I move the ./uarch-bench.sh script out into a more generic python wrapper that can wrap any call and tries to disable or warn about whatever things might cause noise.

travisdowns avatar Aug 12 '20 21:08 travisdowns

Note that Linux is now filtering userspace MSR writes, with just one MSR allowed at the moment:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/x86/kernel/msr.c?id=a7e1f67ed29f0c339e2aa7483d13b085127566ab

The good news is that on AMD systems the acpi-cpufreq driver exposes a 'boost' sysfs node, which also works to disable turbo. Unfortunately intel-pstate driver does not provide hooks for this interface, so the code needs to support cpufreq/boost as well as intel_pstate/no_turbo:

https://www.kernel.org/doc/Documentation/cpu-freq/boost.txt

amonakov avatar Aug 18 '20 09:08 amonakov

Note that Linux is now filtering userspace MSR writes

Ugh, yes, this definitely makes this trickier. Do you know in which kernel version this starts? I haven't run into it yet, but I saw the news on lwn some time ago.

The good news is that on AMD systems the acpi-cpufreq driver exposes a 'boost' sysfs node, which also works to disable turbo. Unfortunately intel-pstate driver does not provide hooks for this interface, so the code needs to support cpufreq/boost as well as intel_pstate/no_turbo:

Yes, I think that's fine. We can check which file is available, if either, and use that.

travisdowns avatar Aug 18 '20 21:08 travisdowns

Ugh, yes, this definitely makes this trickier. Do you know in which kernel version this starts? I haven't run into it yet, but I saw the news on lwn some time ago.

It was just merged, so may appear in the next release, i.e. 5.9.

amonakov avatar Aug 18 '20 21:08 amonakov