From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58]) by dpdk.org (Postfix) with ESMTP id E7CCEAFDC for ; Tue, 15 Apr 2014 16:44:46 +0200 (CEST) Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1Wa4bJ-0001lx-6K; Tue, 15 Apr 2014 10:44:45 -0400 Date: Tue, 15 Apr 2014 10:44:40 -0400 From: Neil Horman To: David Marchand Message-ID: <20140415144440.GD3557@hmsreliant.think-freely.org> References: <1397569859-14460-1-git-send-email-david.marchand@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1397569859-14460-1-git-send-email-david.marchand@6wind.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Score: -2.9 (--) X-Spam-Status: No Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 1/2] mem: add write memory barrier before changing heap state 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, 15 Apr 2014 14:44:47 -0000 On Tue, Apr 15, 2014 at 03:50:58PM +0200, David Marchand wrote: > From: Didier Pallard > > a write memory barrier is needed before changing heap state > value, else some concurrent core may see state changing before > all initialization values are written to memory, causing > unpredictable results in malloc function. > > Signed-off-by: Didier Pallard > --- > lib/librte_malloc/malloc_heap.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/lib/librte_malloc/malloc_heap.c b/lib/librte_malloc/malloc_heap.c > index f4a0294..64668cb 100644 > --- a/lib/librte_malloc/malloc_heap.c > +++ b/lib/librte_malloc/malloc_heap.c > @@ -147,6 +147,7 @@ malloc_heap_init(struct malloc_heap *heap) > */ > heap->numa_socket = heap - mcfg->malloc_heaps; > rte_spinlock_init(&heap->lock); > + rte_wmb(); > heap->initialised = INITIALISED; > } > } > -- > 1.7.10.4 > > This certainly won't hurt anything, but from my read we have a fixed array of malloc_heaps in the mem_config array. It would seem to me that the more appropriate solution would be to initalize all of the malloc_heaps before starting any additional threads or processes that access the dpdk. I.e. call malloc_heap_init for every entry in the array during rte_eal_init. That prevents you from even needing to keep the ->initalized member around because its ready during the library initalization Neil