Skip to contentSkip to conversation

ndctl: fail NUMA filtering when unsupported

PATCH In review Ross Zwisler 3 participants 3 messages Mar 9, 2018 – Mar 10, 2018 libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ndctl: fail NUMA filtering when unsupported

For systems that don't support NUMA, numactl gives a loud and fatal error:

  # numactl -N 0 ls
  numactl: This system does not support NUMA policy

Follow this model in ndctl for NUMA based filtering:

  # ./ndctl/ndctl list --numa-node=0
    Error: This system does not support NUMA

This is done instead of just quietly filtering out all dimms, regions and namespaces because the NUMA node they were trying to match didn't exist in the system.

---
 util/filter.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
util/filter.c +10 -0
index 291d7ed..fdc46a3 100644
@@ -14,7 +14,10 @@
 #include <string.h>
 #include <stdlib.h>
 #include <limits.h>
+#include <unistd.h>
+#include <sys/stat.h>
 #include <util/util.h>
+#include <sys/types.h>
 #include <ndctl/ndctl.h>
 #include <util/filter.h>
 #include <ndctl/libndctl.h>
@@ -328,6 +331,13 @@ int util_filter_walk(struct ndctl_ctx *ctx, struct util_filter_ctx *fctx,
 	}
 
 	if (param->numa_node && strcmp(param->numa_node, "all") != 0) {
+		struct stat st;
+
+		if (stat("/sys/devices/system/node", &st)) {
+			error("This system does not support NUMA\n");
+			return -EINVAL;
+		}
+
 		numa_node = strtol(param->numa_node, &end, 0);
 		if (end == param->numa_node || end[0]) {
 			error("invalid numa_node: '%s'\n", param->numa_node);
Signature · 6 lines
2.14.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
maintainer
#1 lore raw
Quoted 41 lines · Ross Zwisler

For systems that don't support NUMA, numactl gives a loud and fatal error:

  # numactl -N 0 ls
  numactl: This system does not support NUMA policy

Follow this model in ndctl for NUMA based filtering:

  # ./ndctl/ndctl list --numa-node=0
    Error: This system does not support NUMA

This is done instead of just quietly filtering out all dimms, regions and
namespaces because the NUMA node they were trying to match didn't exist in
the system.

---
 util/filter.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
util/filter.c +3 -0
index 291d7ed..fdc46a3 100644
@@ -14,7 +14,10 @@
 #include <string.h>
 #include <stdlib.h>
 #include <limits.h>
+#include <unistd.h>
+#include <sys/stat.h>
 #include <util/util.h>
+#include <sys/types.h>
 #include <ndctl/ndctl.h>
 #include <util/filter.h>
 #include <ndctl/libndctl.h>
@@ -328,6 +331,13 @@ int util_filter_walk(struct ndctl_ctx *ctx,
 struct util_filter_ctx *fctx,
 	}

util/filter.c int util_filter_walk(struct ndctl_ctx *ctx, · line 342

Quoted 10 lines
util/filter.c +6 -0
 
 	if (param->numa_node && strcmp(param->numa_node, "all") !=
 0) {
+		struct stat st;
+
+		if (stat("/sys/devices/system/node", &st)) {
+			error("This system does not support
 NUMA\n");
+			return -EINVAL;
+		}

Is it ok to just directly read sysfs here? Alternatively we could use the get_mempolicy syscall (like libnuma does) but that requires linking with -lnuma..

https://github.com/numactl/numactl/blob/master/libnuma.c#L800

Quoted 5 lines
util/filter.c +1 -0
+
util/filter.c +0 -0
 		numa_node = strtol(param->numa_node, &end, 0);
 		if (end == param->numa_node || end[0]) {
 			error("invalid numa_node: '%s'\n", param-
Quoted 1 line

numa_node);

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#2 lore raw
Quoted 58 lines · Vishal L
Quoted 41 lines · Ross Zwisler

For systems that don't support NUMA, numactl gives a loud and fatal error:

  # numactl -N 0 ls
  numactl: This system does not support NUMA policy

Follow this model in ndctl for NUMA based filtering:

  # ./ndctl/ndctl list --numa-node=0
    Error: This system does not support NUMA

This is done instead of just quietly filtering out all dimms, regions and
namespaces because the NUMA node they were trying to match didn't exist in
the system.

---
 util/filter.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
util/filter.c +3 -0
index 291d7ed..fdc46a3 100644
@@ -14,7 +14,10 @@
 #include <string.h>
 #include <stdlib.h>
 #include <limits.h>
+#include <unistd.h>
+#include <sys/stat.h>
 #include <util/util.h>
+#include <sys/types.h>
 #include <ndctl/ndctl.h>
 #include <util/filter.h>
 #include <ndctl/libndctl.h>
@@ -328,6 +331,13 @@ int util_filter_walk(struct ndctl_ctx *ctx,
 struct util_filter_ctx *fctx,
      }

util/filter.c int util_filter_walk(struct ndctl_ctx *ctx, · line 342

Quoted 10 lines
util/filter.c +6 -0
 
      if (param->numa_node && strcmp(param->numa_node, "all") !=
 0) {
+             struct stat st;
+
+             if (stat("/sys/devices/system/node", &st)) {
+                     error("This system does not support
 NUMA\n");
+                     return -EINVAL;
+             }

Is it ok to just directly read sysfs here? Alternatively we could use the get_mempolicy syscall (like libnuma does) but that requires linking with -lnuma..

Quoted 1 line

https://github.com/numactl/numactl/blob/master/libnuma.c#L800

I don't mind linking against libnuma if the goal is to mimic the behavior of numactl.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm