libnvme: add support for retrieving additional NVMe stat
cover libnvme: add support for retrieving additional NVMe stat
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(-)
Signature · 1 line
2.53.0
PATCH 1/9 libnvme: annotate nvme_path::ana_state with !accessors:none
The default accessor generation creates getters that return cached attribute values. However, for nvme_path::ana_state, a real-time (non-cached) value is required.
This is particularly useful for tools such as nvme-top, which rely on up-to-date information for displaying a real-time dashboard.
Annotate nvme_path::ana_state with "!accessors:none" to disable the auto-generated accessor, and provide a custom implementation of nvme_path_get_ana_state() that returns the current value.
--- libnvme/src/accessors.ld | 2 -- libnvme/src/libnvme.ld | 1 + libnvme/src/nvme/accessors.c | 13 ------------- libnvme/src/nvme/accessors.h | 15 --------------- libnvme/src/nvme/private.h | 2 +- libnvme/src/nvme/tree.c | 16 ++++++++++++++++ libnvme/src/nvme/tree.h | 8 ++++++++ 7 files changed, 26 insertions(+), 31 deletions(-)
libnvme/src/accessors.ld +0 -2
@@ -14,8 +14,6 @@ LIBNVME_ACCESSORS_3 { nvme_path_set_name; nvme_path_get_sysfs_dir; nvme_path_set_sysfs_dir; - nvme_path_get_ana_state; - nvme_path_set_ana_state; nvme_path_get_numa_nodes; nvme_path_set_numa_nodes; nvme_path_get_grpid;
libnvme/src/libnvme.ld +1 -0
@@ -142,6 +142,7 @@ LIBNVME_3 { nvme_path_get_ctrl; nvme_path_get_ns; nvme_path_get_queue_depth; + nvme_path_get_ana_state; nvme_filter_paths; nvme_read_config; nvme_read_key;
libnvme/src/nvme/accessors.c +0 -13
@@ -52,19 +52,6 @@ __public const char *nvme_path_get_sysfs_dir(const struct nvme_path *p)return p->sysfs_dir; } -__public void nvme_path_set_ana_state( -struct nvme_path *p, -const char *ana_state) -{ -free (p->ana_state); - p->ana_state = ana_state ?strdup (ana_state) :NULL ; -} - -__public const char *nvme_path_get_ana_state(const struct nvme_path *p) -{ -return p->ana_state; -} - __public void nvme_path_set_numa_nodes(struct nvme_path *p,const char *numa_nodes)
libnvme/src/nvme/accessors.h +0 -15
@@ -68,21 +68,6 @@ void nvme_path_set_sysfs_dir(struct nvme_path *p, const char *sysfs_dir);*/ const char *nvme_path_get_sysfs_dir (const struct nvme_path *p); -/** -* nvme_path_set_ana_state() - Set ana_state. -* @p: The &struct nvme_path instance to update. -* @ana_state: New string; a copy is stored. Pass NULL to clear. -*/ -void nvme_path_set_ana_state (struct nvme_path *p,const char *ana_state); - -/** -* nvme_path_get_ana_state() - Get ana_state. -* @p: The &struct nvme_path instance to query. -* -* Return: The value of the ana_state field, or NULL if not set. -*/ -const char *nvme_path_get_ana_state (const struct nvme_path *p); -/** * nvme_path_set_numa_nodes() - Set numa_nodes. * @p: The &struct nvme_path instance to update.
libnvme/src/nvme/private.h +1 -1
@@ -137,8 +137,8 @@ struct nvme_path { /*!generate-accessors*/char *name;char *sysfs_dir; -char *ana_state;char *numa_nodes; +char *ana_state;//!accessors:none int grpid;int queue_depth;//!accessors:none };
libnvme/src/nvme/tree.c +16 -0
@@ -804,6 +804,22 @@ __public int nvme_path_get_queue_depth(nvme_path_t p)return p->queue_depth; } +__public char *nvme_path_get_ana_state(nvme_path_t p) +{ + _cleanup_free_ char *ana_state = NULL; + + ana_state =nvme_get_path_attr (p,"ana_state" ); +if (ana_state) { +if (!p->ana_state ||strcmp (ana_state, p->ana_state)) { +free (p->ana_state); + p->ana_state =strdup (ana_state); + + } + } + +return p->ana_state; +} +void nvme_free_path (struct nvme_path *p) {list_del_init (&p->entry);
libnvme/src/nvme/tree.h +8 -0
@@ -679,6 +679,14 @@ int nvme_ns_identify_descs(nvme_ns_t n, struct nvme_ns_id_desc *descs);*/ int nvme_path_get_queue_depth (nvme_path_t p); +/** +* nvme_path_get_ana_state() - ANA state of an nvme_path_t object +* @p: &nvme_path_t object +* +* Return: ANA state of @p +*/ +char *nvme_path_get_ana_state (nvme_path_t p); +/** * nvme_path_get_ctrl() - Parent controller of an nvme_path_t object * @p: &nvme_path_t object
Signature · 1 line
2.53.0
PATCH 2/9 libnvme: annotate nvme_path::numa_nodes with !accessors:none
In reply to Nilay ShroffThe default accessor generation creates getters that return cached attribute values. However, for nvme_path::numa_nodes, a real-time (non-cached) value is required.
This is particularly useful for tools such as nvme-top, which rely on up-to-date information for displaying a real-time dashboard.
Annotate nvme_path::numa_nodes with "!accessors:none" to disable the auto-generated accessor, and provide a custom implementation of nvme_path_get_numa_nodes() that returns the current value.
--- libnvme/src/accessors.ld | 2 -- libnvme/src/libnvme.ld | 1 + libnvme/src/nvme/accessors.c | 13 ------------- libnvme/src/nvme/accessors.h | 15 --------------- libnvme/src/nvme/private.h | 2 +- libnvme/src/nvme/tree.c | 15 +++++++++++++++ libnvme/src/nvme/tree.h | 8 ++++++++ 7 files changed, 25 insertions(+), 31 deletions(-)
libnvme/src/accessors.ld +0 -2
@@ -14,8 +14,6 @@ LIBNVME_ACCESSORS_3 { nvme_path_set_name; nvme_path_get_sysfs_dir; nvme_path_set_sysfs_dir; - nvme_path_get_numa_nodes; - nvme_path_set_numa_nodes; nvme_path_get_grpid; nvme_path_set_grpid; nvme_ns_get_nsid;
libnvme/src/libnvme.ld +1 -0
@@ -143,6 +143,7 @@ LIBNVME_3 { nvme_path_get_ns; nvme_path_get_queue_depth; nvme_path_get_ana_state; + nvme_path_get_numa_nodes; nvme_filter_paths; nvme_read_config; nvme_read_key;
libnvme/src/nvme/accessors.c +0 -13
@@ -52,19 +52,6 @@ __public const char *nvme_path_get_sysfs_dir(const struct nvme_path *p)return p->sysfs_dir; } -__public void nvme_path_set_numa_nodes( -struct nvme_path *p, -const char *numa_nodes) -{ -free (p->numa_nodes); - p->numa_nodes = numa_nodes ?strdup (numa_nodes) :NULL ; -} - -__public const char *nvme_path_get_numa_nodes(const struct nvme_path *p) -{ -return p->numa_nodes; -} - __public void nvme_path_set_grpid(struct nvme_path *p, int grpid) { p->grpid = grpid;
libnvme/src/nvme/accessors.h +0 -15
@@ -68,21 +68,6 @@ void nvme_path_set_sysfs_dir(struct nvme_path *p, const char *sysfs_dir);*/ const char *nvme_path_get_sysfs_dir (const struct nvme_path *p); -/** -* nvme_path_set_numa_nodes() - Set numa_nodes. -* @p: The &struct nvme_path instance to update. -* @numa_nodes: New string; a copy is stored. Pass NULL to clear. -*/ -void nvme_path_set_numa_nodes (struct nvme_path *p,const char *numa_nodes); - -/** -* nvme_path_get_numa_nodes() - Get numa_nodes. -* @p: The &struct nvme_path instance to query. -* -* Return: The value of the numa_nodes field, or NULL if not set. -*/ -const char *nvme_path_get_numa_nodes (const struct nvme_path *p); -/** * nvme_path_set_grpid() - Set grpid. * @p: The &struct nvme_path instance to update.
libnvme/src/nvme/private.h +1 -1
@@ -137,8 +137,8 @@ struct nvme_path { /*!generate-accessors*/char *name;char *sysfs_dir; -char *numa_nodes;char *ana_state;//!accessors:none +char *numa_nodes;//!accessors:none int grpid;int queue_depth;//!accessors:none };
libnvme/src/nvme/tree.c +15 -0
@@ -820,6 +820,21 @@ __public char *nvme_path_get_ana_state(nvme_path_t p)return p->ana_state; } +__public char *nvme_path_get_numa_nodes(nvme_path_t p) +{ + _cleanup_free_ char *numa_nodes = NULL; + + numa_nodes =nvme_get_path_attr (p,"numa_nodes" ); +if (numa_nodes) { +if (!p->numa_nodes ||strcmp (numa_nodes, p->numa_nodes)) { +free (p->numa_nodes); + p->numa_nodes =strdup (numa_nodes); + } + } + +return p->numa_nodes; +} +void nvme_free_path (struct nvme_path *p) {list_del_init (&p->entry);
libnvme/src/nvme/tree.h +8 -0
@@ -687,6 +687,14 @@ int nvme_path_get_queue_depth(nvme_path_t p);*/ char *nvme_path_get_ana_state (nvme_path_t p); +/** +* nvme_path_get_numa_nodes() - Numa nodes of an nvme_path_t object +* @p: &nvme_path_t object +* +* Return: Numa nodes of @p +*/ +char *nvme_path_get_numa_nodes (nvme_path_t p); +/** * nvme_path_get_ctrl() - Parent controller of an nvme_path_t object * @p: &nvme_path_t object
Signature · 1 line
2.53.0
PATCH 3/9 libnvme: annotate nvme_subsystem::iopolicy with !accessors:none
In reply to Nilay ShroffThe default accessor generation creates getters that return cached attribute values. However, for nvme_subsystem::iopolicy, a real-time (non-cached) value is required.
This is particularly useful for tools such as nvme-top, which rely on up-to-date information for displaying a real-time dashboard.
Annotate nvme_subsystem::iopolicy with "!accessors:none" to disable the auto-generated accessor, and provide a custom implementation of nvme_subsystem_get_iopolicy() that returns the current value.
--- libnvme/src/accessors.ld | 2 -- libnvme/src/libnvme.ld | 1 + libnvme/src/nvme/accessors.c | 13 ------------- libnvme/src/nvme/accessors.h | 17 ----------------- libnvme/src/nvme/private.h | 2 +- libnvme/src/nvme/tree.c | 15 +++++++++++++++ libnvme/src/nvme/tree.h | 8 ++++++++ 7 files changed, 25 insertions(+), 33 deletions(-)
libnvme/src/accessors.ld +0 -2
@@ -77,8 +77,6 @@ LIBNVME_ACCESSORS_3 { nvme_subsystem_get_subsystype; nvme_subsystem_get_application; nvme_subsystem_set_application; - nvme_subsystem_get_iopolicy; - nvme_subsystem_set_iopolicy; nvme_host_get_hostnqn; nvme_host_get_hostid; nvme_host_get_dhchap_host_key;
libnvme/src/libnvme.ld +1 -0
@@ -176,6 +176,7 @@ LIBNVME_3 { nvme_subsystem_first_ns; nvme_get_subsystem; nvme_subsystem_get_host; + nvme_subsystem_get_iopolicy; nvme_subsystem_lookup_namespace; nvme_subsystem_next_ctrl; nvme_subsystem_next_ns;
libnvme/src/nvme/accessors.c +0 -13
@@ -404,19 +404,6 @@ __public const char *nvme_subsystem_get_application(return p->application; } -__public void nvme_subsystem_set_iopolicy( -struct nvme_subsystem *p, -const char *iopolicy) -{ -free (p->iopolicy); - p->iopolicy = iopolicy ?strdup (iopolicy) :NULL ; -} - -__public const char *nvme_subsystem_get_iopolicy(const struct nvme_subsystem *p) -{ -return p->iopolicy; -} -/**************************************************************************** * Accessors for: struct nvme_host ****************************************************************************/
libnvme/src/nvme/accessors.h +0 -17
@@ -575,23 +575,6 @@ void nvme_subsystem_set_application(*/ const char *nvme_subsystem_get_application (const struct nvme_subsystem *p); -/** -* nvme_subsystem_set_iopolicy() - Set iopolicy. -* @p: The &struct nvme_subsystem instance to update. -* @iopolicy: New string; a copy is stored. Pass NULL to clear. -*/ -void nvme_subsystem_set_iopolicy ( -struct nvme_subsystem *p, -const char *iopolicy); - -/** -* nvme_subsystem_get_iopolicy() - Get iopolicy. -* @p: The &struct nvme_subsystem instance to query. -* -* Return: The value of the iopolicy field, or NULL if not set. -*/ -const char *nvme_subsystem_get_iopolicy (const struct nvme_subsystem *p); -/**************************************************************************** * Accessors for: struct nvme_host ****************************************************************************/
libnvme/src/nvme/private.h +1 -1
@@ -230,7 +230,7 @@ struct nvme_subsystem { /*!generate-accessors*/char *firmware;/*!accessors:readonly*/ char *subsystype;/*!accessors:readonly*/ char *application; -char *iopolicy; +char *iopolicy;//!accessors:none };struct nvme_host {/*!generate-accessors*/
libnvme/src/nvme/tree.c +15 -0
@@ -445,6 +445,21 @@ __public nvme_host_t nvme_subsystem_get_host(nvme_subsystem_t s)return s->h; } +__public char *nvme_subsystem_get_iopolicy(nvme_subsystem_t s) +{ + _cleanup_free_ char *iopolicy = NULL; + + iopolicy =nvme_get_subsys_attr (s,"iopolicy" ); +if (iopolicy) { +if (!s->iopolicy ||strcmp (iopolicy, s->iopolicy)) { +free (s->iopolicy); + s->iopolicy =strdup (iopolicy); + } + } + +return s->iopolicy; +} + __public nvme_ns_t nvme_subsystem_first_ns(nvme_subsystem_t s) { return list_top(&s->namespaces, struct nvme_ns, entry);
libnvme/src/nvme/tree.h +8 -0
@@ -212,6 +212,14 @@ void nvme_free_subsystem(struct nvme_subsystem *s);*/ nvme_host_t nvme_subsystem_get_host (nvme_subsystem_t s); +/** +* nvme_subsystem_get_iopolicy() - Get subsystem iopolicy name +* @s: subsystem +* +* Return: The iopolicy configured in subsystem @s +*/ +char *nvme_subsystem_get_iopolicy (nvme_subsystem_t s); +/** * nvme_ctrl_first_ns() - Start namespace iterator * @c: Controller instance
Signature · 1 line
2.53.0
PATCH 4/9 libnvme: add support for retrieving per-path gendisk I/O statistics
In reply to Nilay ShroffGendisk I/O statistics provide useful insight into disk activity, including read/write/discard/flush operations, as well as information about in-flight I/Os and I/O timing.
Parsing these statistics allows users to determine the number of I/Os processed, time spent servicing I/O, number of sectors accessed, and the count of in-flight requests.
Add support for retrieving per-path gendisk I/O statistics. Also add support for computing deltas of these statistics between samples, such as I/O ticks, number of sectors, and number of serviced I/Os.
These metrics can be used by tools such as nvme-top to display real-time disk activity. Per-path metrics are particularly useful when NVMe native multipath is enabled.
--- libnvme/src/libnvme.ld | 12 ++ libnvme/src/nvme/private.h | 26 ++++ libnvme/src/nvme/tree.c | 255 +++++++++++++++++++++++++++++++++++++ libnvme/src/nvme/tree.h | 102 +++++++++++++++ 4 files changed, 395 insertions(+)
libnvme/src/libnvme.ld +12 -0
@@ -144,6 +144,18 @@ LIBNVME_3 { nvme_path_get_queue_depth; nvme_path_get_ana_state; nvme_path_get_numa_nodes; + nvme_path_get_stat; + nvme_path_get_read_ios; + nvme_path_get_write_ios; + nvme_path_get_inflights; + nvme_path_get_stat_interval; + nvme_path_get_io_ticks; + nvme_path_get_read_ticks; + nvme_path_get_write_ticks; + nvme_path_get_read_sectors; + nvme_path_get_write_sectors; + nvme_path_reset_stat; + nvme_path_update_stat; nvme_filter_paths; nvme_read_config; nvme_read_key;
libnvme/src/nvme/private.h +26 -0
@@ -20,6 +20,7 @@#include <nvme/fabrics.h> #include <nvme/mi.h> +#include <nvme/tree.h> const char *nvme_subsys_sysfs_dir (void );const char *nvme_ctrl_sysfs_dir (void );
@@ -128,9 +129,34 @@ struct nvme_transport_handle {struct nvme_log *log; }; +enum stat_group { +READ =0 , +WRITE , +DISCARD , +FLUSH , + +NR_STAT_GROUPS +}; + +struct nvme_stat { +struct { +unsigned long ios; +unsigned long merges; +unsigned long long sectors; +unsigned int ticks;/* in milliseconds */ + } group[NR_STAT_GROUPS ]; + +unsigned int inflights; +unsigned int io_ticks;/* in milliseconds */ +unsigned int tot_ticks;/* in milliseconds */ + +double ts_ms;/* timestamp when the stat is updated */ +}; +struct nvme_path {/*!generate-accessors*/ struct list_node entry;struct list_node nentry; +struct nvme_stat stat[2 ];struct nvme_ctrl *c;struct nvme_ns *n;
libnvme/src/nvme/tree.c +255 -0
267 lines not on this page · raw message
libnvme/src/nvme/tree.h +102 -0
114 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 5/9 libnvme: add support for retrieving namespace gendisk I/O statistics
In reply to Nilay ShroffGendisk I/O statistics provide useful insight into disk activity, including read/write/discard/flush operations, as well as information about in-flight I/Os and I/O timing.
Parsing these statistics allows users to determine the number of I/Os processed, time spent servicing I/O, number of sectors accessed, and the count of in-flight requests.
Add support for retrieving namespace gendisk I/O statistics. Also add support for computing deltas of these statistics between samples, such as I/O ticks, number of sectors, and number of serviced I/Os.
These metrics can be used by tools such as nvme-top to display real-time disk activity.
--- libnvme/src/libnvme.ld | 11 +++ libnvme/src/nvme/private.h | 3 + libnvme/src/nvme/tree.c | 140 +++++++++++++++++++++++++++++++++++++ libnvme/src/nvme/tree.h | 102 +++++++++++++++++++++++++++ 4 files changed, 256 insertions(+)
libnvme/src/libnvme.ld +11 -0
@@ -130,6 +130,17 @@ LIBNVME_3 { nvme_ns_get_serial; nvme_ns_get_subsystem; nvme_ns_get_uuid; + nvme_ns_reset_stat; + nvme_ns_update_stat; + nvme_ns_get_stat_interval; + nvme_ns_get_read_ios; + nvme_ns_get_write_ios; + nvme_ns_get_read_ticks; + nvme_ns_get_write_ticks; + nvme_ns_get_read_sectors; + nvme_ns_get_write_sectors; + nvme_ns_get_inflights; + nvme_ns_get_io_ticks; nvme_ns_identify; nvme_ns_read; nvme_rescan_ns;
libnvme/src/nvme/private.h +3 -0
@@ -184,6 +184,9 @@ struct nvme_ns { /*!generate-accessors*/struct nvme_ns_head *head;struct nvme_global_ctx *ctx; + +struct nvme_stat stat[2 ]; +struct nvme_transport_handle *hdl;__u32 nsid;char *name;
libnvme/src/nvme/tree.c +140 -0
188 lines not on this page · raw message
libnvme/src/nvme/tree.h +102 -0
108 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 6/9 libnvme: add support for per-path diagnostic counters
In reply to Nilay ShroffAdd support for retrieving per-path diagnostic counters such as command_retry_count, command_error_count, and multipath_failover_count. These counters improve visibility into NVMe native multipath behavior and can be useful for tools such as nvme-top to display real-time statistics.
Unlike other sysfs attributes, these counters can change dynamically. Annotate them with "!accessors:none" and provide custom implementations to always retrieve the latest (non-cached) values.
--- libnvme/src/libnvme.ld | 3 +++ libnvme/src/nvme/private.h | 3 +++ libnvme/src/nvme/tree.c | 33 +++++++++++++++++++++++++++++++++ libnvme/src/nvme/tree.h | 27 +++++++++++++++++++++++++++ 4 files changed, 66 insertions(+)
libnvme/src/libnvme.ld +3 -0
@@ -167,6 +167,9 @@ LIBNVME_3 { nvme_path_get_write_sectors; nvme_path_reset_stat; nvme_path_update_stat; + nvme_path_get_command_retry_count; + nvme_path_get_command_error_count; + nvme_path_get_multipath_failover_count; nvme_filter_paths; nvme_read_config; nvme_read_key;
libnvme/src/nvme/private.h +3 -0
@@ -167,6 +167,9 @@ struct nvme_path { /*!generate-accessors*/char *numa_nodes;//!accessors:none int grpid;int queue_depth;//!accessors:none +long multipath_failover_count;//!accessors:none +long command_retry_count;//!accessors:none +long command_error_count;//!accessors:none };struct nvme_ns_head {
libnvme/src/nvme/tree.c +33 -0
@@ -851,6 +851,39 @@ __public char *nvme_path_get_numa_nodes(nvme_path_t p)return p->numa_nodes; } +__public long nvme_path_get_multipath_failover_count (nvme_path_t p) +{ + _cleanup_free_ char *failover_count = NULL; + + failover_count =nvme_get_path_attr (p,"multipath_failover_count" ); +if (failover_count) +sscanf (failover_count,"%ld" , &p->multipath_failover_count); + +return p->multipath_failover_count; +} + +__public long nvme_path_get_command_retry_count (nvme_path_t p) +{ + _cleanup_free_ char *retry_count = NULL; + + retry_count =nvme_get_path_attr (p,"command_retry_count" ); +if (retry_count) +sscanf (retry_count,"%ld" , &p->command_retry_count); + +return p->command_retry_count; +} + +__public long nvme_path_get_command_error_count (nvme_path_t p) +{ + _cleanup_free_ char *error_count = NULL; + + error_count =nvme_get_path_attr (p,"command_error_count" ); +if (error_count) +sscanf (error_count,"%ld" , &p->command_error_count); + +return p->command_error_count; +} +static nvme_stat_t nvme_path_get_stat (nvme_path_t p,int curr) {if (curr <0 || curr >1 )
libnvme/src/nvme/tree.h +27 -0
@@ -704,6 +704,33 @@ char *nvme_path_get_ana_state(nvme_path_t p);*/ char *nvme_path_get_numa_nodes (nvme_path_t p); +/** +* nvme_path_get_multipath_failover_count() - Get multipath failover count +* @p: &nvme_path_t object +* +* Return: Number of times I/Os have to be failed over to another active path +* from path @p maybe due to any transient error observed on path @p +*/ +long nvme_path_get_multipath_failover_count (nvme_path_t p); + +/** +* nvme_path_get_command_retry_count() - Get command retry count +* @p: &nvme_path_t object +* +* Return: Number of times any command issued to the namespace represented by +* path @p has to be retried +*/ +long nvme_path_get_command_retry_count (nvme_path_t p); + +/** +* nvme_path_get_command_error_count() - Get command error count +* @p: &nvme_path_t object +* +* Return: Number of times command issued to the namespace represented by path +* @p returns non-zero status or error +*/ +long nvme_path_get_command_error_count (nvme_path_t p); +/** * nvme_path_get_ctrl() - Parent controller of an nvme_path_t object * @p: &nvme_path_t object
Signature · 1 line
2.53.0
PATCH 7/9 libnvme: add support for namespace diagnostic counters
In reply to Nilay ShroffAdd support for retrieving namespace diagnostic counters such as command_retry_count and command_error_count. These counters improve visibility and can be useful for tools such as nvme-top to display real-time statistics.
Unlike other sysfs attributes, these counters can change dynamically. Annotate them with "!accessors:none" and provide custom implementations to always retrieve the latest (non-cached) values.
--- libnvme/src/libnvme.ld | 2 ++ libnvme/src/nvme/private.h | 3 +++ libnvme/src/nvme/tree.c | 22 ++++++++++++++++++++++ libnvme/src/nvme/tree.h | 17 +++++++++++++++++ 4 files changed, 44 insertions(+)
libnvme/src/libnvme.ld +2 -0
@@ -141,6 +141,8 @@ LIBNVME_3 { nvme_ns_get_write_sectors; nvme_ns_get_inflights; nvme_ns_get_io_ticks; + nvme_ns_get_command_retry_count; + nvme_ns_get_command_error_count; nvme_ns_identify; nvme_ns_read; nvme_rescan_ns;
libnvme/src/nvme/private.h +3 -0
@@ -206,6 +206,9 @@ struct nvme_ns { /*!generate-accessors*/uint8_t nguid[16 ];unsigned char uuid[NVME_UUID_LEN ];enum nvme_csi csi; + +long command_retry_count;//!accessors:none +long command_error_count;//!accessors:none };struct nvme_ctrl {/*!generate-accessors*/
libnvme/src/nvme/tree.c +22 -0
@@ -2548,6 +2548,28 @@ __public void nvme_ns_get_uuid(nvme_ns_t n, unsigned char out[NVME_UUID_LEN])memcpy (out, n->uuid,NVME_UUID_LEN ); } +__public long nvme_ns_get_command_retry_count (nvme_ns_t n) +{ + _cleanup_free_ char *retry_count = NULL; + + retry_count =nvme_get_ns_attr (n,"command_retry_count" ); +if (retry_count) +sscanf (retry_count,"%ld" , &n->command_retry_count); + +return n->command_retry_count; +} + +__public long nvme_ns_get_command_error_count (nvme_ns_t n) +{ + _cleanup_free_ char *error_count = NULL; + + error_count =nvme_get_ns_attr (n,"command_error_count" ); +if (error_count) +sscanf (error_count,"%ld" , &n->command_error_count); + +return n->command_error_count; +} + __public int nvme_ns_identify(nvme_ns_t n, struct nvme_id_ns *ns) {struct nvme_transport_handle *hdl;
libnvme/src/nvme/tree.h +17 -0
@@ -529,6 +529,23 @@ const uint8_t *nvme_ns_get_nguid(nvme_ns_t n);*/ void nvme_ns_get_uuid (nvme_ns_t n,unsigned char out[NVME_UUID_LEN ]); +/** +* nvme_ns_get_command_retry_count() - Get command retry count +* @n: &nvme_ns_t object +* +* Return: Number of times any command issued to namespace @n has to be retried +*/ +long nvme_ns_get_command_retry_count (nvme_ns_t n); + +/** +* nvme_ns_get_command_error_count() - Get command error count +* @n: &nvme_ns_t object +* +* Return: Number of times command issued to namespace @n returns non-zero +* status or error +*/ +long nvme_ns_get_command_error_count (nvme_ns_t n); +/** * nvme_ns_get_generic_name() - Returns name of generic namespace chardev. * @n: Namespace instance
Signature · 1 line
2.53.0
PATCH 8/9 libnvme: add support for nshead diagnostic counters
In reply to Nilay ShroffAdd support for retrieving nshead diagnostic counters such as requeue_ no_usable_path_count and fail_no_available_path_count.
The requeue_no_usable_path_count counter represents the number of I/Os requeued to the namespace head when no usable path is available (for example, due to transient link issues). The fail_no_available_path_count counter represents the number of I/Os failed when no I/O path is available (for example, when all paths are removed).
These counters improve visibility into NVMe native multipath behavior and can be useful for tools such as nvme-top to display real-time statistics.
Unlike other sysfs attributes, these counters can change dynamically. Annotate them with "!accessors:none" and provide custom implementations to always retrieve the latest (non-cached) values.
--- libnvme/src/libnvme.ld | 2 ++ libnvme/src/nvme/private.h | 2 ++ libnvme/src/nvme/tree.c | 22 ++++++++++++++++++++++ libnvme/src/nvme/tree.h | 17 +++++++++++++++++ 4 files changed, 43 insertions(+)
libnvme/src/libnvme.ld +2 -0
@@ -143,6 +143,8 @@ LIBNVME_3 { nvme_ns_get_io_ticks; nvme_ns_get_command_retry_count; nvme_ns_get_command_error_count; + nvme_ns_get_requeue_no_usable_path_count; + nvme_ns_get_fail_no_available_path_count; nvme_ns_identify; nvme_ns_read; nvme_rescan_ns;
libnvme/src/nvme/private.h +2 -0
@@ -209,6 +209,8 @@ struct nvme_ns { /*!generate-accessors*/long command_retry_count;//!accessors:none long command_error_count;//!accessors:none +long requeue_no_usable_path_count;//!accessors:none +long fail_no_available_path_count;//!accessors:none };struct nvme_ctrl {/*!generate-accessors*/
libnvme/src/nvme/tree.c +22 -0
@@ -2570,6 +2570,28 @@ __public long nvme_ns_get_command_error_count(nvme_ns_t n)return n->command_error_count; } +__public long nvme_ns_get_requeue_no_usable_path_count (nvme_ns_t n) +{ + _cleanup_free_ char *requeue_count = NULL; + + requeue_count =nvme_get_ns_attr (n,"requeue_no_usable_path_count" ); +if (requeue_count) +sscanf (requeue_count,"%ld" , &n->requeue_no_usable_path_count); + +return n->requeue_no_usable_path_count; +} + +__public long nvme_ns_get_fail_no_available_path_count (nvme_ns_t n) +{ + _cleanup_free_ char *fail_count = NULL; + + fail_count =nvme_get_ns_attr (n,"fail_no_available_path_count" ); +if (fail_count) +sscanf (fail_count,"%ld" , &n->fail_no_available_path_count); + +return n->fail_no_available_path_count; +} + __public int nvme_ns_identify(nvme_ns_t n, struct nvme_id_ns *ns) {struct nvme_transport_handle *hdl;
libnvme/src/nvme/tree.h +17 -0
@@ -546,6 +546,23 @@ long nvme_ns_get_command_retry_count(nvme_ns_t n);*/ long nvme_ns_get_command_error_count (nvme_ns_t n); +/** +* nvme_ns_get_requeue_no_usable_path_count() - Get num of I/O requeue count +* @n: &nvme_ns_t object +* +* Return: Number of I/Os which are re-queued due to the unavalibility of +* any usable path (maybe path is currently experiencing transinet link failure) +*/ +long nvme_ns_get_requeue_no_usable_path_count (nvme_ns_t n); + +/** +* nvme_ns_get_fail_no_available_path_count() - Get num of I/Os forced to fail +* @n: &nvme_ns_t object +* +* Return: Number of I/Os which are forced to fail due to no path available +*/ +long nvme_ns_get_fail_no_available_path_count (nvme_ns_t n); +/** * nvme_ns_get_generic_name() - Returns name of generic namespace chardev. * @n: Namespace instance
Signature · 1 line
2.53.0
PATCH 9/9 libnvme: add support for ctrl diagnostic counters
In reply to Nilay ShroffAdd support for retrieving ctrl diagnostic counters such as command_ error_count, reset_count and reconnect_count. These counters improve visibility and can be useful for tools such as nvme-top to display real-time statistics.
Unlike other sysfs attributes, these counters can change dynamically. Annotate them with "!accessors:none" and provide custom implementations to always retrieve the latest (non-cached) values.
--- libnvme/src/libnvme.ld | 3 +++ libnvme/src/nvme/private.h | 3 +++ libnvme/src/nvme/tree.c | 33 +++++++++++++++++++++++++++++++++ libnvme/src/nvme/tree.h | 25 +++++++++++++++++++++++++ 4 files changed, 64 insertions(+)
libnvme/src/libnvme.ld +3 -0
@@ -16,6 +16,9 @@ LIBNVME_3 { nvme_ctrl_get_subsysnqn; nvme_ctrl_get_subsystem; nvme_ctrl_get_transport_handle; + nvme_ctrl_get_command_error_count; + nvme_ctrl_get_reset_count; + nvme_ctrl_get_reconnect_count; nvme_ctrl_identify; nvme_ctrl_next_ns; nvme_ctrl_next_path;
libnvme/src/nvme/private.h +3 -0
@@ -250,6 +250,9 @@ struct nvme_ctrl { /*!generate-accessors*/bool unique_discovery_ctrl;bool discovered;bool persistent; +long command_error_count;//!accessors:none +long reset_count;//!accessors:none +long reconnect_count;//!accessors:none struct nvme_fabrics_config cfg; };
libnvme/src/nvme/tree.c +33 -0
@@ -1400,6 +1400,39 @@ __public const char *nvme_ctrl_get_state(nvme_ctrl_t c)return c->state; } +__public long nvme_ctrl_get_command_error_count (nvme_ctrl_t c) +{ + _cleanup_free_ char *error_count = NULL; + + error_count =nvme_get_ctrl_attr (c,"command_error_count" ); +if (error_count) +sscanf (error_count,"%ld" , &c->command_error_count); + +return c->command_error_count; +} + +__public long nvme_ctrl_get_reset_count (nvme_ctrl_t c) +{ + _cleanup_free_ char *reset_count = NULL; + + reset_count =nvme_get_ctrl_attr (c,"reset_count" ); +if (reset_count) +sscanf (reset_count,"%ld" , &c->reset_count); + +return c->reset_count; +} + +__public long nvme_ctrl_get_reconnect_count (nvme_ctrl_t c) +{ + _cleanup_free_ char *reconnect_count = NULL; + + reconnect_count =nvme_get_ctrl_attr (c,"reconnect_count" ); +if (reconnect_count) +sscanf (reconnect_count,"%ld" , &c->reconnect_count); + +return c->reconnect_count; +} + __public struct nvme_fabrics_config *nvme_ctrl_get_config(nvme_ctrl_t c) {return &c->cfg;
libnvme/src/nvme/tree.h +25 -0
@@ -1047,6 +1047,31 @@ unsigned long long nvme_ns_get_write_sectors(nvme_ns_t n, int curr);*/ struct nvme_fabrics_config *nvme_ctrl_get_config (nvme_ctrl_t c); +/** +* nvme_ctrl_get_command_error_count() - Get admin command error count +* @c: Controller instance +* +* Return: Number of times admin command issued to controller @c failed or +* returned error status +*/ +long nvme_ctrl_get_command_error_count (nvme_ctrl_t c); + +/** +* nvme_ctrl_get_reset_count() - Get controller reset count +* @c: Controller instance +* +* Return: Number of timer controller @c is reset +*/ +long nvme_ctrl_get_reset_count (nvme_ctrl_t c); + +/** +* nvme_ctrl_get_reconnect_count() - Get controller reconnect count +* @c: Controller instance +* +* Return: Number of times controller has to reconnect to the target +*/ +long nvme_ctrl_get_reconnect_count (nvme_ctrl_t c); +/** * nvme_ctrl_identify() - Issues an 'identify controller' command * @c: Controller instance
Signature · 1 line
2.53.0
Re: [PATCH 1/9] libnvme: annotate nvme_path::ana_state with !accessors:none
In reply to Nilay Shrofflibnvme/src/nvme/tree.c __public int nvme_path_get_queue_depth(nvme_path_t p) · line 817
Quoted 11 lines · Nilay Shroff
libnvme/src/nvme/tree.c +11
-0+__public char *nvme_path_get_ana_state(nvme_path_t p) +{ + _cleanup_free_ char *ana_state = NULL; + + ana_state =nvme_get_path_attr (p,"ana_state" ); +if (ana_state) { +if (!p->ana_state ||strcmp (ana_state, p->ana_state)) { +free (p->ana_state); + p->ana_state =strdup (ana_state); + + }
a couple of tabs indention here
Quoted 4 lines
libnvme/src/nvme/tree.c +4
-0+ } + +return p->ana_state; +}
Re: [PATCH 4/9] libnvme: add support for retrieving per-path gendisk I/O statistics
In reply to Nilay ShroffQuoted 12 lines · Nilay Shroff
libnvme/src/nvme/tree.c +12
-0+static int nvme_update_stat (const char *sysfs_stat_path,nvme_stat_t stat) +{ +int n; +struct timespec ts; +unsigned long rd_ios, rd_merges, wr_ios, wr_merges; +unsigned long dc_ios, dc_merges, fl_ios; +unsigned long long rd_sectors, wr_sectors, dc_sectors; +unsigned int rd_ticks, wr_ticks, dc_ticks, fl_ticks; +unsigned int io_ticks, tot_ticks, inflights; + +memset (stat,0 ,sizeof (struct nvme_stat )); +
libnvme/src/nvme/tree.c __public char *nvme_path_get_numa_nodes(nvme_path_t p) · line 890
Quoted 10 lines
libnvme/src/nvme/tree.c +10
-0+ n =sscanf (sysfs_stat_path, +"%lu %lu %llu %u %lu %lu %llu %u %u %u %u %lu %lu %llu %u %lu %u" , + &rd_ios, &rd_merges, &rd_sectors, &rd_ticks, + &wr_ios, &wr_merges, &wr_sectors, &wr_ticks, + &inflights, &io_ticks, &tot_ticks, + &dc_ios, &dc_merges, &dc_sectors, &dc_ticks, + &fl_ios, &fl_ticks); + +if (n <17 ) +return -1 ;
return a proper error code, e.g. -EINVAL or whatever matches better.
Quoted 1 line
+__public int
nvme_path_update_stat(nvme_path_t p, int curr)
Do we need to expose 'curr' to the user? I'd prefer not to expose this implementation detail to the user if possible.
libnvme/src/nvme/tree.c __public char *nvme_path_get_numa_nodes(nvme_path_t p) · line 932
Quoted 7 lines
libnvme/src/nvme/tree.c +7
-0+{ + _cleanup_free_ char *sysfs_stat_path = NULL; +nvme_stat_t stat; + + stat =nvme_path_get_stat (p, curr); +if (!stat) +return -1 ;
return an error code instead -1. same comment for the rest of the patch.
libnvme/src/nvme/tree.c __public char *nvme_path_get_numa_nodes(nvme_path_t p) · line 972
Quoted 6 lines
libnvme/src/nvme/tree.c +6
-0+__public unsigned int nvme_path_get_io_ticks(nvme_path_t p, int this) +{ +nvme_stat_t curr, prev; + + curr =nvme_path_get_stat (p, this); + prev =nvme_path_get_stat (p, !this);
Do we really need to expose 'this'?
Re: [PATCH 5/9] libnvme: add support for retrieving namespace gendisk I/O statistics
In reply to Nilay ShroffQuoted 8 lines · Nilay Shroff
Gendisk I/O statistics provide useful insight into disk activity, including read/write/discard/flush operations, as well as information about in-flight I/Os and I/O timing.
Parsing these statistics allows users to determine the number of I/Os processed, time spent servicing I/O, number of sectors accessed, and the count of in-flight requests.
Quoted 6 lines
Add support for retrieving namespace gendisk I/O statistics. Also add support for computing deltas of these statistics between samples, such as I/O ticks, number of sectors, and number of serviced I/Os.
These metrics can be used by tools such as nvme-top to display real-time disk activity.
Same comments as in the previous patch.
- error codes
- is it necessary to expose 'cur', 'this' via the API?
Re: [PATCH 6/9] libnvme: add support for per-path diagnostic counters
In reply to Nilay ShroffQuoted 9 lines · Nilay Shroff
Add support for retrieving per-path diagnostic counters such as
command_retry_count,command_error_count, andmultipath_failover_count. These counters improve visibility into NVMe native multipath behavior and can be useful for tools such as nvme-top to display real-time statistics.Unlike other sysfs attributes, these counters can change dynamically. Annotate them with "!accessors:none" and provide custom implementations to always retrieve the latest (non-cached) values.
If I got this right, this and the next patches depend on
https://lore.kernel.org/all/[email protected]
Should we wait with interfaces here until they are ready? As we currently still in the development phase of nvme-cli 3 and thus the API is not stable, we can touch it again. In the past we also added support for kernel feature which weren't there yet. I don't mind too much, just asking what would be best here.
The whole series looks pretty good, just my nitpicks and the question on exposing 'cur'/'this'.
Re: [PATCH 4/9] libnvme: add support for retrieving per-path gendisk I/O statistics
In reply to Daniel WagnerQuoted 17 lines · Daniel Wagner
Quoted 16 lines · Nilay Shroff
libnvme/src/nvme/tree.c +16
-0+static int nvme_update_stat (const char *sysfs_stat_path,nvme_stat_t stat) +{ +int n; +struct timespec ts; +unsigned long rd_ios, rd_merges, wr_ios, wr_merges; +unsigned long dc_ios, dc_merges, fl_ios; +unsigned long long rd_sectors, wr_sectors, dc_sectors; +unsigned int rd_ticks, wr_ticks, dc_ticks, fl_ticks; +unsigned int io_ticks, tot_ticks, inflights; + +memset (stat,0 ,sizeof (struct nvme_stat )); + + n = sscanf(sysfs_stat_path, + "%lu %lu %llu %u %lu %lu %llu %u %u %u %u %lu %lu %llu %u %lu %u", + &rd_ios, &rd_merges, &rd_sectors, &rd_ticks, + &wr_ios, &wr_merges, &wr_sectors, &wr_ticks,
Quoted 8 lines
libnvme/src/nvme/tree.c __public char *nvme_path_get_numa_nodes(nvme_path_t p) · line 890
Quoted 6 lines
libnvme/src/nvme/tree.c +6
-0+ &inflights, &io_ticks, &tot_ticks, + &dc_ios, &dc_merges, &dc_sectors, &dc_ticks, + &fl_ios, &fl_ticks); + +if (n <17 ) +return -1 ;return a proper error code, e.g.
-EINVALor whatever matches better.
Yes will return the proper error code.
Quoted 6 lines
Quoted 2 lines
+__public int
nvme_path_update_stat(nvme_path_t p, int curr)Do we need to expose 'curr' to the user? I'd prefer not to expose this implementation detail to the user if possible.
Here, @curr represents the bucket index. As you may have noticed, nvme_path_t maintains a stats[2] array that stores both the previous and current statistics.
Typically, at a regular interval (for example, when nvme-top runs with a 1-second interval), the user/nvme-cli invokes nvme_path_update_stat(). This function reads the gendisk I/O statistics and updates one of the entries in stats[]. The @curr parameter indicates which bucket should be updated with the latest values.
After updating the stat, the caller/nvme-cli invokes nvme_path_get_xxx() APIs to retrieve specific metrics. These APIs also take the current index and compute results by comparing the current and previous statistics.
In the next interval, the caller/nvme-cli toggles the index. This effectively swaps the roles of the two buckets—what was previously the current stats becomes the previous stats, and vice versa. The caller then invokes nvme_path_update_stat() again with the updated index, followed by the nvme_path_get_xxx() APIs to retrieve the latest computed statistics.
From this, you can see that if this logic were handled entirely within libnvme, the library would need to maintain internal state to track which bucket to update. Instead, I prefer leaving this responsibility to the caller, since it already operates within the interval loop. This keeps the library stateless and gives the caller explicit control over the bucket selection for each interval. Does this make sense?
Quoted 10 lines
libnvme/src/nvme/tree.c __public char *nvme_path_get_numa_nodes(nvme_path_t p) · line 932
Quoted 7 lines
libnvme/src/nvme/tree.c +7
-0+{ + _cleanup_free_ char *sysfs_stat_path = NULL; +nvme_stat_t stat; + + stat =nvme_path_get_stat (p, curr); +if (!stat) +return -1 ;return an error code instead -1. same comment for the rest of the patch.
Quoted 9 lines
libnvme/src/nvme/tree.c __public char *nvme_path_get_numa_nodes(nvme_path_t p) · line 972
Quoted 6 lines
libnvme/src/nvme/tree.c +6
-0+__public unsigned int nvme_path_get_io_ticks(nvme_path_t p, int this) +{ +nvme_stat_t curr, prev; + + curr =nvme_path_get_stat (p, this); + prev =nvme_path_get_stat (p, !this);Do we really need to expose 'this'?
As explained above @this is also a bucket index which is used to calculate/derive the io_ticks comparing the ticks values in the current and previous stat buckets.
Thanks,
--Nilay
Re: [PATCH 1/9] libnvme: annotate nvme_path::ana_state with !accessors:none
In reply to Daniel WagnerQuoted 15 lines · Daniel Wagner
libnvme/src/nvme/tree.c __public int nvme_path_get_queue_depth(nvme_path_t p) · line 817
Quoted 11 lines · Nilay Shroff
libnvme/src/nvme/tree.c +11
-0+__public char *nvme_path_get_ana_state(nvme_path_t p) +{ + _cleanup_free_ char *ana_state = NULL; + + ana_state =nvme_get_path_attr (p,"ana_state" ); +if (ana_state) { +if (!p->ana_state ||strcmp (ana_state, p->ana_state)) { +free (p->ana_state); + p->ana_state =strdup (ana_state); + + }a couple of tabs indention here
Ah, good catch. Will fix.
Quoted 4 lines
libnvme/src/nvme/tree.c __public int nvme_path_get_queue_depth(nvme_path_t p) · line 821
Quoted 4 lines
libnvme/src/nvme/tree.c +4
-0+ } + +return p->ana_state; +}
Thanks,
--Nilay
Re: [PATCH 5/9] libnvme: add support for retrieving namespace gendisk I/O statistics
In reply to Daniel WagnerQuoted 13 lines · Daniel Wagner
Quoted 12 lines · Nilay Shroff
Gendisk I/O statistics provide useful insight into disk activity, including read/write/discard/flush operations, as well as information about in-flight I/Os and I/O timing.
Parsing these statistics allows users to determine the number of I/Os processed, time spent servicing I/O, number of sectors accessed, and the count of in-flight requests.
Add support for retrieving namespace gendisk I/O statistics. Also add support for computing deltas of these statistics between samples, such as I/O ticks, number of sectors, and number of serviced I/Os.
Quoted 6 lines
Quoted 2 lines
These metrics can be used by tools such as nvme-top to display real-time disk activity.
Same comments as in the previous patch.
- error codes
- is it necessary to expose 'cur', 'this' via the API?
Yeah will use proper error codes.
The same rationale as in the previous patch applies here for exposing cur/this. The only difference is that the earlier patch handled nvme_path_t statistics, while this one operates on nvme_ns_t statistics.
Thanks,
--Nilay
Re: [PATCH 6/9] libnvme: add support for per-path diagnostic counters
In reply to Daniel WagnerQuoted 7 lines · Daniel Wagner
Quoted 6 lines · Nilay Shroff
Add support for retrieving per-path diagnostic counters such as
command_retry_count,command_error_count, andmultipath_failover_count. These counters improve visibility into NVMe native multipath behavior and can be useful for tools such as nvme-top to display real-time statistics.
Quoted 8 lines
Quoted 3 lines
Unlike other sysfs attributes, these counters can change dynamically. Annotate them with "!accessors:none" and provide custom implementations to always retrieve the latest (non-cached) values.
If I got this right, this and the next patches depend on
https://lore.kernel.org/all/[email protected]
Yes you're correct, I am just waiting for Keith's response on that thread here:
https://lore.kernel.org/all/[email protected]/
Quoted 6 lines
Should we wait with interfaces here until they are ready? As we currently still in the development phase of nvme-cli 3 and thus the API is not stable, we can touch it again. In the past we also added support for kernel feature which weren't there yet. I don't mind too much, just asking what would be best here.
I’m fine either way regarding when to introduce these interfaces. Even if we include the diagnostic counter patches now, it won’t break anything. If the corresponding sysfs attributes are not present, the library will simply return 0 for those counters.
There are essentially two options,
1. Include the diagnostic counter patches now:
In this case, nvme-cli/nvme-top can start using the libnvme APIs immediately. If the kernel does not yet expose these attributes, the counters will appear as zero in the dashboard. Once the kernel support lands, the correct values will automatically be reflected without requiring further changes to libnvme or nvme-cli (unless the sysfs layout changes).
2. Defer the diagnostic counter patches:
In this case, the counters would be omitted from the nvme-top dashboard for now. Once kernel support is available, we would need to update nvme-top (and libnvme) to add them.
Given these options, I would lean towards option (1), but I’m happy to go with your preference.
Quoted 2 lines
The whole series looks pretty good, just my nitpicks and the question on exposing 'cur'/'this'.
I will address nitpick comments in next patchset, and I have provided the rationale about why we need to expose 'cur'/'this' in an earlier reply.
Thanks,
--Nilay
Re: [PATCH 4/9] libnvme: add support for retrieving per-path gendisk I/O statistics
In reply to Nilay ShroffHi Nilay,
Sorry for the late response.
Quoted 3 lines · Nilay Shroff
After updating the stat, the caller/nvme-cli invokes
nvme_path_get_xxx()APIs to retrieve specific metrics. These APIs also take the current index and compute results by comparing the current and previous statistics.
Let's try to avoid leaking internal implementation details to the public API. This makes it unnecessary hard to maintain.
The stats update function could take an argument what it should do:
- update internal stats, calculate diff -> getters return the diff
- update internal stats, getters return the absolute value
Thanks,
Daniel
Re: [PATCH 6/9] libnvme: add support for per-path diagnostic counters
In reply to Nilay ShroffQuoted 9 lines · Nilay Shroff
There are essentially two options,
1. Include the diagnostic counter patches now:
In this case, nvme-cli/nvme-top can start using the libnvme APIs immediately. If the kernel does not yet expose these attributes, the counters will appear as zero in the dashboard. Once the kernel support lands, the correct values will automatically be reflected without requiring further changes to libnvme or nvme-cli (unless the sysfs layout changes).
Quoted 7 lines
2. Defer the diagnostic counter patches:
In this case, the counters would be omitted from the nvme-top dashboard for now. Once kernel support is available, we would need to update nvme-top (and libnvme) to add them.Given these options, I would lean towards option (1), but I’m happy to go with your preference.
I’m not sure if I read the room right, but I sensed the patches might be blocked by the libmultipath project. If they’re just delayed for the usual reasons, I’m fine with option (1).
FWIW, the 3.0 release is still months away, so there’s no hurry. I still have a few TODO items and want to wait for feedback from LSFMM. I’ll likely start the -rc cycle after that. Realistically, 3.0 won't land until August.
Re: [PATCH 4/9] libnvme: add support for retrieving per-path gendisk I/O statistics
In reply to Daniel WagnerQuoted 3 lines · Daniel Wagner
Hi Nilay,
Sorry for the late response.
No worries:-)
Quoted 6 lines · Nilay Shroff
Quoted 3 lines
After updating the stat, the caller/nvme-cli invokes
nvme_path_get_xxx()APIs to retrieve specific metrics. These APIs also take the current index and compute results by comparing the current and previous statistics.
Quoted 7 lines
Let's try to avoid leaking internal implementation details to the public API. This makes it unnecessary hard to maintain.
The stats update function could take an argument what it should do:
- update internal stats, calculate diff -> getters return the diff
- update internal stats, getters return the absolute value
Yes got it.. I think we could do this way. I will give it a shot and respin a new patchset with the above change.
Thanks,
--Nilay
Re: [PATCH 6/9] libnvme: add support for per-path diagnostic counters
In reply to Daniel WagnerQuoted 15 lines · Daniel Wagner
Quoted 14 lines · Nilay Shroff
There are essentially two options,
1. Include the diagnostic counter patches now:
In this case, nvme-cli/nvme-top can start using the libnvme APIs immediately. If the kernel does not yet expose these attributes, the counters will appear as zero in the dashboard. Once the kernel support lands, the correct values will automatically be reflected without requiring further changes to libnvme or nvme-cli (unless the sysfs layout changes).2. Defer the diagnostic counter patches:
In this case, the counters would be omitted from the nvme-top dashboard for now. Once kernel support is available, we would need to update nvme-top (and libnvme) to add them.
Quoted 7 lines
Quoted 2 lines
Given these options, I would lean towards option (1), but I’m happy to go with your preference.
I’m not sure if I read the room right, but I sensed the patches might be blocked by the libmultipath project. If they’re just delayed for the usual reasons, I’m fine with option (1).
I think that the proposed kernel changes shouldn't come in way for libmultipath work, but let me ping Keith one more time... Oh I see Keith is already in this mail list..
Keith,
I am not sure if you got a chance to review this:
https://lore.kernel.org/all/[email protected]/
But if possible, would you please help let us know your thought/suggestion about the above thread?
Quoted 4 lines
FWIW, the 3.0 release is still months away, so there’s no hurry. I still have a few TODO items and want to wait for feedback from LSFMM. I’ll likely start the -rc cycle after that. Realistically, 3.0 won't land until August.
Yes understood, sounds reasonable...
Thanks,
--Nilay