diff options
Diffstat (limited to 'src/vppinfra')
-rw-r--r-- | src/vppinfra/cpu.h | 17 |
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" |