diff options
author | Dave Barach <dave@barachs.net> | 2020-01-21 12:34:55 -0500 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2020-02-05 23:38:56 +0000 |
commit | a690fdbfe179e0ea65818c03b52535bf9210efd0 (patch) | |
tree | 345200955b873dbc2f5bb6857b1acc7966ffed90 /src/vppinfra/mem.h | |
parent | 86e8bce44f43c1f3c50a3397f9ab850f484f4cad (diff) |
vppinfra: numa vector placement support
Type: feature
Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I7e7d95a089dd849c1f01ecea84529d8dbf239f21
Diffstat (limited to 'src/vppinfra/mem.h')
-rw-r--r-- | src/vppinfra/mem.h | 54 |
1 files changed, 38 insertions, 16 deletions
diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h index d4819b7f989..5492e106d91 100644 --- a/src/vppinfra/mem.h +++ b/src/vppinfra/mem.h @@ -56,9 +56,46 @@ #include <vppinfra/sanitizer.h> #define CLIB_MAX_MHEAPS 256 +#define CLIB_MAX_NUMAS 8 + +/* Unspecified NUMA socket */ +#define VEC_NUMA_UNSPECIFIED (0xFF) /* Per CPU heaps. */ extern void *clib_per_cpu_mheaps[CLIB_MAX_MHEAPS]; +extern void *clib_per_numa_mheaps[CLIB_MAX_NUMAS]; + +always_inline void * +clib_mem_get_per_cpu_heap (void) +{ + int cpu = os_get_thread_index (); + return clib_per_cpu_mheaps[cpu]; +} + +always_inline void * +clib_mem_set_per_cpu_heap (u8 * new_heap) +{ + int cpu = os_get_thread_index (); + void *old = clib_per_cpu_mheaps[cpu]; + clib_per_cpu_mheaps[cpu] = new_heap; + return old; +} + +always_inline void * +clib_mem_get_per_numa_heap (u32 numa_id) +{ + ASSERT (numa_id >= 0 && numa_id < ARRAY_LEN (clib_per_numa_mheaps)); + return clib_per_numa_mheaps[numa_id]; +} + +always_inline void * +clib_mem_set_per_numa_heap (u8 * new_heap) +{ + int numa = os_get_numa_index (); + void *old = clib_per_numa_mheaps[numa]; + clib_per_numa_mheaps[numa] = new_heap; + return old; +} always_inline void clib_mem_set_thread_index (void) @@ -81,22 +118,6 @@ clib_mem_set_thread_index (void) ASSERT (__os_thread_index > 0); } -always_inline void * -clib_mem_get_per_cpu_heap (void) -{ - int cpu = os_get_thread_index (); - return clib_per_cpu_mheaps[cpu]; -} - -always_inline void * -clib_mem_set_per_cpu_heap (u8 * new_heap) -{ - int cpu = os_get_thread_index (); - void *old = clib_per_cpu_mheaps[cpu]; - clib_per_cpu_mheaps[cpu] = new_heap; - return old; -} - always_inline uword clib_mem_size_nocheck (void *p) { @@ -287,6 +308,7 @@ clib_mem_set_heap (void *heap) void *clib_mem_init (void *heap, uword size); void *clib_mem_init_thread_safe (void *memory, uword memory_size); +void *clib_mem_init_thread_safe_numa (void *memory, uword memory_size); void clib_mem_exit (void); |