DPDK patches and discussions
 help / color / mirror / Atom feed
From: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
To: Jim Harris <james.r.harris@intel.com>, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] contigmem: zero all pages during mmap
Date: Tue, 16 Aug 2016 13:32:40 +0100	[thread overview]
Message-ID: <77d8fc36-625f-f898-ddef-0ffc19a8820b@intel.com> (raw)
In-Reply-To: <20160815181708.5586.26252.stgit@jrharri1-mac>

On 15/08/2016 19:17, Jim Harris wrote:
> On Linux, all huge pages are zeroed by the kernel before
> first access by the DPDK application.  But on FreeBSD,
> the contigmem driver would only zero the contiguous
> memory regions during initial driver load.
>
> DPDK commit b78c91751 eliminated the explicit memset()
> operation for rte_zmalloc(), which was OK on Linux
> because the kernel zeroes the pages during app start,
> but this broke FreeBSD.  So this patch explicitly
> zeroes the pages before they are mmap'd, to ensure
> equivalent behavior to Linux
>
> Reported-by: Daniel Verkamp <daniel.verkamp@intel.com>
> Tested-by: Daniel Verkamp <daniel.verkamp@intel.com>
> Signed-off-by: Jim Harris <james.r.harris@intel.com>
> ---
>   lib/librte_eal/bsdapp/contigmem/contigmem.c |    8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/lib/librte_eal/bsdapp/contigmem/contigmem.c b/lib/librte_eal/bsdapp/contigmem/contigmem.c
> index c6ca3b9..da971de 100644
> --- a/lib/librte_eal/bsdapp/contigmem/contigmem.c
> +++ b/lib/librte_eal/bsdapp/contigmem/contigmem.c
> @@ -216,15 +216,19 @@ static int
>   contigmem_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t size,
>   		struct vm_object **obj, int nprot)
>   {
> +	uint64_t buffer_index;
> +
>   	/*
>   	 * The buffer index is encoded in the offset.  Divide the offset by
>   	 *  PAGE_SIZE to get the index of the buffer requested by the user
>   	 *  app.
>   	 */
> -	if ((*offset/PAGE_SIZE) >= contigmem_num_buffers)
> +	buffer_index = *offset / PAGE_SIZE;
> +	if (buffer_index >= contigmem_num_buffers)
>   		return EINVAL;
>   
> -	*offset = (vm_ooffset_t)vtophys(contigmem_buffers[*offset/PAGE_SIZE]);
> +	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);
>   
>
>

I think you should include the Fixes line:
Fixes: b78c9175118f ("mem: do not zero out memory on zmalloc")

Other than that:

Acked-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>

      reply	other threads:[~2016-08-16 12:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-15 18:17 Jim Harris
2016-08-16 12:32 ` Sergio Gonzalez Monroy [this message]

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=77d8fc36-625f-f898-ddef-0ffc19a8820b@intel.com \
    --to=sergio.gonzalez.monroy@intel.com \
    --cc=dev@dpdk.org \
    --cc=james.r.harris@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).