From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 0F1FF2BAE for ; Thu, 20 Apr 2017 09:39:11 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id A9FBC207F5; Thu, 20 Apr 2017 03:39:10 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Thu, 20 Apr 2017 03:39:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=pB4Exass6ITM8+x Yc3dM7KP2WWAxBA5AU1EERmxxr70=; b=dIry3KJui/xKCtnwyzYZFSfOGU2XE8f V1wfCLrebetyTCcyU584DfVK2TMB/2CLr0Zox6cj6wAJvlOfe38yhgfLFnYa/VUl IpSMV09U7s0JFFGWMrtHAscFsJIAFaJSGm5I4F9aJAtcjgfJKqyRn/18v1zvWpgR 5HGBOe9iQuZo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=pB4Exass6ITM8+xYc3dM7KP2WWAxBA5AU1EERmxxr70=; b=mXLdpeSp BLYpAAdyih5KBTSOD4xoexYwvQFne++ckOA+fEnReguYwJ1cDHCQMi/tyhJBZ04P N/Wd/kxJL5Uo0ssPoKNUghPY6xYMYsPnnMsQZLZWROE+BvBb5na7O7Lce6dMruxy oFi9/7PK/8FRkr3Q0QJw+cGotJozLSGEDw24q/xnvdFX4ZVG4R/pz8uVL28vDT92 M227YoPV3o+d0txrGuZ3fyiAsSEcODZVYzTt19BCx6VuBvgxkjmKrGt5fzVATEaC hCyzgu0LPY8ndUddgmWLLCUfPISzDmbH1Sk2fBy5w5OvLrxJsbFRl1IAwOg+QC+Z t9oYgq8wCEswgQ== X-ME-Sender: X-Sasl-enc: VbJjcZhTYLxnSQell/wGKge1SyyFD6LeaePrkVT38IhE 1492673950 Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 3D0E7241E3; Thu, 20 Apr 2017 03:39:10 -0400 (EDT) From: Thomas Monjalon To: Chao Zhu Cc: dev@dpdk.org, Gowrishankar , sergio.gonzalez.monroy@intel.com, david.marchand@6wind.com Date: Thu, 20 Apr 2017 09:39:09 +0200 Message-ID: <8100178.UKWLChnxCa@xps> In-Reply-To: <1491473170-25160-2-git-send-email-chaozhu@linux.vnet.ibm.com> References: <1491473170-25160-1-git-send-email-chaozhu@linux.vnet.ibm.com> <1491473170-25160-2-git-send-email-chaozhu@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH 1/2] eal/ppc: fix mmap for memory initialization 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: , X-List-Received-Date: Thu, 20 Apr 2017 07:39:11 -0000 06/04/2017 12:06, Chao Zhu: > On IBM POWER platform, when mapping /dev/zero file to hugepage memory > space, mmap will not respect the requested address hint. This will cause > the memory initilization for the second process fails. This patch adds > the required mmap flags to make it work. Beside this, users need to set > the nr_overcommit_hugepages to expand the VA range. When > doing the initilization, users need to set both nr_hugepages and > nr_overcommit_hugepages to the same value, like 64, 128, etc. > > Signed-off-by: Chao Zhu > --- > lib/librte_eal/linuxapp/eal/eal_memory.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c > b/lib/librte_eal/linuxapp/eal/eal_memory.c index a956bb2..e06186b 100644 > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c > @@ -313,7 +313,11 @@ int rte_xen_dom0_supported(void) > } > do { > addr = mmap(addr, > +#ifndef RTE_ARCH_PPC_64 > (*size) + hugepage_sz, PROT_READ, MAP_PRIVATE, fd, 0); > +#else > + (*size) + hugepage_sz, PROT_READ, MAP_PRIVATE | > MAP_ANONYMOUS | MAP_HUGETLB, fd, 0); +#endif > if (addr == MAP_FAILED) > *size -= hugepage_sz; > } while (addr == MAP_FAILED && *size > 0); > @@ -1330,7 +1334,11 @@ static int huge_wrap_sigsetjmp(void) > * use mmap to get identical addresses as the primary process. > */ > base_addr = mmap(mcfg->memseg[s].addr, mcfg->memseg[s].len, > +#ifndef RTE_ARCH_PPC_64 > PROT_READ, MAP_PRIVATE, fd_zero, 0); > +#else > + PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, > fd_zero, 0); +#endif > if (base_addr == MAP_FAILED || > base_addr != mcfg->memseg[s].addr) { > max_seg = s; Indentation and line length are wrong. Changed to this: --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -331,7 +331,13 @@ get_virtual_area(size_t *size, size_t hugepage_sz) } do { addr = mmap(addr, - (*size) + hugepage_sz, PROT_READ, MAP_PRIVATE, fd, 0); + (*size) + hugepage_sz, PROT_READ, +#ifdef RTE_ARCH_PPC_64 + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, +#else + MAP_PRIVATE, +#endif + fd, 0); if (addr == MAP_FAILED) *size -= hugepage_sz; } while (addr == MAP_FAILED && *size > 0); @@ -1359,7 +1365,13 @@ rte_eal_hugepage_attach(void) * use mmap to get identical addresses as the primary process. */ base_addr = mmap(mcfg->memseg[s].addr, mcfg->memseg[s].len, - PROT_READ, MAP_PRIVATE, fd_zero, 0); + PROT_READ, +#ifdef RTE_ARCH_PPC_64 + MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, +#else + MAP_PRIVATE, +#endif + fd_zero, 0); if (base_addr == MAP_FAILED || base_addr != mcfg->memseg[s].addr) { max_seg = s;