Skip to contentSkip to conversation

Add unit test module for AMD P-State driver

PATCH Superseded Meng Li 2 participants 6 messages Apr 21, 2022 – Apr 22, 2022

Subsystems (4)

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore

Meng Li

author
#0 lore raw

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

Hi all:

AMD P-State unit test(amd_pstate_testmod) 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_testmod 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 a rst document.
2) we will add more test cases to improve the depth and coverage of the test.

See patch series in below git repo:
V1: https://lore.kernel.org/linux-pm/[email protected]/
V2: 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.

Thanks,
Jasmine

Meng Li (3):
cpufreq: amd-pstate: Expose struct amd_cpudata
selftests: cpufreq: Add wapper script for test AMD P-State
selftests: cpufreq: Add amd_pstate_testmod kernel module for testing

 MAINTAINERS                                   |   1 +
 drivers/cpufreq/amd-pstate.c                  |  60 +---
 include/linux/amd-pstate.h                    |  77 ++++
 .../selftests/cpufreq/amd_pstate_testmod.sh   |   4 +
 .../cpufreq/amd_pstate_testmod/Makefile       |  20 ++
 .../amd_pstate_testmod/amd_pstate_testmod.c   | 329 ++++++++++++++++++
 tools/testing/selftests/cpufreq/config        |   1 +
 tools/testing/selftests/cpufreq/main.sh       |   1 +
 8 files changed, 434 insertions(+), 59 deletions(-)
 create mode 100644 include/linux/amd-pstate.h
 create mode 100755 tools/testing/selftests/cpufreq/amd_pstate_testmod.sh
 create mode 100644 tools/testing/selftests/cpufreq/amd_pstate_testmod/Makefile
 create mode 100644 tools/testing/selftests/cpufreq/amd_pstate_testmod/amd_pstate_testmod.c
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH v3 1/3 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_testmod) module. The amd_pstate_testmod 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 61d9f114c37f..6f814eda95b5 100644
@@ -1020,6 +1020,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
author
#2 lore raw

PATCH v3 2/3 selftests: cpufreq: Add wapper script for test AMD P-State

In reply to Meng Li

Adds a wrapper shell script for the amd_pstate_testmod module.

---
 tools/testing/selftests/cpufreq/amd_pstate_testmod.sh | 4 ++++
 tools/testing/selftests/cpufreq/config                | 1 +
 tools/testing/selftests/cpufreq/main.sh               | 1 +
 3 files changed, 6 insertions(+)
 create mode 100755 tools/testing/selftests/cpufreq/amd_pstate_testmod.sh
tools/testing/selftests/cpufreq/amd_pstate_testmod.sh new file +4 -0
new file mode 100755
index 000000000000..5398ad568885
@@ -0,0 +1,4 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# Tests the AMD P-State unit test infrastructure using amd_pstate_testmod kernel module.
+$(dirname $0)/../kselftest/module.sh "amd_pstate_testmod" amd_pstate_testmod
tools/testing/selftests/cpufreq/config +1 -0
index 75e900793e8a..374a8adbb34c 100644
@@ -13,3 +13,4 @@ CONFIG_DEBUG_LOCK_ALLOC=y
 CONFIG_PROVE_LOCKING=y
 CONFIG_LOCKDEP=y
 CONFIG_DEBUG_ATOMIC_SLEEP=y
+CONFIG_AMD_PSTATE_TESTMOD=m
tools/testing/selftests/cpufreq/main.sh +1 -0
index 60ce18ed0666..d3602fa11392 100755
@@ -6,6 +6,7 @@ source cpufreq.sh
 source governor.sh
 source module.sh
 source special-tests.sh
+source amd_pstate_testmod.sh
 
 FUNC=basic	# do basic tests by default
 OUTFILE=cpufreq_selftest
Signature · 1 line
2.25.1
maintainer
#3 lore raw

Re: [PATCH V3 2/3] selftests: cpufreq: Add wapper script for test AMD P-State

Quoted 16 lines · Meng Li

Adds a wrapper shell script for the amd_pstate_testmod module.

---
  tools/testing/selftests/cpufreq/amd_pstate_testmod.sh | 4 ++++
  tools/testing/selftests/cpufreq/config                | 1 +
  tools/testing/selftests/cpufreq/main.sh               | 1 +
  3 files changed, 6 insertions(+)

create mode 100755 tools/testing/selftests/cpufreq/amd_pstate_testmod.sh

tools/testing/selftests/cpufreq/amd_pstate_testmod.sh new file +0 -0
new file mode 100755
index 000000000000..5398ad568885

tools/testing/selftests/cpufreq/amd_pstate_testmod.sh line 4

Quoted 4 lines
tools/testing/selftests/cpufreq/amd_pstate_testmod.sh new file +4 -0
@@ -0,0 +1,4 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# Tests the AMD P-State unit test infrastructure using amd_pstate_testmod kernel module.
+$(dirname $0)/../kselftest/module.sh "amd_pstate_testmod" amd_pstate_testmod

The script could load the module and unload once the test is complete.

Quoted 14 lines
tools/testing/selftests/cpufreq/config +1 -0
index 75e900793e8a..374a8adbb34c 100644
@@ -13,3 +13,4 @@ CONFIG_DEBUG_LOCK_ALLOC=y
  CONFIG_PROVE_LOCKING=y
  CONFIG_LOCKDEP=y
  CONFIG_DEBUG_ATOMIC_SLEEP=y
+CONFIG_AMD_PSTATE_TESTMOD=m
tools/testing/selftests/cpufreq/main.sh +0 -0
index 60ce18ed0666..d3602fa11392 100755

tools/testing/selftests/cpufreq/main.sh source cpufreq.sh · line 10

Quoted 5 lines
tools/testing/selftests/cpufreq/main.sh +1 -0
@@ -6,6 +6,7 @@ source cpufreq.sh
  source governor.sh
  source module.sh
  source special-tests.sh
+source amd_pstate_testmod.sh
 

Does the script check if the test module is loaded and bail out? I don't see the check for CONFIG_AMD_PSTATE_TESTMOD enable and module load.

tools/testing/selftests/cpufreq/main.sh source cpufreq.sh · line 12

Quoted 3 lines
tools/testing/selftests/cpufreq/main.sh +0 -0
  FUNC=basic	# do basic tests by default
  OUTFILE=cpufreq_selftest

thanks,
-- Shuah

author
#4 lore raw

PATCH v3 3/3 selftests: cpufreq: Add amd_pstate_testmod kernel module for testing

In reply to Meng Li

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

---
 .../cpufreq/amd_pstate_testmod/Makefile       |  20 ++
 .../amd_pstate_testmod/amd_pstate_testmod.c   | 329 ++++++++++++++++++
 2 files changed, 349 insertions(+)
 create mode 100644 tools/testing/selftests/cpufreq/amd_pstate_testmod/Makefile
 create mode 100644 tools/testing/selftests/cpufreq/amd_pstate_testmod/amd_pstate_testmod.c
tools/testing/selftests/cpufreq/amd_pstate_testmod/Makefile new file +20 -0
new file mode 100644
index 000000000000..8a5596cb2c18
@@ -0,0 +1,20 @@
+AMD_PSTATE_TESTMOD_DIR := $(realpath $(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
+KDIR ?= $(abspath $(AMD_PSATE_TESTMOD_DIR)/../../../../..)
+
+ifeq ($(V),1)
+Q =
+else
+Q = @
+endif
+
+MODULES = amd_pstate_testmod.ko
+
+obj-m += amd_pstate_testmod.o
+CFLAGS_amd_pstate_testmod.o = -I$(src)
+
+all:
+	+$(Q)make -C $(KDIR) M=$(AMD_PSTATE_TESTMOD_DIR) modules
+
+clean:
+	+$(Q)make -C $(KDIR) M=$(AMD_PSTATE_TESTMOD_DIR) clean
+
tools/testing/selftests/cpufreq/amd_pstate_testmod/amd_pstate_testmod.c new file +329 -0

329 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#5 lore raw
In reply to Meng Li
Quoted 24 lines · Meng Li

Hi all:

AMD P-State unit test(amd_pstate_testmod) 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_testmod 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.

Quoted 4 lines

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

TODO : 1) we will add a rst document.

Please include document in this series and describe how the test can be run. It is not clear to me how use should go about running this test especially since the script depends on a test module which will need to be compiled and loaded.

I would like to see clear details in the document on the steps involved in running the test.

Quoted 3 lines

2) we will add more test cases to improve the depth and coverage of the test.

thanks,
-- Shuah