Skip to contentSkip to conversation

high_freq_hwp_cap_cppc.c: new test for testing acpi_cppc/highest_perf

PATCH Superseded Piotr Kubaj 2 participants 2 messages Jun 10

v15 of 16 Superseded Latest is v16 →

lore
Share & tools
lore
#0 lore raw

PATCH v15 1/1 high_freq_hwp_cap_cppc.c: new test for testing acpi_cppc/highest_perf

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.

---
1. Sets the new needs_cpu_vendor tst_test field - still commented out, because the commit introducing this field is still not pushed. Please uncomment it when pushing.
2. Addresses review issues from the bot.
3. Drops mismatch[] array, which is now unnecessary.

 runtest/power_management_tests                |   1 +
 testcases/kernel/power_management/.gitignore  |   1 +
 .../power_management/high_freq_hwp_cap_cppc.c | 112 ++++++++++++++++++
 3 files changed, 114 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
index b670da6ec..4da57ee72 100644
@@ -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
new file mode 100644
index 000000000..03f0c83e4
@@ -0,0 +1 @@
+high_freq_hwp_cap_cppc
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c new file +112 -0

112 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
#1 lore raw

Hi Piotr,

testcases/kernel/power_management/high_freq_hwp_cap_cppc.c line 54

Quoted 8 lines · Piotr Kubaj

high_freq_hwp_cap_cppc.c: new test for testing acpi_cppc/highest_perf

testcases/kernel/power_management/high_freq_hwp_cap_cppc.c new file +6 -0
+static void run(void)
+{
+	bool status = true;
+	char path[PATH_MAX];
+
+	for (int i = 0; i < nproc; i++) {

The static mismatch array is zeroed once by SAFE_CALLOC in setup(), but run() only ever sets elements to 1 and never resets them. When the test is invoked with -i N, stale entries from a previous iteration survive into the next one.

For example, if CPU 2 mismatches on iteration 1 but matches on iteration 2, the summary loop still prints "cpu2: MISMATCH" while the verdict says TPASS. Adding a memset at the top of run() would fix it:

    memset(mismatch, 0, nproc * sizeof(int));

testcases/kernel/power_management/high_freq_hwp_cap_cppc.c line 85

Quoted 6 lines
testcases/kernel/power_management/high_freq_hwp_cap_cppc.c new file +6 -0
+		if (msr_highest_perf != sysfs_highest_perf) {
+			tst_res(TINFO, "cpu%d: sysfs=%llu MSR=%llu",
+				i, sysfs_highest_perf, msr_highest_perf);
+			mismatch[i] = 1;
+			status = false;
+		}

Per-CPU mismatches are reported with TINFO and the actual TFAIL is deferred to the end of run() via the status flag. LTP convention is to report results directly where they are determined. Could the mismatch be reported as TFAIL inline (dropping the status flag and the mismatch array), with TPASS emitted at the end only when no mismatch was found?

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