Skip to content

Commit 2722f62

Browse files
shroffniigaw
authored andcommitted
tree: add attribute numa_nodes for NVMe path object
Add a new attribute named "numa_nodes" under the NVMe path object. This attribute is used by the iopolicy "numa". The numa_nodes value is stored for each NVMe path and represents the NUMA node(s) associated with it. When the iopolicy is set to "numa", I/O traffic originating from a given NUMA node will be forwarded through the corresponding NVMe path. The numa_nodes attribute is useful for observing which NVMe path the kernel would choose for I/O forwarding based on NUMA affinity. To support this, export the attribute in libnvme.map so it can be accessed via nvme-cli. Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Nilay Shroff <[email protected]> Signed-off-by: Daniel Wagner <[email protected]>
1 parent ed783ea commit 2722f62

4 files changed

Lines changed: 20 additions & 0 deletions

File tree

src/libnvme.map

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ LIBNVME_1_0 {
327327
nvme_path_get_ctrl;
328328
nvme_path_get_name;
329329
nvme_path_get_ns;
330+
nvme_path_get_numa_nodes;
330331
nvme_path_get_queue_depth;
331332
nvme_path_get_sysfs_dir;
332333
nvme_paths_filter;

src/nvme/private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct nvme_path {
3333
char *name;
3434
char *sysfs_dir;
3535
char *ana_state;
36+
char *numa_nodes;
3637
int grpid;
3738
int queue_depth;
3839
};

src/nvme/tree.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,13 +925,19 @@ const char *nvme_path_get_ana_state(nvme_path_t p)
925925
return p->ana_state;
926926
}
927927

928+
const char *nvme_path_get_numa_nodes(nvme_path_t p)
929+
{
930+
return p->numa_nodes;
931+
}
932+
928933
void nvme_free_path(struct nvme_path *p)
929934
{
930935
list_del_init(&p->entry);
931936
list_del_init(&p->nentry);
932937
free(p->name);
933938
free(p->sysfs_dir);
934939
free(p->ana_state);
940+
free(p->numa_nodes);
935941
free(p);
936942
}
937943

@@ -967,6 +973,10 @@ static int nvme_ctrl_scan_path(nvme_root_t r, struct nvme_ctrl *c, char *name)
967973
if (!p->ana_state)
968974
p->ana_state = strdup("optimized");
969975

976+
p->numa_nodes = nvme_get_path_attr(p, "numa_nodes");
977+
if (!p->numa_nodes)
978+
p->numa_nodes = strdup("-1");
979+
970980
grpid = nvme_get_path_attr(p, "ana_grpid");
971981
if (grpid) {
972982
sscanf(grpid, "%d", &p->grpid);

src/nvme/tree.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,14 @@ const char *nvme_path_get_sysfs_dir(nvme_path_t p);
867867
*/
868868
const char *nvme_path_get_ana_state(nvme_path_t p);
869869

870+
/**
871+
* nvme_path_get_numa_nodes() - NUMA nodes of an nvme_path_t object
872+
* @p : &nvme_path_t object
873+
*
874+
* Return: NUMA nodes associated to @p
875+
*/
876+
const char *nvme_path_get_numa_nodes(nvme_path_t p);
877+
870878
/**
871879
* nvme_path_get_queue_depth() - Queue depth of an nvme_path_t object
872880
* @p: &nvme_path_t object

0 commit comments

Comments
 (0)