From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <olivier.matz@6wind.com>
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 <dev@dpdk.org>; Fri, 25 Mar 2016 11:32:49 +0100 (CET)
Received: by mail-wm0-f41.google.com with SMTP id p65so18540791wmp.0
 for <dev@dpdk.org>; Fri, 25 Mar 2016 03:32:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=6wind-com.20150623.gappssmtp.com; s=20150623;
 h=subject:to:references:cc:from:message-id:date:user-agent
 :mime-version:in-reply-to:content-transfer-encoding;
 bh=T50pOu13R0uNQ1wd0Ce3dYh0X9PE+lnpPFBt65/pEkc=;
 b=PHPyJZiPv4H6aKFR2zeuGqAv1TyEPYaOH/nBi/Z7PVGrEIrfBFP1uz0TyO/31Sl+LM
 /o5I1vapNPn9+k5Or8nYUF5eK+sLiYZS/rZb7I1cYvMVFsNEnsWfJIxac00f3WowH0VF
 kWjXd9/4x/tOloIS/yWjmh1bHDYnteA6glzIamg4s280LO8dipzJsibbX1BirnBkQei6
 FjysG50YhvhwEgvGpATCGUuKIC0kBfrjhp67LLRwNQPT6GwLIIEwfh8zdTMmhhD0qIH3
 WpA4//MBtB2Tl9JP75/R3QNfjPkBp5ecvuRUkeOwgtxdLqC6SFGhY/akNcgirUyRWaoG
 iNSQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:subject:to:references:cc:from:message-id:date
 :user-agent:mime-version:in-reply-to:content-transfer-encoding;
 bh=T50pOu13R0uNQ1wd0Ce3dYh0X9PE+lnpPFBt65/pEkc=;
 b=RsO2lkFt8VYJ3feeHSDrIo1kFHoVk34IGRfqBzm6hO3MqGpVBdR6c1rHADZWtfwYL6
 ojNJS3+xZJKdb1KskFcrKKUtYi39ChiwWOm4t/iwSgzAy1OzZA7iOcPGOs4q9Ea2V04t
 S+Ql482Z1lJFG0Skwh2cebNgHS1jae0MCGtJndmoUmkG6SrQS1US7nAqOKczx8sz0eo5
 YRfo2BvY18KZO5juSZWQaHanmdJVoPmtCnIztg/joltXbuxTXuuOzacgLiS8Tuyym9hD
 j9+XToi5ixwvwgoIbfSb3EqGraspTtZCyGyfHTB9wZGLdhLOnFd5vVhic0Gn1kbayO3m
 sAtw==
X-Gm-Message-State: AD7BkJIE7mn41Qpt3gCZnkVf5rzOWPhp/gsHV5puY/0I+PtHz7meGZGEnvFEWBXe1nZ8yK1q
X-Received: by 10.194.92.68 with SMTP id ck4mr14183217wjb.144.1458901969517;
 Fri, 25 Mar 2016 03:32:49 -0700 (PDT)
Received: from [192.168.0.10] (was59-1-82-226-113-214.fbx.proxad.net.
 [82.226.113.214])
 by smtp.gmail.com with ESMTPSA id ys9sm11310153wjc.35.2016.03.25.03.32.48
 (version=TLSv1/SSLv3 cipher=OTHER);
 Fri, 25 Mar 2016 03:32:48 -0700 (PDT)
To: dev@dpdk.org
References: <1458044745-32764-1-git-send-email-olivier.matz@6wind.com>
Cc: "Richardson, Bruce" <bruce.richardson@intel.com>
From: Olivier Matz <olivier.matz@6wind.com>
X-Enigmail-Draft-Status: N1110
Message-ID: <56F513CF.4090604@6wind.com>
Date: Fri, 25 Mar 2016 11:32:47 +0100
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101
 Icedove/38.6.0
MIME-Version: 1.0
In-Reply-To: <1458044745-32764-1-git-send-email-olivier.matz@6wind.com>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Fri, 25 Mar 2016 10:32:49 -0000

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 <olivier.matz@6wind.com>

Sorry, I forgot to CC you in the first mail. Do you have any opinion
about this rfc patch?

Thanks,
Olivier