1

I tried it on desktop Ubuntu 22.04.3, 23.10, regular and lowlatency versions. I have to increase the minimum frequency of a core, which runs an image capture process requiring high CPU clock. Here is an example:

paul@box4x4:~$ sudo cpupower -c 5 frequency-set -d 3000MHz
Setting cpu: 5

which sets the minimum frequency for core #5, but the actual frequency doesn't change:

paul@box4x4:~/profiler$ cpupower -c 5 frequency-info
analyzing CPU 5:
  driver: amd-pstate-epp
  CPUs which run at the same hardware frequency: 5
  CPUs which need to have their frequency coordinated by software: 5
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 400 MHz - 5.58 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 3.00 GHz and 5.58 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 400 MHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: no

and stays and glacial 400MHz. Am I doing it wrong? Is there another, hopefully not too cumbersome, way and tool to accomplish it?

One red flag with I see here is a bogus maximum frequency of 5.58GHz. It is not possible. 4.9GHz is the maximum turbo frequency for AMD Ryzen 5 7640U CPU I'm using.


I did a sanity test on Intel N100 PC and it seems to work there:

paul@cube:~$ sudo cpupower -c 3 frequency-info
analyzing CPU 3:
  driver: intel_pstate
  CPUs which run at the same hardware frequency: 3
  CPUs which need to have their frequency coordinated by software: 3
  maximum transition latency:  Cannot determine or is not supported.
  hardware limits: 700 MHz - 3.40 GHz
  available cpufreq governors: performance powersave
  current policy: frequency should be within 3.40 GHz and 3.40 GHz.
                  The governor "performance" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 3.30 GHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes

Core #3 frequency reaches requested 3.4GHz, but sometimes reading lower when monitored with watch grep \"cpu MHz\" /proc/cpuinfo. Still, vastly better than the results on AMD CPU.

Paul Jurczak
  • 1,267
  • Try reading and writing from the scaling files in /sys/devices/system/cpu/cpu*/cpufreq. Set both max and min if you want it constant. If the governor is schedutil, set it to something else first. – Daniel T Jan 29 '24 at 09:43
  • @DanielT scaling-governor, scaling_max_freq and scaling_min_freq files have values corresponding to cpupower-frequency-info output. – Paul Jurczak Jan 29 '24 at 09:49
  • Oh. Now I have read cpufreq.c. Please run the frequency-info as root to avoid "current CPU frequency: Unable to call hardware". Based on "CPUs which [...] frequency: 5 CPUs which [...] software: 5", does it work when you change the frequency of all cores together? (for reference, https://unix.stackexchange.com/a/61300/524752). Since you're using the EPP driver, what are the contents of energy_performance_preference? – Daniel T Jan 29 '24 at 10:18
  • @DanielT sudo doesn't change Unable to call hardware. Setting all cores together doesn't change the behavior. energy_performance_preference is set to performance. Reading on the subject, I think that OS is not allowed to control these parameters. I don't see a BIOS setting to change it, though. – Paul Jurczak Jan 29 '24 at 10:27
  • 2
    Let's try something else. What if you put amd_pstate=disable in the /etc/default/grub command line, upgrade-grub and reboot? This should turn "driver: amd-pstate-epp" into "driver: acpi-cpufreq". Then retry everything you and I thought of. – Daniel T Jan 29 '24 at 10:40
  • @DanielT I did that and I'm still getting driver: amd-pstate-epp – Paul Jurczak Jan 29 '24 at 19:44
  • @DanielT I initially placed amd_pstate=disable at the end of the file. When added to GRUB_CMDLINE_LINUX_DEFAULT it works as intended. BTW, update-grub is what I needed. – Paul Jurczak Jan 30 '24 at 03:37
  • I will move this to an answer. Yeah, that's what I meant. I think I need to omit less details from now one. Yesterday, in the comments of another question, I wrote echo | sudo tee and wrongly assumed people would understand it based on context – Daniel T Jan 30 '24 at 04:37

2 Answers2

2

The problem here is the driver: amd-pstate-epp. It is trying to be too smart, so let's disable it:

  1. sudo vim /etc/default/grub
  2. Find the line with GRUB_CMDLINE_LINUX_DEFAULT=
  3. Add amd_pstate=disable inside the double quotes. If there are other items, add this to the end, and separate it from the previous items with a space.
  4. Save and exit
  5. Run sudo update-grub
  6. reboot
  7. Retry your original sudo cpupower -c 5 frequency-set -d 3000MHz

The EPP in amd-pstate-epp stands for energy_performance_preference. It might also have some kind of interaction with the "CPUs which run at the same hardware frequency [...and...] need to have their frequency coordinated by software". According to the docs, the

amd_pstate_epp driver provides a hint to the hardware if software wants to bias toward performance (0x0) or energy efficiency (0xff) to the CPPC firmware. then CPPC power algorithm will calculate the runtime workload and adjust the realtime cores frequency according to the power supply and thermal, core voltage and some other hardware conditions.

and the other modes are similar. The amd-pstate attribute controls which strategy it will use, if at all.

The acpi-cpufreq driver is the old one. It usually just does what you tell it to do. In this case, you do indeed want to "increase the minimum frequency of a core," based on your specialized knowledge that it is going to be used for "an image capture process," so you need this driver.

Daniel T
  • 5,362
0

In my case switching to acpi-cpufreq did not help (Debian 13 Trixie RC1, kernel 6.12.27).

Solved by building and installing fresh 6.14.9 kernel from the sources, in this case frequency is controlled even using the default amd-pstate-epp driver. It also works out of the box in Arch.

Sunny Cove
  • 101
  • 1