From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: Re: [PATCH 26/36] mempool: introduce a function to create an empty mempool Date: Fri, 15 Apr 2016 09:42:32 +0200 Message-ID: <57109B68.5070807@6wind.com> References: <1457540381-20274-1-git-send-email-olivier.matz@6wind.com> <1460629199-32489-1-git-send-email-olivier.matz@6wind.com> <1460629199-32489-27-git-send-email-olivier.matz@6wind.com> <2176C989-77F0-4C88-B40D-BD97D58B9A20@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: "Richardson, Bruce" , "stephen@networkplumber.org" To: "Wiles, Keith" , "dev@dpdk.org" Return-path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 713DB28FD for ; Fri, 15 Apr 2016 09:42:38 +0200 (CEST) In-Reply-To: <2176C989-77F0-4C88-B40D-BD97D58B9A20@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On 04/14/2016 05:57 PM, Wiles, Keith wrote: >> Introduce a new function rte_mempool_create_empty() >> that allocates a mempool that is not populated. >> >> The functions rte_mempool_create() and rte_mempool_xmem_create() >> now make use of it, making their code much easier to read. >> Currently, they are the only users of rte_mempool_create_empty() >> but the function will be made public in next commits. >> >> Signed-off-by: Olivier Matz >> +/* create an empty mempool */ >> +static struct rte_mempool * >> +rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, >> + unsigned cache_size, unsigned private_data_size, >> + int socket_id, unsigned flags) >> { > > When two processes need to use the same mempool, do we have a race condition with one doing a rte_mempool_create_empty() and the other process tries to use it when it finds that mempool before being fully initialized by the first process? > I'm not an expert of the dpdk multiprocess model. But I would say that there are a lot of possible race conditions like this (ex: a port is created but not started), and I assume that applications doing multiprocess have their synchronization. If we really want a solution in mempool, we could: - remove the TAILQ_INSERT_TAIL() from rte_mempool_create() - create a new function rte_mempool_share() that adds the mempool in the tailq for multiprocess. This function would be called at the end of rte_mempool_create(), or by the user if using rte_mempool_create_empty(). I may be mistaking but I don't feel it's really required. Any comment from a multiprocess expert is welcome though. Regards, Olivier