high_freq_hwp_cap_cppc.c: new test
PATCH v14 1/1 high_freq_hwp_cap_cppc.c: new test
Verify for all online logical CPUs that their highest performance value are the same for HWP Capability MSR 0x771 and CPPC sysfs file.
On HWP-capable x86 platforms the acpi_cppc/highest_perf sysfs attribute is expected to reflect the same highest-performance value that firmware programs into the HWP Capabilities MSR (0x771, bits 7:0). A mismatch between the two interfaces indicates a kernel regression in how CPPC values are exposed to userspace, and would break tools (e.g. cpupower, intel_pstate tuning scripts) that rely on the sysfs interface to make frequency-scaling decisions.
The test is valid only for Intel platforms.
---
The new version checks the CPU vendor and only runs on Intel.
runtest/power_management_tests | 1 + testcases/kernel/power_management/.gitignore | 1 + .../power_management/high_freq_hwp_cap_cppc.c | 133 ++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 testcases/kernel/power_management/.gitignore create mode 100644 testcases/kernel/power_management/high_freq_hwp_cap_cppc.c
runtest/power_management_tests +1 -0
@@ -1,4 +1,5 @@ #POWER_MANAGEMENT +high_freq_hwp_cap_cppc high_freq_hwp_cap_cppc runpwtests03 runpwtests03.sh runpwtests04 runpwtests04.sh runpwtests06 runpwtests06.sh
testcases/kernel/power_management/.gitignore new file +1 -0
@@ -0,0 +1 @@ +high_freq_hwp_cap_cppc
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c new file +133 -0
133 lines not on this page · raw message
Signature · 13 lines
2.47.3 --------------------------------------------------------------------- Intel Technology Poland sp. z o.o. ul. Slowackiego 173 | 80-298 Gdansk | Sad Rejonowy Gdansk Polnoc | VII Wydzial Gospodarczy Krajowego Rejestru Sadowego - KRS 101882 | NIP 957-07-52-316 | Kapital zakladowy 200.000 PLN. Spolka oswiadcza, ze posiada status duzego przedsiebiorcy w rozumieniu ustawy z dnia 8 marca 2013 r. o przeciwdzialaniu nadmiernym opoznieniom w transakcjach handlowych. Ta wiadomosc wraz z zalacznikami jest przeznaczona dla okreslonego adresata i moze zawierac informacje poufne. W razie przypadkowego otrzymania tej wiadomosci, prosimy o powiadomienie nadawcy oraz trwale jej usuniecie; jakiekolwiek przegladanie lub rozpowszechnianie jest zabronione. This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited. -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Piotr,
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c line 21
Quoted 5 lines · Piotr Kubaj
high_freq_hwp_cap_cppc.c: new testtestcases/kernel/power_management/high_freq_hwp_cap_cppc.c new file +3
-0+#include "tst_test.h" +#include "tst_safe_prw.h" +#include "lapi/cpuid.h"
lapi/cpuid.h contains #error on non-x86 architectures and __cpuid_count uses x86 inline assembly, so this file will not compile on ARM, s390x, etc.
Ground rule 6 requires architecture-specific tests to still compile everywhere. The existing ptrace07.c shows the correct pattern:
wrap the entire file body in
#if defined(__i386__) || defined(__x86_64__) with a TST_TEST_TCONF("test requires x86") in the #else branch.
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c line 110
Quoted 2 lines
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c new file +2
-0+for (int i =0 ; i < nproc; i++) +tst_res (TINFO ,"cpu%d: %s" , i, mismatch[i] ?"MISMATCH" :"OK" );
Offline CPUs are skipped during the comparison loop but the summary still prints "OK" for them (mismatch[i] is zero from memset). This is misleading -- "OK" implies the values matched when no check was performed. Consider skipping offline CPUs here too, or printing "OFFLINE" instead.
Quoted 3 lines
+/*\
+ * Verify for all online logical CPUs that their highest performance value are
+ * the same for HWP Capability MSR0x771and CPPC sysfs file.
The test sets .needs_root = 1 but the doc comment does not explain why root is required. Per the LTP guidelines, the reason should be stated (reading /dev/cpu/N/msr needs CAP_SYS_RAWIO / root).
Verdict: Needs revision
---
Note:
The agent can sometimes produce false positives although often its findings are genuine. If you find issues with the review, please comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 10 lines · Piotr Kubaj
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c line 21
Quoted 5 lines
high_freq_hwp_cap_cppc.c: new testtestcases/kernel/power_management/high_freq_hwp_cap_cppc.c new file +3
-0+#include "tst_test.h" +#include "tst_safe_prw.h" +#include "lapi/cpuid.h"
lapi/cpuid.hcontains #error on non-x86 architectures and__cpuid_countuses x86 inline assembly, so this file will not compile on ARM, s390x, etc.
I think that more generic solution is to add the functionality into the test library. Let me draft a patch.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c line 44
Quoted 8 lines
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c new file +8
-0+static void setup (void ) +{ +unsigned int eax, ebx, ecx, edx; + +__cpuid_count (0 ,0 , eax, ebx, ecx, edx); +if (ebx !=CPUID_VENDOR_EBX || edx !=CPUID_VENDOR_EDX || + ecx !=CPUID_VENDOR_ECX ) +tst_brk (TCONF ,"not a GenuineIntel CPU" );
I've send a patch for the tst_test structure that adds .needs_cpu_vendor field. If that gets merged you can just set it to "GenuineIntel" and the test should be automatically skipped on anything but Intel CPUs.
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c line 48
Quoted 3 lines
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c new file +3
-0+__cpuid_count (CPUID_LEAF_THERMAL ,0 , eax, ebx, ecx, edx); +if (!(eax &CPUID_HWP_BIT )) +tst_brk (TCONF ,"HWP not supported (MSR 0x771 unavailable)" );
This specific check still needs to be ifdefed around with x86 and x86_64 macros.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Piotr,
this patch is failing to build on Debian Stable (ppc64el, arm64, s390x):
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Please fix the patch-set and send a new version.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp