Store numa-noda and cpu-index in vlib_main_t
Change-Id: If88ccd965122b9318a39a8d71b53334cd1fd81e4
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vppinfra/cpu.h b/src/vppinfra/cpu.h
index 6dc0a23..8341eaf 100644
--- a/src/vppinfra/cpu.h
+++ b/src/vppinfra/cpu.h
@@ -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 @@
_ (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"