Skip region filtering if numa_node attribute is not present
PATCH 1/1 Skip region filtering if numa_node attribute is not present
For kernel versions older than 5.4, the numa_node attribute is not present for regions; due to which ndctl list -U 1 fails to list namespaces.
--- ndctl/lib/libndctl.c | 11 +++++++++++ ndctl/lib/libndctl.sym | 1 + ndctl/libndctl.h | 1 + util/filter.c | 12 +++++++++++- 4 files changed, 24 insertions(+), 1 deletion(-)
ndctl/lib/libndctl.c +11 -0
@@ -2471,6 +2471,17 @@ NDCTL_EXPORT struct ndctl_dimm *ndctl_region_get_next_dimm(struct ndctl_region *return NULL ; } +NDCTL_EXPORT int ndctl_region_has_numa_attr(struct ndctl_region *region) +{ +char *path = region->region_buf; + +sprintf (path,"%s/numa_node" , region->region_path); +if (access (path,F_OK ) !=-1 ) +return 1 ; + +return 0 ; +} + NDCTL_EXPORT int ndctl_region_get_numa_node(struct ndctl_region *region) {return region->numa_node;
ndctl/lib/libndctl.sym +1 -0
@@ -430,4 +430,5 @@ LIBNDCTL_23 { ndctl_region_get_target_node; ndctl_region_get_align; ndctl_region_set_align; + ndctl_region_has_numa_attr; } LIBNDCTL_22;
ndctl/libndctl.h +1 -0
@@ -385,6 +385,7 @@ struct ndctl_dimm *ndctl_region_get_first_dimm(struct ndctl_region *region);struct ndctl_dimm *ndctl_region_get_next_dimm (struct ndctl_region *region,struct ndctl_dimm *dimm);int ndctl_region_get_numa_node (struct ndctl_region *region); +int ndctl_region_has_numa_attr (struct ndctl_region *region);int ndctl_region_get_target_node (struct ndctl_region *region);struct ndctl_region *ndctl_bus_get_region_by_physical_address (struct ndctl_bus *bus,unsigned long long address);
util/filter.c +11 -1
@@ -467,7 +467,13 @@ int util_filter_walk(struct ndctl_ctx *ctx, struct util_filter_ctx *fctx, param->namespace))continue ; -if (numa_node !=NUMA_NO_NODE && +/* +* if numa_node attribute is not available for regions +* (which is true for pre 5.4 kernels), don't skip the +* region, let namespace filter handle the filtering. +*/ +if (ndctl_region_has_numa_attr (region) && + numa_node !=NUMA_NO_NODE &&ndctl_region_get_numa_node (region) != numa_node)continue ;
@@ -489,6 +495,10 @@ int util_filter_walk(struct ndctl_ctx *ctx, struct util_filter_ctx *fctx,if (param->mode &&util_nsmode (param->mode) != mode)continue ; +if (numa_node !=NUMA_NO_NODE && +ndctl_namespace_get_numa_node (ndns) != numa_node) +continue ; + fctx->filter_namespace (ndns, fctx); } }
Signature · 4 lines
2.25.2 _______________________________________________ Linux-nvdimm mailing list -- [email protected] To unsubscribe send an email to [email protected]
Quoted 18 lines · Santosh Sivaraj
For kernel versions older than 5.4, the
numa_nodeattribute is not present for regions; due to whichndctl list -U 1fails to list namespaces.Signed-off-by Santosh Sivaraj <[email protected]>--- ndctl/lib/libndctl.c | 11 +++++++++++ ndctl/lib/libndctl.sym | 1 + ndctl/libndctl.h | 1 + util/filter.c | 12 +++++++++++- 4 files changed, 24 insertions(+), 1 deletion(-)ndctl/lib/libndctl.c +0
-0
ndctl/lib/libndctl.c NDCTL_EXPORT struct ndctl_dimm *ndctl_region_get_next_dimm(struct ndctl_region * · line 2474
Quoted 4 lines
ndctl/lib/libndctl.c +1
-0@@ -2471,6 +2471,17 @@ NDCTL_EXPORT struct ndctl_dimm *ndctl_region_get_next_dimm(struct ndctl_region *return NULL ; } +NDCTL_EXPORT int ndctl_region_has_numa_attr(struct ndctl_region *region)
I'd shorten this to just ndctl_region_has_numa().
ndctl/lib/libndctl.c NDCTL_EXPORT struct ndctl_dimm *ndctl_region_get_next_dimm(struct ndctl_region * · line 2480
Quoted 6 lines
ndctl/lib/libndctl.c +6
-0+{ +char *path = region->region_buf; + +sprintf (path,"%s/numa_node" , region->region_path); +if (access (path,F_OK ) !=-1 ) +return 1 ;
You should be able to cache this result at the beginning of time at add_region() time to check for the ENOENT error return here:
sprintf(path, "%s/numa_node", region_base);
if (sysfs_read_attr(ctx, path, buf) == 0)
region->numa_node = strtol(buf, NULL, 0);
else
region->numa_node = -1;Quoted 35 lines
ndctl/lib/libndctl.c +4
-0+ +return 0 ; +} + NDCTL_EXPORT int ndctl_region_get_numa_node(struct ndctl_region *region) {return region->numa_node;ndctl/lib/libndctl.sym +1
-0@@ -430,4 +430,5 @@ LIBNDCTL_23 { ndctl_region_get_target_node; ndctl_region_get_align; ndctl_region_set_align; + ndctl_region_has_numa_attr; } LIBNDCTL_22;ndctl/libndctl.h +1
-0@@ -385,6 +385,7 @@ struct ndctl_dimm *ndctl_region_get_first_dimm(struct ndctl_region *region);struct ndctl_dimm *ndctl_region_get_next_dimm (struct ndctl_region *region,struct ndctl_dimm *dimm);int ndctl_region_get_numa_node (struct ndctl_region *region); +int ndctl_region_has_numa_attr (struct ndctl_region *region);int ndctl_region_get_target_node (struct ndctl_region *region);struct ndctl_region *ndctl_bus_get_region_by_physical_address (struct ndctl_bus *bus,unsigned long long address);util/filter.c +0
-0@@ -467,7 +467,13 @@ int util_filter_walk(struct ndctl_ctx *ctx, struct util_filter_ctx *fctx, param->namespace))
util/filter.c int util_filter_walk(struct ndctl_ctx *ctx, struct util_filter_ctx *fctx, · line 476
Quoted 10 lines
util/filter.c +7
-1continue ; - if (numa_node != NUMA_NO_NODE && +/* +* if numa_node attribute is not available for regions +* (which is true for pre 5.4 kernels), don't skip the +* region, let namespace filter handle the filtering. +*/ + if (ndctl_region_has_numa_attr(region) && + numa_node != NUMA_NO_NODE &&
This should also check that namespaces are being requested otherwise failing here is the right thing to do. An error message stating that the kernel lacks region-numa support when no namespaces are present would also be useful.
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]