From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 92CC3A49 for ; Fri, 21 Sep 2018 08:45:27 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20180921064526euoutp02ad6f8af7820f69a70b03490140d2618b~WV1CHVOsq0583105831euoutp02h for ; Fri, 21 Sep 2018 06:45:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180921064526euoutp02ad6f8af7820f69a70b03490140d2618b~WV1CHVOsq0583105831euoutp02h DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1537512326; bh=KSZMv5l7nA17gUOD16O8vfuNXHBry7Hyj+p8qwhzWMY=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=mxfJ3/zBIDtiZ7e5KmJjXIKCZwlVxXMhaElkO9/y5t06ZyFFa7AMwOq/Ip1fXLZDl /z/DqW98wMnJDizXXM5p8HFN7sjKlVhZugWwHFvtFHftUinCh8VdP33QOoZ8a30gV2 D18HUbG4QEKk0Kxa7sOWp4iNytJ+fiKGP8MPO6XY= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180921064525eucas1p240e173fb175e300f30964ab8d2067217~WV1BoF3XE1701917019eucas1p2J; Fri, 21 Sep 2018 06:45:25 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 41.D2.04441.58394AB5; Fri, 21 Sep 2018 07:45:25 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20180921064524eucas1p147ff66419605b9b141969e1a672196f9~WV1A0hUgX1031210312eucas1p1k; Fri, 21 Sep 2018 06:45:24 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20180921064524eusmtrp17c5118c85775bd4aeb0e7a1144b397a1~WV1AjuEMv2694026940eusmtrp1m; Fri, 21 Sep 2018 06:45:24 +0000 (GMT) X-AuditID: cbfec7f2-5c9ff70000001159-e5-5ba493854ab6 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 24.BA.04128.48394AB5; Fri, 21 Sep 2018 07:45:24 +0100 (BST) Received: from [106.109.129.180] (unknown [106.109.129.180]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20180921064524eusmtip20dfc8f4f581dbf4debcf8c564f5d330a~WV1AM3bF-2815928159eusmtip2j; Fri, 21 Sep 2018 06:45:24 +0000 (GMT) To: Anatoly Burakov , dev@dpdk.org Cc: solal.pirelli@gmail.com, stable@dpdk.org From: Ilya Maximets Date: Fri, 21 Sep 2018 09:47:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <7e4178219213303b982e505ae4cb4387d9d3814a.1537447684.git.anatoly.burakov@intel.com> Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNKsWRmVeSWpSXmKPExsWy7djP87qtk5dEG9x9L2Lx6N5iZot3n7Yz WVxp/8lucWLqDBaLfx1/2B1YPX4tWMrqsXPWXXaPxXteMnn0bVnFGMASxWWTkpqTWZZapG+X wJVxrOE7W8EMgYrFH18yNzBO4O1i5OSQEDCRON91i62LkYtDSGAFo0Tb2dnsEM4XRolnfRuh nM+MEk/uf2PsYuQAa3ly0xMivpxR4sjed1BFHxklpr1oAisSFnCQOHPdAmSFiICtxKf5d5hA bGYBHYkVz5cxgthsQPap1UfAbBYBVYn9HV9YQWxRgQiJIw8WgsV5BQ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OQtMxC0jILScsCRpZVjCKppcW56bnFRnrFibnFpXnpesn5 uZsYgVG17djPLTsYu94FH2IU4GBU4uE1WLw4Wog1say4MvcQowQHs5II776uJdFCvCmJlVWp RfnxRaU5qcWHGE2BnpvILCWanA+M+LySeENTQ3MLS0NzY3NjMwslcd7zBpVRQgLpiSWp2amp BalFMH1MHJxSDYylyzS6BVKOTi1rmO9xwehIUZ/pxIu1Dg5nvzh5L63ZpP9NhXXzylX6d0Q3 9T3nPKEgcIpp1wzhK16eE1/rTXupYrQ+zW4uT/NlJeZ91ixdW/Ye3Dpl11PjFX+eZQtrxMmK MGtMlTu61uZjIbPyipqk9cs/unqpdnWE1q9VPKsYesdWKuTbEi0lluKMREMt5qLiRACTVgz+ wAIAAA== Message-Id: <20180921064524eucas1p147ff66419605b9b141969e1a672196f9~WV1A0hUgX1031210312eucas1p1k@eucas1p1.samsung.com> X-CMS-MailID: 20180921064524eucas1p147ff66419605b9b141969e1a672196f9 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20180920125054epcas2p26c547d287926ed85abad1fe3fbb4ec59 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180920125054epcas2p26c547d287926ed85abad1fe3fbb4ec59 References: <2624b855f3454691212cdb244f04926631c391a2.1535544966.git.anatoly.burakov@intel.com> <7e4178219213303b982e505ae4cb4387d9d3814a.1537447684.git.anatoly.burakov@intel.com> Subject: Re: [dpdk-stable] [PATCH v2] mem: fix undefined behavior in NUMA code X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Sep 2018 06:45:27 -0000 On 20.09.2018 15:50, Anatoly Burakov wrote: > When NUMA-aware hugepages config option is set, we rely on > libnuma to tell the kernel to allocate hugepages on a specific > NUMA node. However, we allocate node mask before we check if > NUMA is available in the first place, which, according to > the manpage [1], causes undefined behaviour. > > Fix by only using nodemask when we have NUMA available. > > [1] https://linux.die.net/man/3/numa_alloc_onnode > > Bugzilla ID: 20 > > Fixes: 1b72605d2416 ("mem: balanced allocation of hugepages") > Cc: i.maximets@samsung.com > Cc: stable@dpdk.org > > Signed-off-by: Anatoly Burakov > --- > lib/librte_eal/linuxapp/eal/eal_memory.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c > index dbf19499e..1a2a84a65 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > @@ -263,7 +263,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi, > int node_id = -1; > int essential_prev = 0; > int oldpolicy; > - struct bitmask *oldmask = numa_allocate_nodemask(); > + struct bitmask *oldmask = NULL; > bool have_numa = true; > unsigned long maxnode = 0; > > @@ -275,6 +275,7 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi, > > if (have_numa) { > RTE_LOG(DEBUG, EAL, "Trying to obtain current memory policy.\n"); > + oldmask = numa_allocate_nodemask(); > if (get_mempolicy(&oldpolicy, oldmask->maskp, > oldmask->size + 1, 0, 0) < 0) { > RTE_LOG(ERR, EAL, > @@ -401,8 +402,8 @@ map_all_hugepages(struct hugepage_file *hugepg_tbl, struct hugepage_info *hpi, > strerror(errno)); > numa_set_localalloc(); > } > + numa_free_cpumask(oldmask); > } > - numa_free_cpumask(oldmask); There will be 'oldmask' leak in case no 'socket-mem' requested. > #endif > return i; > } >