Is the amd-pstate driver included in 5.17-rc1 kernel?

Everything seems to be fine
I’ve got a question. Maybe wrong place to ask, if so - forgive me
Is amd-pstate driver included in 5.17-rc1 kernel? I don’t quite understand how to change cpu scaling driver to amd_pstate that was introduced in mainline kernel 5.17
Thank you

Yes it is, see

How to enable I have no clue though. I would hope it’s done automatically on detection.
When you find out, would you mind telling?

2 Likes

I don’t know how much different the driver is in 5.17 than the community patch form the TKG Kernel build but according to that patch “Support for most non-Epyc processors has been disabled by default”. Personally I’ve tried it with amd_pstate.shared_mem=1 but I couldn’t get it working at all while using the community patch.

seems that u’re right because I couldn’t turn on the amd-pstate scaling driver even with amd_pstate.shared_mem=1

I just tried rc2 and it still uses acpi:

# cpupower frequency-info 
analyzing CPU 0:
  driver: acpi-cpufreq
...

It seems that the kernel was built with amd-pstate support:

zless /proc/config.gz

contains a line

CONFIG_X86_AMD_PSTATE=y

yes i checked this either and it seems like amd pstate driver should be included in the kernel but there is no amd-pstate driver tho :frowning:

What computer are you using? I think the BIOS needs to expose some interface of the CPU [1]. I have an Lenovo L14 (AMD) Gen 1 with an 4750U.

From the documentation [2]:

+The amd-pstate initialization will fail if the _CPC in ACPI SBIOS is
+not existed at the detected processor, and it uses acpi_cpc_valid to
+check the _CPC existence.

So at this point I think the most likely explanation is that Lenovo just needlessly locked down some necessary interface.

[1] AMD P-State Driver To Premiere In Linux 5.17 With Aim To Deliver Better Power Efficiency - Phoronix
[2] LKML: Huang Rui: [PATCH v7 13/14] Documentation: amd-pstate: Add AMD P-State driver introduction

Kernel documentation states option for shared memory support is currently disabled to address a performance issue:

amd-pstate CPU Performance Scaling Driver — The Linux Kernel documentation

Kernel Module Options for amd-pstate

shared_mem Use a module param (shared_mem) to enable related processors manually with amd_pstate.shared_mem=1. Due to the performance issue on the processors with Shared Memory Support, so we disable it for the moment and will enable this by default once we address performance issue on this solution.

The way to check whether current processor is Full MSR Support or Shared Memory Support :

lscpu | grep cppc

If CPU Flags have cppc, then this processor supports Full MSR Support. Otherwise it supports Shared Memory Support.

lscpu says cppc and msr:

  Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_go
                       od nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy sv
                       m extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate
                        ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc 
                       cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter 
                       pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip rdpid overflow_recov succor smca

I did some more digging and found that modinfo amd_pstate says “shared_mem:enable” and I can’t even disable it by setting the kernel parameter amd_pstate.shared_mem=0.

amd_pstate.shared_mem also does not appear in sysctl and modprobe amd_pstate shared_mem=1 does nothing.

It seems necessary to add AMD to the configuration file of mkinitcpio_ Pstate kernel module, but AMD_ The benefit of pstate seems to be very low. Even if the CPU runs at 550MHz, the power consumption will not be reduced much. Even if all hard disks are turned off, the minimum power consumption of 5800x and b550 platforms is about 75W (measured by hardware power meter).

I enabled amd_pstate.shared_mem=1 in grub config and checked:

sudo cpupower frequency-info        
analyzing CPU 0:
  driver: amd-pstate
  CPUs which run at the same hardware frequency: 0
  CPUs which need to have their frequency coordinated by software: 0
  maximum transition latency: 131 us
  hardware limits: 550 MHz - 4.21 GHz
  available cpufreq governors: conservative ondemand userspace powersave performance schedutil
  current policy: frequency should be within 550 MHz and 4.21 GHz.
                  The governor "schedutil" may decide which speed to use
                  within this range.
  current CPU frequency: Unable to call hardware
  current CPU frequency: 647 MHz (asserted by call to kernel)
  boost state support:
    Supported: yes
    Active: yes
    Boost States: 0
    Total States: 3
    Pstate-P0:  3600MHz
    Pstate-P1:  2800MHz
    Pstate-P2:  2200MHz

But I got the two error messages in the log:

journalctl --no-pager -p 3 -b                                                                                                                                                                                            8s
Mai 20 17:50:22 zesko systemd-udevd[425]: could not read from '/sys/module/pcc_cpufreq/initstate': No such device
Mai 20 17:50:23 zesko systemd-udevd[436]: could not read from '/sys/module/pcc_cpufreq/initstate': No such device

I think these error messages are related to amd-pstate or not?

Linux Kernel:

5.17.9-1-MANJARO

I disabled amd-pstate, these error messages are gone.

Seems Manjaro’s (also Arch’s?) 5.18 kernel comes with CONFIG_X86_AMD_PSTATE=m, so using amd_pstate takes some extra steps now.

I’ve been tinkering with this (with 5.18.17-1-MANJARO) for a couple of days and think I figured it out.

First I tried with the “amd_pstate.shared_mem=1” option in grub config. This worked, but then I read the driver author’s description at kernel dot org and he mentions something about latency/performance issues with the shared memory solution.

If your CPU supports it, it seems the better solution is to aim for “Full MSR Support”.

I was finally able to do this with a combination of the following:

  1. Edit /etc/default/grub and Insert initcall_blacklist=acpi_cpufreq_init into GRUB_CMDLINE_LINUX_DEFAULT= (and then sudo update-grub)

  2. Edit /etc/modules-load.d/modules.conf and simply add the text amd_pstate

It is working very well indeed. CPU (R5 5625U) idles at 400MHz and shows:

analyzing CPU 0:
driver: amd-pstate
CPUs which run at the same hardware frequency: 0
CPUs which need to have their frequency coordinated by software: 0
maximum transition latency: 131 us
hardware limits: 400 MHz - 4.39 GHz
available cpufreq governors: conservative ondemand userspace powersave performance schedutil
current policy: frequency should be within 400 MHz and 4.39 GHz.
The governor “conservative” may decide which speed to use
within this range.
current CPU frequency: Unable to call hardware
current CPU frequency: 465 MHz (asserted by call to kernel)
boost state support:
Supported: yes
Active: yes
AMD PSTATE Highest Performance: 166. Maximum Frequency: 4.39 GHz.
AMD PSTATE Nominal Performance: 87. Nominal Frequency: 2.30 GHz.
AMD PSTATE Lowest Non-linear Performance: 42. Lowest Non-linear Frequency: 1.11 GHz.
AMD PSTATE Lowest Performance: 16. Lowest Frequency: 400 MHz.

By the way, this is on my new HP 15-ef3017ca laptop. CPU idle temp is down to 45C (was 60C with acpi_cpufreq) using conservative governor. The fan is inaudible (until under sustained load, of course). Frequency scaling is very granular and smooth, from 400MHz all the way through 4.3GHz.

5.18 has been EOL for a moment. amd-pstate works again in 5.19

LOL. Thanks.

How did I possibly miss 5.19 kernel in Manjaro Settings Manager ?

I feel like a fool.

EDIT: Although I think I will hold off on 5.19 for now, as I see it has an issue resuming from suspend.