From: Nicolas Dichtel Date: Thu, 23 May 2019 09:52:31 +0000 (+0200) Subject: mem: ease init in a docker container X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=2a96c88be83e3101c3915c2af8c03158aeb605a7;p=dpdk.git mem: ease init in a docker container move_pages() is only used to get the numa node id, but this function is not allowed by default in docker (it needs CAP_SYS_NICE and an update of the seccomp profile). get_mempolicy() also requires CAP_SYS_NICE but doesn't need any change in the default seccomp profile. Note that the returned value of move_pages() was not checked, thus some errors could be hidden (if the requested id was 0). Fixes: 582bed1e1d1d ("mem: support mapping hugepages at runtime") Cc: stable@dpdk.org Signed-off-by: Nicolas Dichtel Reviewed-by: Olivier Matz Reviewed-by: Didier Pallard Reviewed-by: David Marchand Acked-by: Anatoly Burakov --- diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c index b1849a28ad..2019636fbf 100644 --- a/lib/librte_eal/linux/eal/eal_memalloc.c +++ b/lib/librte_eal/linux/eal/eal_memalloc.c @@ -599,9 +599,13 @@ alloc_seg(struct rte_memseg *ms, void *addr, int socket_id, } #ifdef RTE_EAL_NUMA_AWARE_HUGEPAGES - move_pages(getpid(), 1, &addr, NULL, &cur_socket_id, 0); - - if (cur_socket_id != socket_id) { + ret = get_mempolicy(&cur_socket_id, NULL, 0, addr, + MPOL_F_NODE | MPOL_F_ADDR); + if (ret < 0) { + RTE_LOG(DEBUG, EAL, "%s(): get_mempolicy: %s\n", + __func__, strerror(errno)); + goto mapped; + } else if (cur_socket_id != socket_id) { RTE_LOG(DEBUG, EAL, "%s(): allocation happened on wrong socket (wanted %d, got %d)\n", __func__, socket_id, cur_socket_id);