From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <l@nofutznetworks.com>
Received: from mail-io0-f182.google.com (mail-io0-f182.google.com
 [209.85.223.182]) by dpdk.org (Postfix) with ESMTP id E95B8C452
 for <dev@dpdk.org>; Sat, 18 Jun 2016 18:15:32 +0200 (CEST)
Received: by mail-io0-f182.google.com with SMTP id 5so100373069ioy.1
 for <dev@dpdk.org>; Sat, 18 Jun 2016 09:15:32 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=nofutznetworks-com.20150623.gappssmtp.com; s=20150623;
 h=mime-version:in-reply-to:references:from:date:message-id:subject:to
 :cc; bh=+l1iqwdTDaQ9Sue/MYKbXMCZ3pdGTpngnFmf1LdtYvY=;
 b=TmWPyiraGp129it/Z81WbBzwdyz8y6IRl04ZIrN4AZPHD2Db0nnDV+YZXXKXE3Bnkt
 iZ6yoiM4pQSoYvp4ZFpnNa527+9Au8DZaCBuUKT7cZ2VRUloaydCtOOIrSAoQ4PeM/cC
 Ecj5nYMEXnuATUfHMnYk5sTNI8vQFovy7ciB/m+kQdlw8LMyEX4YOGgDei1B5Egia/n/
 WCOaapGkmicWIdHMck+0cNgS3Y37cw6k4sSMEiaCaSiGoMJrUWKgPgP5g25S5KYnSNMX
 AbBX3AuZMkd/SMoohr2j1/enQdicZYl87wMp5TL5t+589m4pCf+cFmyi7S37DL++QMPV
 w8OA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20130820;
 h=x-gm-message-state:mime-version:in-reply-to:references:from:date
 :message-id:subject:to:cc;
 bh=+l1iqwdTDaQ9Sue/MYKbXMCZ3pdGTpngnFmf1LdtYvY=;
 b=FjidlIPx9FhFFxh0ZqI0GvFjaabZwhKCI3NaRuq6rpAWutkacNUJzm12luS7+DM9wf
 YOvkUEhjfoLPTcObzod0tc6TeLf4uEsMLVjV/k0mp1wt4q4YME2MSb043B7QDCfGckwG
 ZPvKUcw8SCOHSzRKhcVnHso8FoTbprTPV1iT5oM9EISXFzl6r1IYO9F3prdTp6cyQKVW
 m9y1aHVppVYYk6KOeuEk6re5DSswwGgDcbSG/6Gvp1nl49L4ZbDEhm4iYFKtmyoVuaRc
 PJ5UYTNJ5Vdap2o0sxvgtdQl+jTCTbrolAfjjUnnZRLZTdleFqnDZSN2aP93x4X4hSni
 gZaw==
X-Gm-Message-State: ALyK8tLOH4mIn9u9tFmeSFL912MMubOWc7/nRwoDSiozcEYLd5etkojqpTPc5BMygJzH/20PVx/gRr29qUlaig==
X-Received: by 10.107.16.140 with SMTP id 12mr12085037ioq.98.1466266532269;
 Sat, 18 Jun 2016 09:15:32 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.107.199.134 with HTTP; Sat, 18 Jun 2016 09:15:31 -0700 (PDT)
In-Reply-To: <5763D2D5.3010209@6wind.com>
References: <1466074939-29863-1-git-send-email-l@nofutznetworks.com>
 <1466074939-29863-4-git-send-email-l@nofutznetworks.com>
 <5763D2D5.3010209@6wind.com>
From: Lazaros Koromilas <l@nofutznetworks.com>
Date: Sat, 18 Jun 2016 17:15:31 +0100
Message-ID: <CAHPNE8iqtEBD4EdoGt6fOvgMTpdrxdn+nMoLq1ZeG_whn8K9+Q@mail.gmail.com>
To: Olivier Matz <olivier.matz@6wind.com>
Cc: dev@dpdk.org, Konstantin Ananyev <konstantin.ananyev@intel.com>, 
 David Hunt <david.hunt@intel.com>
Content-Type: text/plain; charset=UTF-8
Subject: Re: [dpdk-dev] [PATCH v3 3/3] mempool: allow for user-owned mempool
	caches
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: Sat, 18 Jun 2016 16:15:33 -0000

On Fri, Jun 17, 2016 at 11:37 AM, Olivier Matz <olivier.matz@6wind.com> wrote:
>
>
> On 06/16/2016 01:02 PM, Lazaros Koromilas wrote:
>> The mempool cache is only available to EAL threads as a per-lcore
>> resource. Change this so that the user can create and provide their own
>> cache on mempool get and put operations. This works with non-EAL threads
>> too. This commit introduces the new API calls:
>>
>>     rte_mempool_cache_create(size, socket_id)
>>     rte_mempool_cache_free(cache)
>>     rte_mempool_cache_flush(cache, mp)
>>     rte_mempool_default_cache(mp, lcore_id)
>
> These new functions should be added in the .map file, else it will
> break the compilation in with shared_lib=y.

Oops, thanks!

>> Changes the API calls:
>>
>>     rte_mempool_generic_put(mp, obj_table, n, cache, flags)
>>     rte_mempool_generic_get(mp, obj_table, n, cache, flags)
>>
>> The cache-oblivious API calls use the per-lcore default local cache.
>>
>> Signed-off-by: Lazaros Koromilas <l@nofutznetworks.com>
>> ---
>>  app/test/test_mempool.c          |  94 ++++++++++++++++------
>>  app/test/test_mempool_perf.c     |  70 ++++++++++++++---
>>  lib/librte_mempool/rte_mempool.c |  66 +++++++++++++++-
>>  lib/librte_mempool/rte_mempool.h | 163 ++++++++++++++++++++++++++++-----------
>>  4 files changed, 310 insertions(+), 83 deletions(-)
>>
>> diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c
>> index 10d706f..723cd39 100644
>> --- a/app/test/test_mempool.c
>> +++ b/app/test/test_mempool.c
>> @@ -79,6 +79,9 @@
>>               printf("test failed at %s():%d\n", __func__, __LINE__); \
>>               return -1;                                              \
>>       } while (0)
>> +#define LOG_ERR() do {                                                       \
>> +             printf("test failed at %s():%d\n", __func__, __LINE__); \
>> +     } while (0)
>>
>
> I see that the usage of this macro is always like this:
>
>         LOG_ERR();
>         ret = -1;
>         goto out;
>
> What do you think of having:
>
> #define LOG_ERR() do {                                          \
>         printf("test failed at %s():%d\n", __func__, __LINE__); \
>         } while (0)
> #define RET_ERR() do { LOG_ERR(); return -1; } while (0)
> #define GOTO_ERR() do { LOG_ERR(); ret = -1; goto out; } while (0)
>
> Then use GOTO_ERR() when appropriate. It would also factorize
> the printf.

The downside of GOTO_ERR() is that it assumes a variable and a label
name. And you may need to have multiple labels 'out0', 'out1', etc for
the error path. How about:

#define GOTO_ERR(ret, out) do { LOG_ERR(); ret = -1; goto out; } while (0)

Lazaros.