]> granicus.if.org Git - strace/commitdiff
bpf: print numa_node using xlat
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 2 Mar 2018 23:30:32 +0000 (00:30 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 12 Apr 2018 23:00:28 +0000 (23:00 +0000)
As the value of -1 has a special meaning.  The issue is complicated
by the fact that this constant is not exported by UAPI.

* xlat/numa_node.in: New file.
* bpf.c (BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)): Print numa_node field
using printxvals_ex with a special xlat style.

bpf.c
xlat/numa_node.in [new file with mode: 0644]

diff --git a/bpf.c b/bpf.c
index f45973dd08f3c9f51fa584865e8022b5824b22c8..8d69424061b168b27cdb4bc9878482d2d5ff45ab 100644 (file)
--- a/bpf.c
+++ b/bpf.c
@@ -46,6 +46,7 @@
 #include "xlat/bpf_attach_type.h"
 #include "xlat/bpf_attach_flags.h"
 #include "xlat/bpf_query_flags.h"
+#include "xlat/numa_node.h"
 
 /** Storage for all the data that is needed to be stored on entering. */
 struct bpf_priv_data {
@@ -134,8 +135,22 @@ BEGIN_BPF_CMD_DECODER(BPF_MAP_CREATE)
        PRINT_FIELD_U(", ", attr, max_entries);
        PRINT_FIELD_FLAGS(", ", attr, map_flags, bpf_map_flags, "BPF_F_???");
        PRINT_FIELD_FD(", ", attr, inner_map_fd, tcp);
-       if (attr.map_flags & BPF_F_NUMA_NODE)
-               PRINT_FIELD_U(", ", attr, numa_node);
+       if (attr.map_flags & BPF_F_NUMA_NODE) {
+               /*
+                * Kernel uses the value of -1 as a designation for "no NUMA
+                * node specified", and even uses NUMA_NO_NODE constant;
+                * however, the constant definition is not a part of UAPI
+                * headers, thus we can't simply print this named constant
+                * instead of the value. Let's force verbose xlat style instead
+                * in order to provide the information for the user while
+                * not hampering the availability to derive the actual value
+                * without the access to the kernel headers.
+                */
+               tprints(", numa_node=");
+               printxvals_ex(attr.numa_node, NULL,
+                             XLAT_STYLE_FMT_U | XLAT_STYLE_VERBOSE,
+                             numa_node, NULL);
+       }
 }
 END_BPF_CMD_DECODER(RVAL_DECODED | RVAL_FD)
 
diff --git a/xlat/numa_node.in b/xlat/numa_node.in
new file mode 100644 (file)
index 0000000..414b35a
--- /dev/null
@@ -0,0 +1 @@
+NUMA_NO_NODE -1U