[dpdk-dev] [PATCH 1/2] eal/ppc: fix mmap for memory initialization

Chao Zhu chaozhu at linux.vnet.ibm.com
Thu Apr 13 03:40:00 CEST 2017


Sergio,

Thanks for the comments!
On POWER, if it doesn't specify the MAP_HUGETLB flag when doing mapping, it
may get the addresses from other regions. However, the address space size of
hugepages is exactly the same as the value specified by user when doing
initialization. There will be not enough space for mmap twice in DPDK.
That's why we need to set the overcommit to expand the address space.

> -----Original Message-----
> From: Sergio Gonzalez Monroy [mailto:sergio.gonzalez.monroy at intel.com]
> Sent: 2017年4月6日 20:59
> To: Chao Zhu <chaozhu at linux.vnet.ibm.com>; dev at dpdk.org
> Cc: Gowrishankar <gowrishankar.m at linux.vnet.ibm.com>;
> david.marchand at 6wind.com
> Subject: Re: [PATCH 1/2] eal/ppc: fix mmap for memory initialization
> 
> Hi Chao,
> 
> You mentioned that 'mmap will not respect the requested address hint', how
> does the proposed change solves that?
> 
> Is it that hugepages map to a specific VA region, and without MAP_HUGETLB
> you may get address from wrong region?
> 
> If mmap were to respect the hinted address, we could do this change
> multi-arch without having to set overcommit hugepages?
> 
> fd = -1
> addr = mmap(addr, (*size) + hugepage_sz, PROT_READ, MAP_PRIVATE |
> MAP_ANONYMOUS | MAP_HUGETLB, fd, 0) # Free hugepages mapping addr =
> mmap(addr, (*size) + hugepage_sz, PROT_READ, MAP_PRIVATE |
> MAP_ANONYMOUS, fd, 0)
> 
> What do you think?
> 
> Regards,
> Sergio
> 
> On 06/04/2017 11:06, Chao Zhu wrote:
> > 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 <chaozhu at linux.vnet.ibm.com>
> > ---
> >   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;
> 




More information about the dev mailing list