From: Nilay Shroff <nilay@linux.ibm.com>
To: linux-nvme@lists.infradead.org
Cc: dwagner@suse.de, hare@suse.com, kbusch@kernel.org, hch@lst.de,
gjoyce@linux.ibm.com, wenxiong@linux.ibm.com,
Nilay Shroff <nilay@linux.ibm.com>
Subject: [PATCHv3 2/9] libnvme: annotate libnvme_path::numa_nodes with !accessors:none
Date: Tue, 21 Apr 2026 20:20:23 +0530 [thread overview]
Message-ID: <20260421145038.3458987-3-nilay@linux.ibm.com> (raw)
In-Reply-To: <20260421145038.3458987-1-nilay@linux.ibm.com>
The default accessor generation creates getters that return cached
attribute values. However, for libnvme_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 libnvme_path::numa_nodes with "!accessors:none" to disable the
auto-generated accessor, and provide a custom implementation of
libnvme_path_get_numa_nodes() that returns the current value.
Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
---
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(-)
diff --git a/libnvme/src/accessors.ld b/libnvme/src/accessors.ld
index 73b238ee9..4ccba1a6e 100644
--- a/libnvme/src/accessors.ld
+++ b/libnvme/src/accessors.ld
@@ -168,11 +168,9 @@ LIBNVME_ACCESSORS_3 {
libnvme_ns_set_sysfs_dir;
libnvme_path_get_grpid;
libnvme_path_get_name;
- libnvme_path_get_numa_nodes;
libnvme_path_get_sysfs_dir;
libnvme_path_set_grpid;
libnvme_path_set_name;
- libnvme_path_set_numa_nodes;
libnvme_path_set_sysfs_dir;
libnvme_subsystem_get_application;
libnvme_subsystem_get_firmware;
diff --git a/libnvme/src/libnvme.ld b/libnvme/src/libnvme.ld
index 19a7910cb..9b26de5cd 100644
--- a/libnvme/src/libnvme.ld
+++ b/libnvme/src/libnvme.ld
@@ -140,6 +140,7 @@ LIBNVME_3 {
libnvme_path_get_ns;
libnvme_path_get_queue_depth;
libnvme_path_get_ana_state;
+ libnvme_path_get_numa_nodes;
libnvme_random_uuid;
libnvme_read_config;
libnvme_read_hostid;
diff --git a/libnvme/src/nvme/accessors.c b/libnvme/src/nvme/accessors.c
index 675bb7d02..bcae8d578 100644
--- a/libnvme/src/nvme/accessors.c
+++ b/libnvme/src/nvme/accessors.c
@@ -291,19 +291,6 @@ __public const char *libnvme_path_get_sysfs_dir(const struct libnvme_path *p)
return p->sysfs_dir;
}
-__public void libnvme_path_set_numa_nodes(
- struct libnvme_path *p,
- const char *numa_nodes)
-{
- free(p->numa_nodes);
- p->numa_nodes = numa_nodes ? strdup(numa_nodes) : NULL;
-}
-
-__public const char *libnvme_path_get_numa_nodes(const struct libnvme_path *p)
-{
- return p->numa_nodes;
-}
-
__public void libnvme_path_set_grpid(struct libnvme_path *p, int grpid)
{
p->grpid = grpid;
diff --git a/libnvme/src/nvme/accessors.h b/libnvme/src/nvme/accessors.h
index 7ff0a274f..7ade91794 100644
--- a/libnvme/src/nvme/accessors.h
+++ b/libnvme/src/nvme/accessors.h
@@ -391,23 +391,6 @@ void libnvme_path_set_sysfs_dir(struct libnvme_path *p, const char *sysfs_dir);
*/
const char *libnvme_path_get_sysfs_dir(const struct libnvme_path *p);
-/**
- * libnvme_path_set_numa_nodes() - Set numa_nodes.
- * @p: The &struct libnvme_path instance to update.
- * @numa_nodes: New string; a copy is stored. Pass NULL to clear.
- */
-void libnvme_path_set_numa_nodes(
- struct libnvme_path *p,
- const char *numa_nodes);
-
-/**
- * libnvme_path_get_numa_nodes() - Get numa_nodes.
- * @p: The &struct libnvme_path instance to query.
- *
- * Return: The value of the numa_nodes field, or NULL if not set.
- */
-const char *libnvme_path_get_numa_nodes(const struct libnvme_path *p);
-
/**
* libnvme_path_set_grpid() - Set grpid.
* @p: The &struct libnvme_path instance to update.
diff --git a/libnvme/src/nvme/private.h b/libnvme/src/nvme/private.h
index 9d25373ed..2471495ad 100644
--- a/libnvme/src/nvme/private.h
+++ b/libnvme/src/nvme/private.h
@@ -176,8 +176,8 @@ struct libnvme_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
};
diff --git a/libnvme/src/nvme/tree.c b/libnvme/src/nvme/tree.c
index 46e72ebc4..c2c959871 100644
--- a/libnvme/src/nvme/tree.c
+++ b/libnvme/src/nvme/tree.c
@@ -854,6 +854,21 @@ __public char *libnvme_path_get_ana_state(libnvme_path_t p)
return p->ana_state;
}
+__public char *libnvme_path_get_numa_nodes(libnvme_path_t p)
+{
+ __cleanup_free char *numa_nodes = NULL;
+
+ numa_nodes = libnvme_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 libnvme_path *p)
{
if (!p)
diff --git a/libnvme/src/nvme/tree.h b/libnvme/src/nvme/tree.h
index aa983b862..7cd90c620 100644
--- a/libnvme/src/nvme/tree.h
+++ b/libnvme/src/nvme/tree.h
@@ -668,6 +668,14 @@ int libnvme_path_get_queue_depth(libnvme_path_t p);
*/
char *libnvme_path_get_ana_state(libnvme_path_t p);
+/**
+ * libnvme_path_get_numa_nodes() - Numa nodes of an nvme_path_t object
+ * @p: &libnvme_path_t object
+ *
+ * Return: Numa nodes of @p
+ */
+char *libnvme_path_get_numa_nodes(libnvme_path_t p);
+
/**
* libnvme_path_get_ctrl() - Parent controller of an libnvme_path_t object
* @p: &libnvme_path_t object
--
2.53.0
next prev parent reply other threads:[~2026-04-21 14:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 14:50 [PATCHv3 0/9] libnvme: add support for retrieving additional NVMe stat Nilay Shroff
2026-04-21 14:50 ` [PATCHv3 1/9] libnvme: annotate libnvme_path::ana_state with !accessors:none Nilay Shroff
2026-04-21 14:50 ` Nilay Shroff [this message]
2026-04-21 14:50 ` [PATCHv3 3/9] libnvme: annotate libnvme_subsystem::iopolicy " Nilay Shroff
2026-04-21 14:50 ` [PATCHv3 4/9] libnvme: add support for retrieving per-path gendisk I/O statistics Nilay Shroff
2026-04-21 14:50 ` [PATCHv3 5/9] libnvme: add support for retrieving namespace " Nilay Shroff
2026-04-21 14:50 ` [PATCHv3 6/9] libnvme: add support for per-path diagnostic counters Nilay Shroff
2026-04-21 14:50 ` [PATCHv3 7/9] libnvme: add support for namespace " Nilay Shroff
2026-04-21 14:50 ` [PATCHv3 8/9] libnvme: add support for nshead " Nilay Shroff
2026-04-21 14:50 ` [PATCHv3 9/9] libnvme: add support for ctrl " Nilay Shroff
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260421145038.3458987-3-nilay@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=dwagner@suse.de \
--cc=gjoyce@linux.ibm.com \
--cc=hare@suse.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=wenxiong@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox