From mboxrd@z Thu Jan 1 00:00:00 1970 From: Olivier Matz Subject: Re: [RFC] hash/lpm: return NULL if the object exists Date: Fri, 25 Mar 2016 11:32:47 +0100 Message-ID: <56F513CF.4090604@6wind.com> References: <1458044745-32764-1-git-send-email-olivier.matz@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: "Richardson, Bruce" To: dev@dpdk.org Return-path: Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 98DC75588 for ; Fri, 25 Mar 2016 11:32:49 +0100 (CET) Received: by mail-wm0-f41.google.com with SMTP id p65so18540791wmp.0 for ; Fri, 25 Mar 2016 03:32:49 -0700 (PDT) In-Reply-To: <1458044745-32764-1-git-send-email-olivier.matz@6wind.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" Hi Bruce, On 03/15/2016 01:25 PM, Olivier Matz wrote: > Seen by trying to fix the func_reentrancy autotest. The test > was doing the following on several cores in parallel: > > name = "common_name"; > do several times { > obj = allocate_an_object(name) // obj = ring, mempool, hash, lpm, ... > if (obj == NULL && lookup(name) == NULL) > return TEST_FAIL; > } > > Issues: > > 1/ rings, mempools, hashs API are not coherent > rings and mempool return NULL if the object does not exist > hash and lpm return an object that was allocated allocated if > it already was allocated > > 2/ The hash/lpm API looks dangerous: when an object is returned, > the user does not know if it should be freed or not (no refcnt) > > 3/ There are some possible race conditions in cuckoo_hash as the > lock is not held in rte_hash_create(). We could find some cases > where NULL is returned when the object already exists (ex: when > rte_ring_create() fails). > > This patch tries to rationalize the APIs of lpm and hash. > > Signed-off-by: Olivier Matz Sorry, I forgot to CC you in the first mail. Do you have any opinion about this rfc patch? Thanks, Olivier