DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Chao Zhu <chaozhu@linux.vnet.ibm.com>
Cc: dev@dpdk.org, Gowrishankar <gowrishankar.m@linux.vnet.ibm.com>,
	sergio.gonzalez.monroy@intel.com, david.marchand@6wind.com
Subject: Re: [dpdk-dev] [PATCH 1/2] eal/ppc: fix mmap for memory initialization
Date: Thu, 20 Apr 2017 09:39:09 +0200	[thread overview]
Message-ID: <8100178.UKWLChnxCa@xps> (raw)
In-Reply-To: <1491473170-25160-2-git-send-email-chaozhu@linux.vnet.ibm.com>

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 <chaozhu@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;

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;

  parent reply	other threads:[~2017-04-20  7:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06 10:06 [dpdk-dev] [PATCH 0/2] ppc:Fix the memory initialization for IBM POWER Chao Zhu
2017-04-06 10:06 ` [dpdk-dev] [PATCH 1/2] eal/ppc: fix mmap for memory initialization Chao Zhu
2017-04-06 12:58   ` Sergio Gonzalez Monroy
2017-04-13  1:40     ` Chao Zhu
2017-04-13  8:14   ` Sergio Gonzalez Monroy
2017-04-20  7:41     ` Thomas Monjalon
2017-04-20  7:39   ` Thomas Monjalon [this message]
2017-04-06 10:06 ` [dpdk-dev] [PATCH 2/2] doc/guides: Add hugepage reserve instructions for IBM POWER Chao Zhu
2017-04-06 16:16   ` Mcnamara, John

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8100178.UKWLChnxCa@xps \
    --to=thomas@monjalon.net \
    --cc=chaozhu@linux.vnet.ibm.com \
    --cc=david.marchand@6wind.com \
    --cc=dev@dpdk.org \
    --cc=gowrishankar.m@linux.vnet.ibm.com \
    --cc=sergio.gonzalez.monroy@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).