Skip to contentSkip to conversation

pmc_core: add test for pkgc_blocker_residency_show

PATCH Superseded Piotr Kubaj 3 participants 4 messages Aug 13

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 is a PKGC_BLOCK_RESIDENCY_<SOURCE> token followed by exactly one unsigned value that fits in u32, 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. Because the bound scales with the measured interval, what it limits is the fraction of that interval a source spent blocking, so it holds regardless of how long the sample took.

An unchanged counter is not a failure. Most sources are idle and read 0 permanently; on the test system 22 of 28 counters never moved. The counters are backed by a PMT telemetry region that the PMC refreshes asynchronously, at roughly 1s granularity on Nova Lake, so the second sample is retried with an exponential backoff until it observes a refresh rather than being taken after a fixed sleep. The retries are capped at 2s, after which a sample that saw no change at all is reported as every source being idle. In practice the test finishes in 0.1s to 1.1s. 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. Root is needed because /sys/kernel/debug is mode 0700 and owned by root, so the counter file cannot be opened otherwise. 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 over 30 runs, with the worst observed advance at 23% of the bound. Fault injection against a stub file confirms the test detects a counter reset, an out-of-range jump, a signed value, a trailing token, a bare prefix with no source, a value too large for u32, a non-numeric value, a renamed counter, a changed counter count 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             | 269 ++++++++++++++++++
 3 files changed, 271 insertions(+)
 create mode 100644 testcases/kernel/power_management/pkgc_blocker_residency_show.c
runtest/power_management_tests +1 -0
index 5a22283d6..a3c7cab5e 100644
@@ -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
index 766f07901..4dd1fc329 100644
@@ -1,3 +1,4 @@
 high_freq_hwp_cap_cppc
 cpufreq_intel
+pkgc_blocker_residency_show
 rfim01
testcases/kernel/power_management/pkgc_blocker_residency_show.c new file +269 -0

269 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,

the commit message is still not following the request I made in the previous version. Please send a proper version, this one is rejected.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

W dniu czw, 13.08.2026 o godzinie 09∶48 +0000, użytkownik Andrea

Quoted 11 lines · Cervesato

Hi Piotr,

the commit message is still not following the request I made in the previous version. Please send a proper version, this one is rejected.

Regards,
--
Andrea Cervesato
SUSE QE Automation Engineer Linux
[email protected]

Sorry, I started rewriting the test case yesterday according to the
review and sent it today, but only just now have noticed your reply.
---------------------------------------------------------------------
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.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
In reply to Piotr Kubaj

Hi Piotr,

testcases/kernel/power_management/pkgc_blocker_residency_show.c line 168

Quoted 10 lines · Piotr Kubaj

pmc_core: add test for pkgc_blocker_residency_show

testcases/kernel/power_management/pkgc_blocker_residency_show.c new file +8 -0
+static void setup(void)
+{
+	if (access(DEBUGFS, F_OK))
+		tst_brk(TCONF | TERRNO, "debugfs not mounted at " DEBUGFS);
+
+	if (access(PATH, R_OK))
+		tst_brk(TCONF | TERRNO, "%s not available", PATH);
+}

Could the test mount debugfs when it is not already mounted, and unmount only a test-created mount in cleanup?

On a supported Nova Lake system with debugfs unmounted, /sys/kernel/debug still exists as the mount-point directory. The first check therefore succeeds, and the missing counter path makes the test report TCONF without testing the supported interface.

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