Store numa-noda and cpu-index in vlib_main_t
[vpp.git] / src / vppinfra / cpu.h
index 6dc0a23..8341eaf 100644 (file)
@@ -16,6 +16,7 @@
 #ifndef included_clib_cpu_h
 #define included_clib_cpu_h
 
+#include <sys/syscall.h>
 #include <vppinfra/format.h>
 
 /*
@@ -99,6 +100,22 @@ _ (asimddp,    20) \
 _ (sha512,     21) \
 _ (sve,        22)
 
+static inline u32
+clib_get_current_cpu_index ()
+{
+  unsigned cpu, node;
+  syscall (__NR_getcpu, &cpu, &node, 0);
+  return cpu;
+}
+
+static inline u32
+clib_get_current_numa_node ()
+{
+  unsigned cpu, node;
+  syscall (__NR_getcpu, &cpu, &node, 0);
+  return node;
+}
+
 #if defined(__x86_64__)
 #include "cpuid.h"