[LTP] [PATCH 0/3] pmc_core: cover the PkgC LTR blocker counters

Piotr Kubaj piotr.kubaj@intel.com
Fri Sep 4 14:40:39 CEST 2026


The intel_pmc_core driver gained a pkgc_ltr_blocker_show debugfs file in
kernel commit 38c79dd63b72 ("platform/x86/intel/pmc: Enable PkgC LTR
blocking counter"), first released in v7.2, and nothing covers it yet.
It reports, per source, how many times an LTR posted by that source
blocked a package C-state entry.

Both tests added here need debugfs mounted, so the first patch moves the
mount handling into the test library instead of open coding it twice.

1/3 adds tst_test.needs_debugfs: the library mounts debugfs at
    /sys/kernel/debug during setup unless it is mounted there already,
    reports TCONF if it cannot, and unmounts it afterwards only if it did
    the mount. A lib/newlib_tests self-test covers both cases. Tests
    reading any other debugfs file can use it as well.

2/3 checks what the file says: every line is a PKGC_PREVENT_LTR_<SOURCE>
    token followed by one u32 value, the file reads to EOF rather than
    erroring out mid-way, the counter set is stable across two reads, and
    no counter advances by more entries than the package could have
    attempted over the interval.

3/3 checks the invariant behind the counters: a package C-state entry is
    only attempted once every CPU in the package is idle, so counters
    that keep advancing with every CPU busy are not counting blocked
    entries. The test proves the counters are alive while idling first,
    so that a counter stuck at a constant value cannot pass for free.

Both tests bound what they accept in time rather than against a hardcoded
counter list, because the counter set is platform specific. That is what
catches a telemetry region read at the wrong offset, which overshoots the
bounds by orders of magnitude.

Tested on Nova Lake running 7.3.0-rc1, with debugfs both mounted and
unmounted beforehand, and in the latter case the mount state is restored
after the run. The TFAIL and TCONF paths were exercised against fake
counter files.

Piotr Kubaj (3):
  lib: add tst_test.needs_debugfs flag
  pmc_core: add test for pkgc_ltr_blocker_show
  pmc_core: add ltr_counter test

 doc/developers/writing_tests.rst              |   3 +
 include/tst_fs.h                              |   4 +
 include/tst_test.h                            |   8 +
 lib/newlib_tests/.gitignore                   |   1 +
 lib/newlib_tests/runtest.sh                   |   1 +
 lib/newlib_tests/tst_needs_debugfs.c          |  37 ++
 lib/tst_test.c                                |  35 ++
 metadata/metaparse.c                          |   1 +
 runtest/power_management_tests                |   2 +
 testcases/kernel/power_management/.gitignore  |   2 +
 .../kernel/power_management/ltr_counter.c     | 355 ++++++++++++++++++
 .../power_management/pkgc_ltr_blocker_show.c  | 294 +++++++++++++++
 12 files changed, 743 insertions(+)
 create mode 100644 lib/newlib_tests/tst_needs_debugfs.c
 create mode 100644 testcases/kernel/power_management/ltr_counter.c
 create mode 100644 testcases/kernel/power_management/pkgc_ltr_blocker_show.c


base-commit: 82568ba8fad0120a9305f7a263ddb6d9d74c4f61
-- 
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.



More information about the ltp mailing list