From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 7E07D3990 for ; Fri, 25 Mar 2016 11:45:41 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 25 Mar 2016 03:45:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,390,1455004800"; d="scan'208";a="771270606" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.220.58]) by orsmga003.jf.intel.com with SMTP; 25 Mar 2016 03:45:38 -0700 Received: by (sSMTP sendmail emulation); Fri, 25 Mar 2016 10:45:38 +0025 Date: Fri, 25 Mar 2016 10:45:37 +0000 From: Bruce Richardson To: Olivier Matz Cc: dev@dpdk.org Message-ID: <20160325104537.GA18028@bricha3-MOBL3> References: <1458044745-32764-1-git-send-email-olivier.matz@6wind.com> <56F513CF.4090604@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56F513CF.4090604@6wind.com> Organization: Intel Shannon Ltd. User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [dpdk-dev] [RFC] hash/lpm: return NULL if the object exists 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: Fri, 25 Mar 2016 10:45:41 -0000 On Fri, Mar 25, 2016 at 11:32:47AM +0100, Olivier Matz wrote: > 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 Hi Olivier, the idea looks good, since an object already existing is an error condition on create. One small change to the libs I'd suggest is to set rte_errno to EEXIST before exit, so that the error reason is known to the app. Regards, /Bruce