[dpdk-dev] [PATCH v3 3/3] mempool: allow for user-owned mempool caches
Lazaros Koromilas
l at nofutznetworks.com
Sat Jun 18 18:15:31 CEST 2016
On Fri, Jun 17, 2016 at 11:37 AM, Olivier Matz <olivier.matz at 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 at 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.
More information about the dev
mailing list