[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v4 00/15] amd-cppc CPU Performance Scaling Driver


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Penny Zheng <Penny.Zheng@xxxxxxx>
  • Date: Mon, 14 Apr 2025 15:40:41 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9aWSOaLrDAtsZ68wXr0GvYxggqEV3GwqC9s74GUmA2Y=; b=pkR/MRkHNNLRo27CppXiS717O1OHBGCspSXSbWRJzk6DLHEkRoFoSuboyCVs1uPu9RLDiVyi2C1+2SsG0PoGyXr5YRP5vQpZPg7QL8rpS9izPat7iaXOay0SSc+6mfpcaANIkGcBHMy9/NblFu9u1swmWNp/JBECZQwgftOobn6vSFSH35XrOSWiwJF3P0OjsWZV1jJwExjO1JHmphtgx7UARRYc2ZMwZiLOBp/R4FzH/TBJhwz1h6Bon6lqjYJXZBov2ah5VkmK4Fhv1fQNI1+W9xE7HidNpFZMkJSg0Ai3sij5X2hiFHNQMKqTShlNRFy6y7fYOteEbg8FXExnqQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j7qIhwNTKoLnyXI5kyEG03uWRU7k3Gld9QLJKo1Rc82L2BudtxqyokrY8rlKBFM/a6b4zL+4NYRu0hYNps2Iwdu9yZAZ8ZJdBSGR6LtOiaQwtPebTAc58ALFPWQ/745n4PaWdhqkYSjp/qSi9o0qjLYjMoC2xFE2/DcGqf/E3zupJ//X+PKBrWShBYuyP21+UvESmr8Qov8sLekHE581NwEe3GEolKqTfDm5dV+FYxOCB8HaU+DYlWBsSPPD/X15eseyTSuWFkZgnwyLl1ksk5vUbkWsiwPc8FVa8cgLWvq//T+s2rWaySNK1sCoDtNH8hgK91pMJF6VN3sEdTNuNg==
  • Cc: <ray.huang@xxxxxxx>, Penny Zheng <Penny.Zheng@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "Anthony PERARD" <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Juergen Gross" <jgross@xxxxxxxx>
  • Delivery-date: Mon, 14 Apr 2025 07:41:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.

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 (15):
  xen/cpufreq: move "init" flag into common structure
  xen/cpufreq: extract _PSD info from "struct xen_processor_performance"
  xen/x86: introduce new sub-hypercall to propagate CPPC data
  xen/cpufreq: refactor cmdline "cpufreq=xxx"
  xen/x86: introduce "cpufreq=amd-cppc" xen cmdline
  xen/cpufreq: disable px statistic info in amd-cppc mode
  xen/cpufreq: fix core frequency calculation for AMD Family 1Ah CPUs
  xen/amd: introduce amd_process_freq() to get processor frequency
  xen/x86: introduce a new amd cppc driver for cpufreq scaling
  xen/cpufreq: only set gov NULL when cpufreq_driver.setpolicy is NULL
  xen/x86: implement EPP support for the amd-cppc driver in active mode
  tools/xenpm: Print CPPC parameters for amd-cppc driver
  tools/xenpm: fix unnecessary scaling_available_frequencies in CPPC
    mode
  tools/xenpm: remove px_cap dependency check for average frequency
  xen/xenpm: Adapt SET/GET_CPUFREQ_CPPC xen_sysctl_pm_op for amd-cppc
    driver

 docs/misc/xen-command-line.pandoc         |  13 +-
 tools/libs/ctrl/xc_pm.c                   |  45 +-
 tools/misc/xenpm.c                        |  20 +-
 xen/arch/x86/acpi/cpufreq/Makefile        |   1 +
 xen/arch/x86/acpi/cpufreq/acpi.c          |  14 +-
 xen/arch/x86/acpi/cpufreq/amd-cppc.c      | 708 ++++++++++++++++++++++
 xen/arch/x86/acpi/cpufreq/cpufreq.c       |  34 +-
 xen/arch/x86/cpu/amd.c                    |  81 ++-
 xen/arch/x86/include/asm/amd.h            |   4 +
 xen/arch/x86/include/asm/msr-index.h      |   6 +
 xen/arch/x86/platform_hypercall.c         |  16 +
 xen/drivers/acpi/pmstat.c                 |  42 +-
 xen/drivers/cpufreq/cpufreq.c             | 306 ++++++++--
 xen/drivers/cpufreq/utility.c             |  14 +
 xen/include/acpi/cpufreq/cpufreq.h        |  22 +-
 xen/include/acpi/cpufreq/processor_perf.h |  11 +-
 xen/include/public/platform.h             |  36 +-
 xen/include/public/sysctl.h               |   2 +
 xen/include/xen/pmstat.h                  |   2 +
 xen/include/xlat.lst                      |   1 +
 20 files changed, 1268 insertions(+), 110 deletions(-)
 create mode 100644 xen/arch/x86/acpi/cpufreq/amd-cppc.c

-- 
2.34.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.