pmc_core: add test for pkgc_blocker_residency_show
PATCH 1/1 pmc_core: add test for pkgc_blocker_residency_show
Add a test for the /sys/kernel/debug/pmc_core/pkgc_blocker_residency_show interface added in kernel commit d727eb1c3ede ("platform/x86/intel/pmc:
Enable Pkgc blocking residency counter"), first released in v7.2.
The debugfs file reports per-source counters tracking which sources kept the platform out of package C-states. The driver prints one line per counter as "%-30s %-30u", where the name is a PKGC_BLOCK_RESIDENCY_<SOURCE> token and the value counts the 10us intervals during which that source blocked a package C-state entry.
The counter set is platform specific, so rather than checking a hardcoded list the test samples the file twice and verifies that every line names a PKGC_BLOCK_RESIDENCY_ source with a numeric value, that the set of counters is stable across the two reads, and that no counter advanced by more than the elapsed wall clock time allows.
The last check is what catches real breakage. The values are u32 counting 10us intervals, so a busy source wraps in well under a day: on Nova Lake, PKGC_BLOCK_RESIDENCY_PMC_LTR advances fast enough to wrap roughly every 15 hours. The delta is therefore computed modulo 2^32, which tolerates a genuine wrap while turning a counter reset or backward jump into a large advance that the elapsed-time bound rejects. A telemetry region read at the wrong offset shows up the same way. At the 2s sample interval the bound admits about 0.01% of the u32 value space.
An unchanged counter is not a failure. Most sources are idle and read 0 permanently; on the test system 21 of 28 counters never moved. The sample interval is 2s because the PMT telemetry region refreshes at roughly 1s granularity - no counter moved over a 200ms or 500ms interval, so a shorter sample would make every counter look static. The plausibility bound allows a factor of two over the theoretical maximum, since a busy source can run close to it: PMC_LTR was observed at 76% of the ceiling.
The debugfs file is only created for a PMC exposing a package C-state telemetry endpoint (pc_guid in the driver's pmc_dev_info), which currently means Nova Lake only. Other platforms report TCONF.
Requires CONFIG_INTEL_PMC_CORE and CONFIG_DEBUG_FS, needs root, and is restricted to x86/x86_64 on GenuineIntel. The vendor check is redundant with the kconfig and debugfs checks, but it is evaluated first and so reports the actual reason rather than a missing debugfs file.
Tested on Nova Lake running 7.2.0-rc7: 28 counters reported, TPASS. Fault injection against a stub file confirms the test detects a counter reset, an out-of-range jump, a malformed line, an unexpected counter name and an empty file, while still accepting a genuine u32 wrap.
--- runtest/power_management_tests | 1 + testcases/kernel/power_management/.gitignore | 1 + .../pkgc_blocker_residency_show.c | 211 ++++++++++++++++++ 3 files changed, 213 insertions(+) create mode 100644 testcases/kernel/power_management/pkgc_blocker_residency_show.c
runtest/power_management_tests +1 -0
@@ -2,6 +2,7 @@ cpufreq_intel cpufreq_intel rfim01 rfim01 high_freq_hwp_cap_cppc high_freq_hwp_cap_cppc +pkgc_blocker_residency_show pkgc_blocker_residency_show runpwtests03 runpwtests03.sh runpwtests04 runpwtests04.sh runpwtests06 runpwtests06.sh
testcases/kernel/power_management/.gitignore +1 -0
@@ -1,3 +1,4 @@ high_freq_hwp_cap_cppc cpufreq_intel rfim01 +pkgc_blocker_residency_show
testcases/kernel/power_management/pkgc_blocker_residency_show.c new file +211 -0
211 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,
Quoted 11 lines · Piotr Kubaj
pmc_core: add test forpkgc_blocker_residency_show/* * Interval between the two samples. The PMT telemetry region behind these * counters refreshes at roughly 1s granularity: measured on Nova Lake, no * counter moved over 200ms or 500ms, while 5 of 28 moved over 1s. Sample well * past that so a static counter means "idle source", not "not refreshed yet". */ #define SAMPLE_DELAY_US 2000000 ... usleep(SAMPLE_DELAY_US);
Could this use bounded exponential-backoff polling instead? The fixed sleep is being used to synchronize the second sample with the asynchronous telemetry refresh, which violates the no sleep-based synchronization rule.
Quoted 6 lines
if (sscanf(line, "%63s %u", name, &value) != 2) {
tst_res(TFAIL, "malformed counter line: '%s'", line);
continue;
}
if (strncmp(name, PREFIX, sizeof(PREFIX) - 1)) {Could this validate the complete line and require a nonempty source suffix? The current conversion accepts signed values, trailing tokens, and the bare name "PKGC_BLOCK_RESIDENCY_". If both snapshots contain such a line, it is recorded as a valid counter and the test can pass despite malformed output.
Quoted 1 line
.needs_root = 1,
Could the high-level description explain why root is required? Tests setting needs_root must document the reason in the exported test description.
Quoted 4 lines
high_freq_hwp_cap_cppc
cpufreq_intel
rfim01
+pkgc_blocker_residency_show
Could the new entry be inserted alphabetically? Leaf .gitignore entries are required to remain sorted.
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 Piotr,
Quoted 49 lines
Hi Piotr,
Quoted 11 lines · Piotr Kubaj
pmc_core: add test forpkgc_blocker_residency_show/* * Interval between the two samples. The PMT telemetry region behind these * counters refreshes at roughly 1s granularity: measured on Nova Lake, no * counter moved over 200ms or 500ms, while 5 of 28 moved over 1s. Sample well * past that so a static counter means "idle source", not "not refreshed yet". */ #define SAMPLE_DELAY_US 2000000 ... usleep(SAMPLE_DELAY_US);Could this use bounded exponential-backoff polling instead? The fixed sleep is being used to synchronize the second sample with the asynchronous telemetry refresh, which violates the no sleep-based synchronization rule.
Quoted 6 lines
if (sscanf(line, "%63s %u", name, &value) != 2) { tst_res(TFAIL, "malformed counter line: '%s'", line); continue; } if (strncmp(name, PREFIX, sizeof(PREFIX) - 1)) {Could this validate the complete line and require a nonempty source suffix? The current conversion accepts signed values, trailing tokens, and the bare name "
PKGC_BLOCK_RESIDENCY_". If both snapshots contain such a line, it is recorded as a valid counter and the test can pass despite malformed output.Quoted 1 line
.needs_root = 1,Could the high-level description explain why root is required? Tests setting
needs_rootmust document the reason in the exported test description.Quoted 4 lines
high_freq_hwp_cap_cppc
cpufreq_intel
rfim01
+pkgc_blocker_residency_showCould the new entry be inserted alphabetically? Leaf .gitignore entries are required to remain sorted.
Verdict - Needs revision
---
Note:
Quoted 9 lines
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 ReviewerSignature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
the review is correct. Please send v2
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Piotr,
please keep the commit message straight to the point, without adding too many information. It's basically describing the full algorithm in details, while we already have it in the code and description. We need to understand _why_ commit was made at the very first look.
Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp