From patchwork Wed May 22 15:41:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Dichtel X-Patchwork-Id: 53623 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id F29E114EC; Wed, 22 May 2019 17:41:57 +0200 (CEST) Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id B19C3A69 for ; Wed, 22 May 2019 17:41:56 +0200 (CEST) Received: from bretzel.dev.6wind.com (unknown [10.16.0.19]) by proxy.6wind.com (Postfix) with ESMTPS id 8D6162B9160; Wed, 22 May 2019 17:41:56 +0200 (CEST) Received: from dichtel by bretzel.dev.6wind.com with local (Exim 4.89) (envelope-from ) id 1hTTNM-00026w-8E; Wed, 22 May 2019 17:41:56 +0200 From: Nicolas Dichtel To: dev@dpdk.org Cc: Anatoly Burakov , Nicolas Dichtel , Olivier Matz , Didier Pallard Date: Wed, 22 May 2019 17:41:43 +0200 Message-Id: <20190522154143.8041-1-nicolas.dichtel@6wind.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH] librte_eal: ease init in a docker container X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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). Signed-off-by: Nicolas Dichtel Reviewed-by: Olivier Matz Reviewed-by: Didier Pallard Acked-by: Anatoly Burakov --- lib/librte_eal/linux/eal/eal_memalloc.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/linux/eal/eal_memalloc.c b/lib/librte_eal/linux/eal/eal_memalloc.c index 1e9ebb86dd1b..438faa0ab168 100644 --- a/lib/librte_eal/linux/eal/eal_memalloc.c +++ b/lib/librte_eal/linux/eal/eal_memalloc.c @@ -600,9 +600,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);