diff options
author | Florin Coras <fcoras@cisco.com> | 2024-07-22 12:09:53 -0700 |
---|---|---|
committer | Damjan Marion <dmarion@0xa5.net> | 2024-07-23 07:41:56 +0000 |
commit | 1f870c9bdc4f2ce4076b1faeb42878a41125fd76 (patch) | |
tree | a0a8a4aaa873ee77e6b0f57e7efe063cb59623d7 /src/vppinfra/linux/mem.c | |
parent | 3ac2ac532497024725e19fdd6f33ecbfceb9ff05 (diff) |
vppinfra: get_mempolicy instead of move_pages for mem init
Use get_mempolicy instead of move_pages to detect numa nodes. Avoids
issues whereby move_pages could stall if another rt thread spin waits
instead of yielding the cpu.
Type: improvement
Signed-off-by: Tatsushi Kanemoto <t-kanemoto@fujitsu.com>
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I7db2073ed82bb0b1e707130d9bd8f54bea333840
Diffstat (limited to 'src/vppinfra/linux/mem.c')
-rw-r--r-- | src/vppinfra/linux/mem.c | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c index 21aaa55fc00..17b4412e6c9 100644 --- a/src/vppinfra/linux/mem.c +++ b/src/vppinfra/linux/mem.c @@ -101,11 +101,13 @@ legacy_get_log2_default_hugepage_size (void) void clib_mem_main_init (void) { + unsigned long nodemask = 0, maxnode = CLIB_MAX_NUMAS; + unsigned long flags = MPOL_F_MEMS_ALLOWED; clib_mem_main_t *mm = &clib_mem_main; long sysconf_page_size; uword page_size; - void *va; - int fd; + void *va = 0; + int fd, mode; if (mm->log2_page_sz != CLIB_MEM_PAGE_SZ_UNKNOWN) return; @@ -131,23 +133,8 @@ clib_mem_main_init (void) mm->log2_sys_default_hugepage_sz = mm->log2_default_hugepage_sz; /* numa nodes */ - va = mmap (0, page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | - MAP_ANONYMOUS, -1, 0); - if (va == MAP_FAILED) - return; - - if (mlock (va, page_size)) - goto done; - - for (int i = 0; i < CLIB_MAX_NUMAS; i++) - { - int status; - if (syscall (__NR_move_pages, 0, 1, &va, &i, &status, 0) == 0) - mm->numa_node_bitmap |= 1ULL << i; - } - -done: - munmap (va, page_size); + if (syscall (__NR_get_mempolicy, &mode, &nodemask, maxnode, va, flags) == 0) + mm->numa_node_bitmap = nodemask; } __clib_export u64 |