Skip to contentSkip to conversation

Add unit test module for AMD P-State driver

PATCH Superseded Meng Li 3 participants 11 messages May 22, 2022 – May 25, 2022

Subsystems (4)

v7 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Meng Li

author
#0 lore raw

v7 cover Add unit test module for AMD P-State driver

Hi all:

AMD P-State unit test(amd-pstate-ut) is a kernel module for testing the functions of amd-pstate driver.
It could import as a module to launch some test tasks.
1) It can help all users to verify their processor support (SBIOS/ Firmware or Hardware).
2) Kernel can have a basic function test to avoid the kernel regression during the update.
3) We can introduce more functional or performance tests to align the together, it will benefit power and performance scale optimization.

We upstream out AMD P-state driver into Linux kernel and use this unit test module to verify the required conditions and basic functions of amd-pstate before integration test.

We use test module in the kselftest frameworks to implement it. We create amd-pstate-ut module and tie it into kselftest.

For example: The test case aput_acpi_cpc is used to check whether the _CPC object is exist in SBIOS.
The amd-pstate initialization will fail if the _CPC in ACPI SBIOS is not existed at the detected processor, so it is a necessary condition.

At present, it only implements the basic framework and some simple test cases.

TODO : 1) we will add more test cases to improve the depth and coverage of the test. E.X. use the script to trigger the tbench, gitsource, kernbench, netperf, speedometer, and etc. testing and monitor the cpu frequency and performance goals change, power consumption at runtime.

Please check the documentation amd-pstate.rst for details of the test steps.

See patch series in below git repo:
V1: https://lore.kernel.org/linux-pm/[email protected]/
V2: https://lore.kernel.org/lkml/[email protected]/
V3: https://lore.kernel.org/lkml/[email protected]/
V4: https://lore.kernel.org/lkml/[email protected]/
V5: https://lore.kernel.org/lkml/[email protected]/
V6: https://lore.kernel.org/lkml/[email protected]/

Changes from V1 -> V2:
- cpufreq: amd-pstate:
- - add a trailing of amd-pstate.h to MAINTAINER AMD PSTATE DRIVER.
- selftests: cpufreq:
- - add a wrapper shell script for the amd_pstate_testmod module.
- selftests: cpufreq:
- - remove amd_pstate_testmod kernel module to .../cpufreq/amd_pstate_testmod.
- Documentation: amd-pstate:
- - amd_pstate_testmod rst document is not provided at present.

Changes from V2 -> V3:
- cpufreq: amd-pstate:
- - adjust the order of add amd-pstate.h in MAINTAINERS.
- selftests: cpufreq:
- - remove the call of amd_pstate_testmod.sh from cpufreq Makefile to main.sh.
- selftests: cpufreq:
- - add explain the goal or intention of the AMD P-State Unit Test module.
- - modify comments.
- - use the checkpatch.pl to check my patches.
- - add conditions judgment before formal test.
- - delete some unnecessary test cases.
- - modify test cases about perf and performance etc.

Changes from V3 -> V4:
- selftests: amd-pstate:
- - remove script and test module to tools/testing/selftests/amd-pstate/
- - uniformly named amd-pstate-ut.
- - check current architectures and cpufreq driver in amd-pstate-ut.sh
- - delete codes about conditions in amd-pstate-ut.c
- Documentation: amd-pstate:
- - add introduce document about amd-pstate unit test.

Changes from V4 -> V5:
- selftests: amd-pstate:
- - add print the current scaling_driver.
- - add amd-pstate-ut.ko into TEST_GEN_FILES.
- - move "insmod/rmmod amd-pstate-ut.ko" stuff into script amd_pstate_ut.sh
- - add a check of read back from X86_FEATURE_CPPC in get_shared_mem().
- Documentation: amd-pstate:
- - delete the test step about insmod/rmmod amd-pstate-ut.ko

Changes from V5 -> V6:
- cpufreq: amd-pstate:
- - add amd-pstate-ut test codes to drivers/cpurfreq
- - add the macro CONFIG_X86_AMD_PSTATE_UT
- selftests: amd-pstate:
- - delete amd-pstate-ut test codes from tools/testing/selftests/amd-pstate/

Changes from V6 -> V7:
- cpufreq: amd-pstate:
- - modify X86_AMD_PSTATE_UT dependencies and default value.
- - modify a brief description of the amd-pstate-ut module.
- - remove kselftest_module.h header include.
- - modify shortform for AMD P-State unit test.
- - add prefix for the names of test cases.
- - in the file operation log, add the file path.
- - add comments about the test cases.
- - correct syntax errors.
- selftests: amd-pstate:
- - delete TEST_GEN_FILES$(TEST_GEN_FILES): $(HEADERS) form amd-pstate Makefile.
- - simplify the judgment about ARCH.
- - add the judgment about cpu vendor.
- - modify the method about load the amd-pstate-ut module.
- Documentation: amd-pstate:
- - update the name of the test function.
- - update kernel log about test result.

Thanks,
Jasmine

Meng Li (4):
cpufreq: amd-pstate: Expose struct amd_cpudata
cpufreq: amd-pstate: Add test module for amd-pstate driver
selftests: amd-pstate: Add test trigger for amd-pstate driver
Documentation: amd-pstate: Add unit test introduction

 Documentation/admin-guide/pm/amd-pstate.rst   |  76 +++++
 MAINTAINERS                                   |   1 +
 drivers/cpufreq/Kconfig.x86                   |   7 +
 drivers/cpufreq/Makefile                      |   1 +
 drivers/cpufreq/amd-pstate-ut.c               | 293 ++++++++++++++++++
 drivers/cpufreq/amd-pstate.c                  |  60 +---
 include/linux/amd-pstate.h                    |  77 +++++
 tools/testing/selftests/Makefile              |   1 +
 tools/testing/selftests/amd-pstate/Makefile   |   9 +
 .../selftests/amd-pstate/amd-pstate-ut.sh     |  55 ++++
 tools/testing/selftests/amd-pstate/config     |   1 +
 11 files changed, 522 insertions(+), 59 deletions(-)
 create mode 100644 drivers/cpufreq/amd-pstate-ut.c
 create mode 100644 include/linux/amd-pstate.h
 create mode 100644 tools/testing/selftests/amd-pstate/Makefile
 create mode 100755 tools/testing/selftests/amd-pstate/amd-pstate-ut.sh
 create mode 100644 tools/testing/selftests/amd-pstate/config
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v7 1/4 cpufreq: amd-pstate: Expose struct amd_cpudata

Expose struct amd_cpudata to AMD P-State unit test module.

This data struct will be used on the following AMD P-State unit test (amd-pstate-ut) module. The amd-pstate-ut module can get some AMD infomations by this data struct. For example: highest perf, nominal perf, boost supported etc.

---
 MAINTAINERS                  |  1 +
 drivers/cpufreq/amd-pstate.c | 60 +---------------------------
 include/linux/amd-pstate.h   | 77 ++++++++++++++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 59 deletions(-)
 create mode 100644 include/linux/amd-pstate.h
MAINTAINERS +1 -0
index edc96cdb85e8..c2e5299b0051 100644
@@ -1021,6 +1021,7 @@ L:	[email protected]
 S:	Supported
 F:	Documentation/admin-guide/pm/amd-pstate.rst
 F:	drivers/cpufreq/amd-pstate*
+F:	include/linux/amd-pstate.h
 F:	tools/power/x86/amd_pstate_tracer/amd_pstate_trace.py
 
 AMD PTDMA DRIVER
drivers/cpufreq/amd-pstate.c +1 -59

72 lines not on this page · raw message

include/linux/amd-pstate.h new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer Acked-by on v7 1/4
#2 lore raw

Re: [PATCH V7 1/4] cpufreq: amd-pstate: Expose struct amd_cpudata

Quoted 7 lines · Meng Li

Expose struct amd_cpudata to AMD P-State unit test module.

This data struct will be used on the following AMD P-State unit test (amd-pstate-ut) module. The amd-pstate-ut module can get some AMD infomations by this data struct. For example: highest perf, nominal perf, boost supported etc.

Quoted 9 lines
---
  MAINTAINERS                  |  1 +
  drivers/cpufreq/amd-pstate.c | 60 +---------------------------
  include/linux/amd-pstate.h   | 77 ++++++++++++++++++++++++++++++++++++
  3 files changed, 79 insertions(+), 59 deletions(-)

create mode 100644 include/linux/amd-pstate.h

Looks good to me.

thanks,
-- Shuah

author
#3 lore raw

PATCH v7 2/4 cpufreq: amd-pstate: Add test module for amd-pstate driver

In reply to Meng Li

Add amd-pstate-ut module, which is conceptually out-of-tree module and provides ways for selftests/amd-pstate driver to test various kernel module-related functionality. This module will be expected by some of selftests to be present and loaded.

---
 drivers/cpufreq/Kconfig.x86     |   7 +
 drivers/cpufreq/Makefile        |   1 +
 drivers/cpufreq/amd-pstate-ut.c | 293 ++++++++++++++++++++++++++++++++
 3 files changed, 301 insertions(+)
 create mode 100644 drivers/cpufreq/amd-pstate-ut.c
drivers/cpufreq/Kconfig.x86 +7 -0
index 55516043b656..fdd819069d72 100644
@@ -51,6 +51,13 @@ config X86_AMD_PSTATE
 
 	  If in doubt, say N.
 
+config X86_AMD_PSTATE_UT
+	tristate "selftest for AMD Processor P-State driver"
+	depends on X86 && ACPI_PROCESSOR
+	default n
+	help
+	  This kernel module is used for testing. It's safe to say M here.
+
 config X86_ACPI_CPUFREQ
 	tristate "ACPI Processor P-States driver"
 	depends on ACPI_PROCESSOR
drivers/cpufreq/Makefile +1 -0
index 285de70af877..49b98c62c5af 100644
@@ -30,6 +30,7 @@ amd_pstate-y				:= amd-pstate.o amd-pstate-trace.o
 
 obj-$(CONFIG_X86_ACPI_CPUFREQ)		+= acpi-cpufreq.o
 obj-$(CONFIG_X86_AMD_PSTATE)		+= amd_pstate.o
+obj-$(CONFIG_X86_AMD_PSTATE_UT)		+= amd-pstate-ut.o
 obj-$(CONFIG_X86_POWERNOW_K8)		+= powernow-k8.o
 obj-$(CONFIG_X86_PCC_CPUFREQ)		+= pcc-cpufreq.o
 obj-$(CONFIG_X86_POWERNOW_K6)		+= powernow-k6.o
drivers/cpufreq/amd-pstate-ut.c new file +293 -0

293 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH V7 2/4] cpufreq: amd-pstate: Add test module for amd-pstate driver

Quoted 5 lines · Meng Li

Add amd-pstate-ut module, which is conceptually out-of-tree module and provides ways for selftests/amd-pstate driver to test various kernel module-related functionality. This module will be expected by some of selftests to be present and loaded.

Quoted 8 lines
---
 drivers/cpufreq/Kconfig.x86     |   7 +
 drivers/cpufreq/Makefile        |   1 +
 drivers/cpufreq/amd-pstate-ut.c | 293 ++++++++++++++++++++++++++++++++
 3 files changed, 301 insertions(+)
 create mode 100644 drivers/cpufreq/amd-pstate-ut.c

I wonder if this should be moved to selftest directories instead ?

Signature · 1 line
viresh
#5 lore raw

RE: [PATCH V7 2/4] cpufreq: amd-pstate: Add test module for amd-pstate driver

[AMD Official Use Only - General]

Quoted 34 lines

-----Original Message-----
From: Viresh Kumar <[email protected]>
Sent: Monday, May 23, 2022 3:32 PM
To: Meng, Li (Jassmine) <[email protected]>
Cc: Shuah Khan <[email protected]>; Huang, Ray <[email protected]>; [email protected]; Rafael J . Wysocki <[email protected]>; Fontenot, Nathan <[email protected]>; Sharma, Deepak <[email protected]>; Deucher, Alexander <[email protected]>; Limonciello, Mario <[email protected]>; Su, Jinzhou (Joe) <[email protected]>; Yuan, Perry <[email protected]>; Du, Xiaojian <[email protected]>; Borislav Petkov <[email protected]>; [email protected]
Subject: Re: [PATCH V7 2/4] cpufreq: amd-pstate: Add test module for amd- pstate driver

[CAUTION: External Email]

Quoted 7 lines · Meng Li

Add amd-pstate-ut module, which is conceptually out-of-tree module and provides ways for selftests/amd-pstate driver to test various kernel module-related functionality. This module will be expected by some of selftests to be present and loaded.

Quoted 7 lines
---
 drivers/cpufreq/Kconfig.x86     |   7 +
 drivers/cpufreq/Makefile        |   1 +
 drivers/cpufreq/amd-pstate-ut.c | 293
++++++++++++++++++++++++++++++++
 3 files changed, 301 insertions(+)
 create mode 100644 drivers/cpufreq/amd-pstate-ut.c
Quoted 4 lines

I wonder if this should be moved to selftest directories instead ?

--
Viresh

Thanks.
We took Shuah's comments and put test driver under drivers/cpufreq.

[Meng, Li (Jassmine)]

maintainer Reviewed-by on v7 2/4
#6 lore raw

Re: [PATCH V7 2/4] cpufreq: amd-pstate: Add test module for amd-pstate driver

In reply to Meng Li
Quoted 1 line · Meng Li

Add amd-pstate-ut module, which is conceptually out-of-tree module

I didn't notice this before. Let's get rid of "out-of-tree" workding.

Quoted 4 lines

and provides ways for selftests/amd-pstate driver to test various kernel module-related functionality. This module will be expected by some of selftests to be present and loaded.

What does "various kernel module-related functionality" mean. Can we rephrase this to say "this module is used by kselftest to unit test amd-pstate functionality" ?

Quoted 3 lines

---

[snip]

drivers/cpufreq/amd-pstate-ut.c line 292

Quoted 6 lines
drivers/cpufreq/amd-pstate-ut.c new file +6 -0
+
+module_init(amd_pstate_ut_init);
+module_exit(amd_pstate_ut_exit);
+
+MODULE_AUTHOR("Meng Li <[email protected]>");
+MODULE_DESCRIPTION("Kselftest for AMD P-state driver");

Change this to "AMD P-state driver Test module"

Having Kselftest in the name is confusing. It is a test driver that kselftest amd_pstate_test depends on.

Quoted 2 lines

+MODULE_LICENSE("GPL");

With these above changes:

thanks,
-- Shuah

author
#7 lore raw

PATCH v7 3/4 selftests: amd-pstate: Add test trigger for amd-pstate driver

In reply to Meng Li

Add amd-pstate test trigger in kselftest, it will load/unload amd-pstate-ut module to test some cases etc.

---
 tools/testing/selftests/Makefile              |  1 +
 tools/testing/selftests/amd-pstate/Makefile   |  9 +++
 .../selftests/amd-pstate/amd-pstate-ut.sh     | 55 +++++++++++++++++++
 tools/testing/selftests/amd-pstate/config     |  1 +
 4 files changed, 66 insertions(+)
 create mode 100644 tools/testing/selftests/amd-pstate/Makefile
 create mode 100755 tools/testing/selftests/amd-pstate/amd-pstate-ut.sh
 create mode 100644 tools/testing/selftests/amd-pstate/config
tools/testing/selftests/Makefile +1 -0
index 2319ec87f53d..975c13368286 100644
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 TARGETS += alsa
+TARGETS += amd-pstate
 TARGETS += arm64
 TARGETS += bpf
 TARGETS += breakpoints
tools/testing/selftests/amd-pstate/Makefile new file +9 -0
new file mode 100644
index 000000000000..199867f44b32
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Makefile for amd-pstate/ function selftests
+
+# No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
+all:
+
+TEST_PROGS := amd-pstate-ut.sh
+
+include ../lib.mk
tools/testing/selftests/amd-pstate/amd-pstate-ut.sh new file +55 -0

55 lines not on this page · raw message

tools/testing/selftests/amd-pstate/config new file +1 -0
new file mode 100644
index 000000000000..f43103c9adc4
@@ -0,0 +1 @@
+CONFIG_X86_AMD_PSTATE_UT=m
Signature · 1 line
2.25.1
maintainer Reviewed-by on v7 3/4
#8 lore raw

Re: [PATCH V7 3/4] selftests: amd-pstate: Add test trigger for amd-pstate driver

Quoted 11 lines · Meng Li

Add amd-pstate test trigger in kselftest, it will load/unload amd-pstate-ut module to test some cases etc.

---
  tools/testing/selftests/Makefile              |  1 +
  tools/testing/selftests/amd-pstate/Makefile   |  9 +++
  .../selftests/amd-pstate/amd-pstate-ut.sh     | 55 +++++++++++++++++++
  tools/testing/selftests/amd-pstate/config     |  1 +
  4 files changed, 66 insertions(+)
Quoted 4 lines

create mode 100644 tools/testing/selftests/amd-pstate/Makefile create mode 100755 tools/testing/selftests/amd-pstate/amd-pstate-ut.sh create mode 100644 tools/testing/selftests/amd-pstate/config

Looks good to me.

thanks,
-- Shuah

author
#9 lore raw

PATCH v7 4/4 Documentation: amd-pstate: Add unit test introduction

In reply to Meng Li

Introduce the AMD P-State unit test module design and implementation.

---
 Documentation/admin-guide/pm/amd-pstate.rst | 76 +++++++++++++++++++++
 1 file changed, 76 insertions(+)
Documentation/admin-guide/pm/amd-pstate.rst +76 -0
index 83b58eb4ab4d..c2b8693601aa 100644
@@ -182,6 +182,7 @@ to the ``struct sugov_cpu`` that the utilization update belongs to.
 Then, ``amd-pstate`` updates the desired performance according to the CPU
 scheduler assigned.
 
+.. _processor_support:
 
 Processor Support
 =======================
@@ -282,6 +283,8 @@ efficiency frequency management method on AMD processors.
 Kernel Module Options for ``amd-pstate``
 =========================================
 
+.. _shared_mem:
+
 ``shared_mem``
 Use a module param (shared_mem) to enable related processors manually with
 **amd_pstate.shared_mem=1**.
@@ -393,6 +396,76 @@ about part of the output. ::
  CPU_005     712          116384        39        49        166       0.7565  9645075 2214891 38431470  25.1   11.646       469         2.496         kworker/5:0-40
  CPU_006     712          116408        39        49        166       0.6769  8950227 1839034 37192089  24.06  11.272       470         2.496         kworker/6:0-1264
 
+Unit Tests for amd-pstate
+-------------------------
+
+``amd-pstate-ut`` is a test module for testing the ``amd-pstate`` driver.
+
+ * It can help all users to verify their processor support (SBIOS/Firmware or Hardware).
+
+ * Kernel can have a basic function test to avoid the kernel regression during the update.
+
+ * We can introduce more functional or performance tests to align the result together, it will benefit power and performance scale optimization.
+
+1. Test case decriptions
+
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+        | Index   | Functions                      | Description                                                                        |
+        +=========+================================+====================================================================================+
+        | 0       | amd_pstate_ut_acpi_cpc_valid   || Check whether the _CPC object is present in SBIOS.                                |
+        |         |                                ||                                                                                   |
+        |         |                                || The detail refer to `Processor Support <processor_support_>`_.                    |
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+        | 1       | amd_pstate_ut_check_enabled    || Check whether AMD P-State is enabled.                                             |
+        |         |                                ||                                                                                   |
+        |         |                                || AMD P-States and ACPI hardware P-States always can be supported in one processor. |
+        |         |                                | But AMD P-States has the higher priority and if it is enabled with                 |
+        |         |                                | :c:macro:`MSR_AMD_CPPC_ENABLE` or ``cppc_set_enable``, it will respond to the      |
+        |         |                                | request from AMD P-States.                                                         |
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+        | 2       | amd_pstate_ut_check_perf       || Check if the each performance values are reasonable.                              |
+        |         |                                || highest_perf >= nominal_perf > lowest_nonlinear_perf > lowest_perf > 0.           |
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+        | 3       | amd_pstate_ut_check_freq       || Check if the each frequency values and max freq when set support boost mode       |
+        |         |                                | are reasonable.                                                                    |
+        |         |                                || max_freq >= nominal_freq > lowest_nonlinear_freq > min_freq > 0                   |
+        |         |                                || If boost is not active but supported, this maximum frequency will be larger than  |
+        |         |                                | the one in ``cpuinfo``.                                                            |
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+
+#. How to execute the tests
+
+   We use test module in the kselftest frameworks to implement it.
+   We create amd-pstate-ut module and tie it into kselftest.(for
+   details refer to Linux Kernel Selftests [4]_).
+
+    1. Build
+
+        + open the :c:macro:`CONFIG_X86_AMD_PSTATE` configuration option.
+        + set the :c:macro:`CONFIG_X86_AMD_PSTATE_UT` configuration option to M.
+        + make project
+        + make selftest ::
+
+            jasminemeng@jasmine-meng:~/amd-brahma$ cd linux
+            jasminemeng@jasmine-meng:~/amd-brahma/linux$ make -C tools/testing/selftests
+
+    #. Installation & Steps ::
+
+        jasmine@jasmine-meng:~/amd-brahma/linux$ make -C tools/testing/selftests install INSTALL_PATH=~/kselftest
+        jasmine@jasmine-meng:~$ sudo ./kselftest/run_kselftest.sh -c amd-pstate
+        TAP version 13
+        1..1
+        # selftests: amd-pstate: amd-pstate-ut.sh
+        # amd-pstate-ut: ok
+        ok 1 selftests: amd-pstate: amd-pstate-ut.sh
+
+    #. Results ::
+
+         jasmine@jasmine-meng:~$ dmesg | grep "amd_pstate_ut" | tee log.txt
+         [12977.570663] amd_pstate_ut: 1    amd_pstate_ut_acpi_cpc_valid  success!
+         [12977.570673] amd_pstate_ut: 2    amd_pstate_ut_check_enabled   success!
+         [12977.571207] amd_pstate_ut: 3    amd_pstate_ut_check_perf      success!
+         [12977.571212] amd_pstate_ut: 4    amd_pstate_ut_check_freq      success!
 
 Reference
 ===========
@@ -405,3 +478,6 @@ Reference
 
 .. [3] Processor Programming Reference (PPR) for AMD Family 19h Model 51h, Revision A1 Processors
        https://www.amd.com/system/files/TechDocs/56569-A1-PUB.zip
+
+.. [4] Linux Kernel Selftests,
+       https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html
Signature · 1 line
2.25.1
maintainer Reviewed-by on v7 4/4
#10 lore raw

Re: [PATCH V7 4/4] Documentation: amd-pstate: Add unit test introduction

Quoted 1 line · Meng Li

Introduce the AMD P-State unit test module design and implementation.

It also talks about kselftest and how to use - let's say that here.

Quoted 74 lines
---
  Documentation/admin-guide/pm/amd-pstate.rst | 76 +++++++++++++++++++++
  1 file changed, 76 insertions(+)
Documentation/admin-guide/pm/amd-pstate.rst +45 -0
index 83b58eb4ab4d..c2b8693601aa 100644
@@ -182,6 +182,7 @@ to the ``struct sugov_cpu`` that the utilization update belongs to.
  Then, ``amd-pstate`` updates the desired performance according to the CPU
  scheduler assigned.
 
+.. _processor_support:
 
  Processor Support
  =======================
@@ -282,6 +283,8 @@ efficiency frequency management method on AMD processors.
  Kernel Module Options for ``amd-pstate``
  =========================================
 
+.. _shared_mem:
+
  ``shared_mem``
  Use a module param (shared_mem) to enable related processors manually with
  **amd_pstate.shared_mem=1**.
@@ -393,6 +396,76 @@ about part of the output. ::
   CPU_005     712          116384        39        49        166       0.7565  9645075 2214891 38431470  25.1   11.646       469         2.496         kworker/5:0-40
   CPU_006     712          116408        39        49        166       0.6769  8950227 1839034 37192089  24.06  11.272       470         2.496         kworker/6:0-1264
 
+Unit Tests for amd-pstate
+-------------------------
+
+``amd-pstate-ut`` is a test module for testing the ``amd-pstate`` driver.
+
+ * It can help all users to verify their processor support (SBIOS/Firmware or Hardware).
+
+ * Kernel can have a basic function test to avoid the kernel regression during the update.
+
+ * We can introduce more functional or performance tests to align the result together, it will benefit power and performance scale optimization.
+
+1. Test case decriptions
+
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+        | Index   | Functions                      | Description                                                                        |
+        +=========+================================+====================================================================================+
+        | 0       | amd_pstate_ut_acpi_cpc_valid   || Check whether the _CPC object is present in SBIOS.                                |
+        |         |                                ||                                                                                   |
+        |         |                                || The detail refer to `Processor Support <processor_support_>`_.                    |
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+        | 1       | amd_pstate_ut_check_enabled    || Check whether AMD P-State is enabled.                                             |
+        |         |                                ||                                                                                   |
+        |         |                                || AMD P-States and ACPI hardware P-States always can be supported in one processor. |
+        |         |                                | But AMD P-States has the higher priority and if it is enabled with                 |
+        |         |                                | :c:macro:`MSR_AMD_CPPC_ENABLE` or ``cppc_set_enable``, it will respond to the      |
+        |         |                                | request from AMD P-States.                                                         |
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+        | 2       | amd_pstate_ut_check_perf       || Check if the each performance values are reasonable.                              |
+        |         |                                || highest_perf >= nominal_perf > lowest_nonlinear_perf > lowest_perf > 0.           |
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+        | 3       | amd_pstate_ut_check_freq       || Check if the each frequency values and max freq when set support boost mode       |
+        |         |                                | are reasonable.                                                                    |
+        |         |                                || max_freq >= nominal_freq > lowest_nonlinear_freq > min_freq > 0                   |
+        |         |                                || If boost is not active but supported, this maximum frequency will be larger than  |
+        |         |                                | the one in ``cpuinfo``.                                                            |
+        +---------+--------------------------------+------------------------------------------------------------------------------------+
+
+#. How to execute the tests
+
+   We use test module in the kselftest frameworks to implement it.
+   We create amd-pstate-ut module and tie it into kselftest.(for
+   details refer to Linux Kernel Selftests [4]_).

Documentation/admin-guide/pm/amd-pstate.rst about part of the output. :: · line 450

Quoted 10 lines
Documentation/admin-guide/pm/amd-pstate.rst +10 -0
+
+    1. Build
+
+        + open the :c:macro:`CONFIG_X86_AMD_PSTATE` configuration option.
+        + set the :c:macro:`CONFIG_X86_AMD_PSTATE_UT` configuration option to M.
+        + make project
+        + make selftest ::
+
+            jasminemeng@jasmine-meng:~/amd-brahma$ cd linux
+            jasminemeng@jasmine-meng:~/amd-brahma/linux$ make -C tools/testing/selftests

Remove the personal data (login etc.) from the above text

Documentation/admin-guide/pm/amd-pstate.rst about part of the output. :: · line 454

Quoted 4 lines
Documentation/admin-guide/pm/amd-pstate.rst +4 -0
+
+    #. Installation & Steps ::
+
+        jasmine@jasmine-meng:~/amd-brahma/linux$ make -C tools/testing/selftests install INSTALL_PATH=~/kselftest

Remove the personal data (login etc.) from the above text

Documentation/admin-guide/pm/amd-pstate.rst about part of the output. :: · line 455

Quoted 1 line
Documentation/admin-guide/pm/amd-pstate.rst +1 -0
+        jasmine@jasmine-meng:~$ sudo ./kselftest/run_kselftest.sh -c amd-pstate

Same here

Documentation/admin-guide/pm/amd-pstate.rst about part of the output. :: · line 464

Quoted 9 lines
Documentation/admin-guide/pm/amd-pstate.rst +9 -0
+        TAP version 13
+        1..1
+        # selftests: amd-pstate: amd-pstate-ut.sh
+        # amd-pstate-ut: ok
+        ok 1 selftests: amd-pstate: amd-pstate-ut.sh
+
+    #. Results ::
+
+         jasmine@jasmine-meng:~$ dmesg | grep "amd_pstate_ut" | tee log.txt

Same here

Quoted 9 lines
Documentation/admin-guide/pm/amd-pstate.rst +4 -0
+         [12977.570663] amd_pstate_ut: 1    amd_pstate_ut_acpi_cpc_valid  success!
+         [12977.570673] amd_pstate_ut: 2    amd_pstate_ut_check_enabled   success!
+         [12977.571207] amd_pstate_ut: 3    amd_pstate_ut_check_perf      success!
+         [12977.571212] amd_pstate_ut: 4    amd_pstate_ut_check_freq      success!
 
  Reference
  ===========

Documentation/admin-guide/pm/amd-pstate.rst Reference · line 483

Quoted 6 lines
Documentation/admin-guide/pm/amd-pstate.rst +3 -0
@@ -405,3 +478,6 @@ Reference
 
  .. [3] Processor Programming Reference (PPR) for AMD Family 19h Model 51h, Revision A1 Processors
         https://www.amd.com/system/files/TechDocs/56569-A1-PUB.zip
+
+.. [4] Linux Kernel Selftests,
+       https://www.kernel.org/doc/html/latest/dev-tools/kselftest.html

With the above changes:

thanks,
-- Shuah