[PATCH v2 0/3] perf pmu: Add tool-provided NVMe PMU

Ian Rogers irogers at google.com
Tue Jun 9 09:57:23 PDT 2026


This patch series introduces a tool-provided PMU for NVMe devices to expose
various hardware logs as perf events.

Using libnvme, the new nvme_pmu extracts metrics from standard NVMe log pages
including:
- SMART / Health Information (e.g. data units read/written, power cycles,
  temperature)
- Endurance Group Information
- FDP (Flexible Data Placement) Statistics
- Error Information
- Zoned Namespaces (ZNS) Changed Zones

Changes in v2:
- Fixed feature check: added test-libnvme.c to test-all.c to correctly
  propagate fast-path discovery failures.
- Makefile cleanup: added libnvme to FEATURE_PKG_CONFIG in Makefile.feature
  to ensure correct pkg-config flags are used during feature testing.
- Alignment safety: replaced strict-aliasing pointers with get_unaligned_le*
  accessors inside nvme_pmu__read_val() to prevent crashes on strict-alignment
  architectures.
- Heap safety: refactored evsel delta snapshots to use a new 'nvme' union
  member inside struct evsel instead of clashing with evsel->priv, preventing
  memory leaks and heap corruption with active tools like perf script.

Ian Rogers (3):
  perf build: Add libnvme feature detection
  perf pmu: Implement tool-provided NVMe PMU
  perf tests: Add NVMe PMU event parsing test

 tools/build/Makefile.feature       |   5 +-
 tools/build/feature/Makefile       |   3 +
 tools/build/feature/test-all.c     |   5 +
 tools/build/feature/test-libnvme.c |  11 +
 tools/perf/Makefile.config         |  12 +
 tools/perf/tests/Build             |   1 +
 tools/perf/tests/builtin-test.c    |   1 +
 tools/perf/tests/nvme_pmu.c        | 176 ++++++++++
 tools/perf/tests/tests.h           |   1 +
 tools/perf/util/Build              |   1 +
 tools/perf/util/evsel.c            |  13 +-
 tools/perf/util/evsel.h            |   4 +
 tools/perf/util/nvme_pmu.c         | 537 +++++++++++++++++++++++++++++
 tools/perf/util/nvme_pmu.h         | 143 ++++++++
 tools/perf/util/pmu.c              |  15 +
 tools/perf/util/pmu.h              |   8 +-
 tools/perf/util/pmus.c             |  31 +-
 tools/perf/util/pmus.h             |   1 +
 18 files changed, 960 insertions(+), 8 deletions(-)
 create mode 100644 tools/build/feature/test-libnvme.c
 create mode 100644 tools/perf/tests/nvme_pmu.c
 create mode 100644 tools/perf/util/nvme_pmu.c
 create mode 100644 tools/perf/util/nvme_pmu.h

-- 
2.54.0.1099.g489fc7bff1-goog




More information about the Linux-nvme mailing list