From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 670875962 for ; Tue, 16 Aug 2016 14:32:43 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 16 Aug 2016 05:32:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,529,1464678000"; d="scan'208";a="1015217353" Received: from smonroyx-mobl.ger.corp.intel.com (HELO [10.237.220.36]) ([10.237.220.36]) by orsmga001.jf.intel.com with ESMTP; 16 Aug 2016 05:32:42 -0700 To: Jim Harris , dev@dpdk.org References: <20160815181708.5586.26252.stgit@jrharri1-mac> From: Sergio Gonzalez Monroy Message-ID: <77d8fc36-625f-f898-ddef-0ffc19a8820b@intel.com> Date: Tue, 16 Aug 2016 13:32:40 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <20160815181708.5586.26252.stgit@jrharri1-mac> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] contigmem: zero all pages during mmap X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Aug 2016 12:32:43 -0000 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 > Tested-by: Daniel Verkamp > Signed-off-by: Jim Harris > --- > 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