diff options
author | Florin Coras <fcoras@cisco.com> | 2020-02-09 18:09:31 +0000 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2020-02-10 20:12:40 +0000 |
commit | 4c9599574929f624a218b963d268d97799289945 (patch) | |
tree | d0fd96ed24813d9bfd88e681f676d598fb409350 /src/vppinfra/mem_dlmalloc.c | |
parent | f1ecb6555326f8a7d5bba6f56aa676f064675dc0 (diff) |
vppinfra: use vm memory allocator for numa mapping
Type: refactor
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I13b239cd572ae6dfaec07019d3d9b7c0ed3edcfa
Diffstat (limited to 'src/vppinfra/mem_dlmalloc.c')
-rw-r--r-- | src/vppinfra/mem_dlmalloc.c | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c index 38226e26f8f..d62bb740c6c 100644 --- a/src/vppinfra/mem_dlmalloc.c +++ b/src/vppinfra/mem_dlmalloc.c @@ -243,46 +243,25 @@ clib_mem_init_thread_safe (void *memory, uword memory_size) } void * -clib_mem_init_thread_safe_numa (void *memory, uword memory_size) +clib_mem_init_thread_safe_numa (void *memory, uword memory_size, u8 numa) { + clib_mem_vm_alloc_t alloc = { 0 }; + clib_error_t *err; void *heap; - unsigned long this_numa; - heap = - clib_mem_init_internal (memory, memory_size, - 0 /* do NOT clib_mem_set_heap */ ); - - ASSERT (heap); - - this_numa = os_get_numa_index (); - -#if HAVE_NUMA_LIBRARY > 0 - unsigned long nodemask = 1 << this_numa; - void *page_base; - unsigned long page_mask; - long rv; - - /* - * Bind the heap to the current thread's NUMA node. - * heap is not naturally page-aligned, so fix it. - */ - - page_mask = ~(clib_mem_get_page_size () - 1); - page_base = (void *) (((unsigned long) heap) & page_mask); - - clib_warning ("Bind heap at %llx size %llx to NUMA numa %d", - page_base, memory_size, this_numa); + alloc.size = memory_size; + alloc.flags = CLIB_MEM_VM_F_NUMA_FORCE; + alloc.numa_node = numa; + if ((err = clib_mem_vm_ext_alloc (&alloc))) + { + clib_error_report (err); + return 0; + } - rv = mbind (page_base, memory_size, MPOL_BIND /* mode */ , - &nodemask /* nodemask */ , - BITS (nodemask) /* max node number */ , - MPOL_MF_MOVE /* flags */ ); + heap = clib_mem_init_internal (memory, memory_size, + 0 /* do NOT clib_mem_set_heap */ ); - if (rv < 0) - clib_unix_warning ("mbind"); -#else - clib_warning ("mbind unavailable, can't bind to numa %d", this_numa); -#endif + ASSERT (heap); return heap; } |