[PATCH 0/9] libnvme: add support for retrieving additional NVMe stat

Nilay Shroff nilay at linux.ibm.com
Sat Mar 21 08:27:59 PDT 2026


Hi,

Certain NVMe attributes and statistics can change dynamically at runtime.
However, the current libnvme implementation caches attribute values while
scanning and building the topology. Subsequent libnvme API calls return
these cached values.

While this approach works well for one-shot nvme-cli commands, it is not
suitable for use cases that require upto date information. In particular,
real-time monitoring tools such as nvme-top require access to the latest
(non-cached) values of such attributes.

To address this, this patchset introduces support for retrieving
non-cached values for selected attributes whose values may change
dynamically. The first three patches disable auto-generated accessors
for ana_state, numa_nodes, and iopolicy using "!accessors:none", and
provide custom implementations that always return the latest values.

In addition, libnvme lacks support for retrieving gendisk statistics, which
provide useful insight into disk activity (e.g., number of I/Os processed,
time spent servicing I/O, and in-flight I/O counts). This patchset adds
support for retrieving gendisk I/O statistics for both per-path and namespace
gendisks.

Finally, this series adds support for retrieving diagnostic counters at 
different levels, including per-path, namespace, nshead, and controller.
These counters should improve visibility into NVMe native multipath behavior.

All of the above statistics and counters can be leveraged by tools such as
nvme-top to provide real-time monitoring and analysis.

As usual, feedback and suggestions are welcome!

Nilay Shroff (9):
  libnvme: annotate nvme_path::ana_state with !accessors:none
  libnvme: annotate nvme_path::numa_nodes with !accessors:none
  libnvme: annotate nvme_subsystem::iopolicy with !accessors:none
  libnvme: add support for retrieving per-path gendisk I/O statistics
  libnvme: add support for retrieving namespace gendisk I/O statistics
  libnvme: add support for per-path diagnostic counters
  libnvme: add support for namespace diagnostic counters
  libnvme: add support for nshead diagnostic counters
  libnvme: add support for ctrl diagnostic counters

 libnvme/src/accessors.ld     |   6 -
 libnvme/src/libnvme.ld       |  36 +++
 libnvme/src/nvme/accessors.c |  39 ---
 libnvme/src/nvme/accessors.h |  47 ---
 libnvme/src/nvme/private.h   |  46 ++-
 libnvme/src/nvme/tree.c      | 551 +++++++++++++++++++++++++++++++++++
 libnvme/src/nvme/tree.h      | 314 ++++++++++++++++++++
 7 files changed, 944 insertions(+), 95 deletions(-)

-- 
2.53.0




More information about the Linux-nvme mailing list