summaryrefslogtreecommitdiffstats
path: root/src/vppinfra/cpu.h
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2019-01-19 23:45:36 +0100
committerFlorin Coras <florin.coras@gmail.com>2019-01-20 19:23:42 +0000
commit0a78fa17cbbeec8137ae823d3c5da8c6bec5ac6e (patch)
tree140c217c3a46ae5ef2bc898adadf5af0b4c75c0c /src/vppinfra/cpu.h
parent4d2f86a1ebcfc952080386603354c4767d2c8825 (diff)
Store numa-noda and cpu-index in vlib_main_t
Change-Id: If88ccd965122b9318a39a8d71b53334cd1fd81e4 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/cpu.h')
-rw-r--r--src/vppinfra/cpu.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/vppinfra/cpu.h b/src/vppinfra/cpu.h
index 6dc0a23e467..8341eaf0e54 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 @@ _ (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"