From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id BA83B8DAE for ; Thu, 8 Sep 2016 10:13:47 +0200 (CEST) Received: from [37.164.124.82] (helo=[192.168.42.87]) by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1bhuVo-0005d0-Va; Thu, 08 Sep 2016 10:16:45 +0200 To: Weiliang Luo , dev@dpdk.org References: <1473305760-2420-1-git-send-email-droidluo@gmail.com> From: Olivier Matz Message-ID: Date: Thu, 8 Sep 2016 10:13:40 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 In-Reply-To: <1473305760-2420-1-git-send-email-droidluo@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] mempool: fix sp sc mempool bug 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: Thu, 08 Sep 2016 08:13:47 -0000 Hi Weiliang, On 09/08/2016 05:36 AM, Weiliang Luo wrote: > Signed-off-by: Weiliang Luo > --- > lib/librte_mempool/rte_mempool.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c > index 2e28e2e..350d77a 100644 > --- a/lib/librte_mempool/rte_mempool.c > +++ b/lib/librte_mempool/rte_mempool.c > @@ -879,7 +879,7 @@ rte_mempool_create(const char *name, unsigned n, unsigned elt_size, > * Since we have 4 combinations of the SP/SC/MP/MC examine the flags to > * set the correct index into the table of ops structs. > */ > - if (flags & (MEMPOOL_F_SP_PUT | MEMPOOL_F_SC_GET)) > + if ((flags & MEMPOOL_F_SP_PUT) && (flags & MEMPOOL_F_SC_GET)) > rte_mempool_set_ops_byname(mp, "ring_sp_sc", NULL); > else if (flags & MEMPOOL_F_SP_PUT) > rte_mempool_set_ops_byname(mp, "ring_sp_mc", NULL); > I would just change the title and add some explanation in the commit log. I suggest: """ mempool: fix corruption due to invalid handler When using rte_mempool_create(), the mempool handler is selected depending on the flags given by the user: - multi-consumer / multi-producer - multi-consumer / single-producer - single-consumer / multi-producer - single-consumer / single-producer The flags were not properly tested, resulting in the selection of sc/sp handler if sc/mp or mc/sp was asked. This can lead to corruption or crashes because the get/put operations are not atomic. Fixes: 449c49b93a6b ("mempool: support handler operations") Signed-off-by: Weiliang Luo Acked-by: Olivier Matz """ Thanks! Olivier