mbox series

[v2,00/11] amd-cppc CPU Performance Scaling Driver

Message ID 20250206083255.1296363-1-Penny.Zheng@amd.com (mailing list archive)
Headers show
Series amd-cppc CPU Performance Scaling Driver | expand

Message

Penny, Zheng Feb. 6, 2025, 8:32 a.m. UTC
amd-cppc is the AMD CPU performance scaling driver that introduces a
new CPU frequency control mechanism on modern AMD APU and CPU series in
Xen. The new mechanism is based on Collaborative Processor Performance
Control (CPPC) which provides finer grain frequency management than
legacy ACPI hardware P-States. Current AMD CPU/APU platforms are using
the ACPI P-states driver to manage CPU frequency and clocks with
switching only in 3 P-states. CPPC replaces the ACPI P-states controls
and allows a flexible, low-latency interface for Xen to directly
communicate the performance hints to hardware.

amd_cppc driver has 2 operation modes: autonomous (active) mode,
and non-autonomous (passive) mode. We register different CPUFreq driver
for different modes, "amd-cppc" for passive mode and "amd-cppc-epp"
for active mode.

The passive mode leverages common governors such as *ondemand*,
*performance*, etc, to manage the performance hints. And the active mode
uses epp to provides a hint to the hardware if software wants to bias
toward performance (0x0) or energy efficiency (0xff). CPPC power algorithm
in hardware will automatically calculate the runtime workload and adjust the
realtime cpu cores frequency according to the power supply and thermal, core
voltage and some other hardware conditions.

amd-cppc is enabled on passive mode with a top-level `cpufreq=amd-cppc` option,
while users add extra `active` flag to select active mode. It will fallback to
`cpufreq=xen` if amd-cppc feature is unavailable on hardware.

With `cpufreq=amd-cppc,active`, we did a 60s sampling test to see the CPU
frequency change, through tweaking the energy_perf preference from
`xenpm set-cpufreq-cppc powersave` to `xenpm set-cpufreq-cppc performance`.
The outputs are as follows:
```
Setting CPU in powersave mode
Sampling and Outputs:
  Avg freq      2000000 KHz
  Avg freq      2000000 KHz
  Avg freq      2000000 KHz
Setting CPU in performance mode
Sampling and Outputs:
  Avg freq      4640000 KHz
  Avg freq      4220000 KHz
  Avg freq      4640000 KHz
```

Penny Zheng (11):
  xen/x86: add CPPC feature flag for AMD processors
  xen/x86: introduce new sub-hypercall to propagate CPPC data
  xen/x86: introduce "cpufreq=amd-cppc" xen cmdline
  xen/amd: export processor max frequency value
  xen/x86: introduce a new amd cppc driver for cpufreq scaling
  xen/cpufreq: only set gov NULL when cpufreq_driver.setpolicy is NULL
  x86/cpufreq: add "cpufreq=amd-cppc,active" para
  xen/cpufreq: abstract Energy Performance Preference value
  xen/x86: implement EPP support for the amd-cppc driver in active mode
  tools/xenpm: Print CPPC parameters for amd-cppc driver
  xen/cpufreq: Adapt SET/GET_CPUFREQ_CPPC xen_sysctl_pm_op for amd-cppc
    driver

 docs/misc/xen-command-line.pandoc           |  14 +-
 tools/misc/xenpm.c                          |  18 +-
 xen/arch/x86/acpi/cpufreq/Makefile          |   1 +
 xen/arch/x86/acpi/cpufreq/amd-cppc.c        | 678 ++++++++++++++++++++
 xen/arch/x86/acpi/cpufreq/cpufreq.c         |  32 +-
 xen/arch/x86/acpi/cpufreq/hwp.c             |  10 +-
 xen/arch/x86/cpu/amd.c                      |   7 +
 xen/arch/x86/include/asm/amd.h              |   1 +
 xen/arch/x86/include/asm/cpufeature.h       |   1 +
 xen/arch/x86/platform_hypercall.c           |  10 +
 xen/arch/x86/x86_64/cpufreq.c               |   2 +
 xen/drivers/acpi/pmstat.c                   |  20 +-
 xen/drivers/cpufreq/cpufreq.c               |  69 +-
 xen/drivers/cpufreq/utility.c               |  11 +
 xen/include/acpi/cpufreq/cpufreq.h          |  31 +
 xen/include/acpi/cpufreq/processor_perf.h   |   1 +
 xen/include/public/arch-x86/cpufeatureset.h |   1 +
 xen/include/public/platform.h               |  17 +
 xen/include/public/sysctl.h                 |   2 +
 xen/include/xen/pmstat.h                    |   1 +
 xen/include/xlat.lst                        |   1 +
 21 files changed, 907 insertions(+), 21 deletions(-)
 create mode 100644 xen/arch/x86/acpi/cpufreq/amd-cppc.c