DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tiwei Bie <tiwei.bie@intel.com>
To: dev@dpdk.org
Cc: bruce.richardson@intel.com, stable@dpdk.org
Subject: [dpdk-dev] [PATCH] eal/bsd: don't zero the pages during mmap in contigmem
Date: Mon,  8 May 2017 08:09:16 +0000	[thread overview]
Message-ID: <20170508080916.4317-1-tiwei.bie@intel.com> (raw)

Don't zero the pages during mmap in contigmem. Instead, zero the
pages after mmap in primary process. Otherwise, the multi-process
support will be broken, as the pages will be zeroed when secondary
processes map the memory.

Fixes: 82f931805506 ("contigmem: zero all pages during mmap")
Cc: stable@dpdk.org

Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
 lib/librte_eal/bsdapp/contigmem/contigmem.c | 1 -
 lib/librte_eal/bsdapp/eal/eal_memory.c      | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/librte_eal/bsdapp/contigmem/contigmem.c b/lib/librte_eal/bsdapp/contigmem/contigmem.c
index da971debe..3826055f7 100644
--- a/lib/librte_eal/bsdapp/contigmem/contigmem.c
+++ b/lib/librte_eal/bsdapp/contigmem/contigmem.c
@@ -227,7 +227,6 @@ contigmem_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t size,
 	if (buffer_index >= contigmem_num_buffers)
 		return EINVAL;
 
-	memset(contigmem_buffers[buffer_index], 0, contigmem_buffer_size);
 	*offset = (vm_ooffset_t)vtophys(contigmem_buffers[buffer_index]);
 	*obj = vm_pager_allocate(OBJT_DEVICE, cdev, size, nprot, *offset,
 			curthread->td_ucred);
diff --git a/lib/librte_eal/bsdapp/eal/eal_memory.c b/lib/librte_eal/bsdapp/eal/eal_memory.c
index 3614da8db..a2809d66a 100644
--- a/lib/librte_eal/bsdapp/eal/eal_memory.c
+++ b/lib/librte_eal/bsdapp/eal/eal_memory.c
@@ -36,6 +36,7 @@
 #include <sys/sysctl.h>
 #include <inttypes.h>
 #include <fcntl.h>
+#include <string.h>
 
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
@@ -121,6 +122,8 @@ rte_eal_hugepage_init(void)
 			seg->nrank = mcfg->nrank;
 			seg->socket_id = 0;
 
+			memset(seg->addr, 0, seg->len);
+
 			RTE_LOG(INFO, EAL, "Mapped memory segment %u @ %p: physaddr:0x%"
 					PRIx64", len %zu\n",
 					seg_idx, addr, physaddr, hpi->hugepage_sz);
-- 
2.12.1

             reply	other threads:[~2017-05-08  8:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-08  8:09 Tiwei Bie [this message]
2017-05-08  8:53 ` Bruce Richardson
2017-05-08  9:13   ` Tiwei Bie

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=20170508080916.4317-1-tiwei.bie@intel.com \
    --to=tiwei.bie@intel.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \
    /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).