From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zoltan Kiss Subject: Re: [PATCH] mempool: limit cache_size Date: Mon, 18 May 2015 13:50:20 +0100 Message-ID: <5559E00C.3050708@linaro.org> References: <1431543554-442-1-git-send-email-zoltan.kiss@linaro.org> <5559DAC1.8050106@linaro.org> <2601191342CEEE43887BDE71AB9772582142FA3B@irsmsx105.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit To: "Ananyev, Konstantin" , "dev@dpdk.org" Return-path: Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by dpdk.org (Postfix) with ESMTP id ADC38377C for ; Mon, 18 May 2015 14:50:21 +0200 (CEST) Received: by wicmc15 with SMTP id mc15so88362415wic.1 for ; Mon, 18 May 2015 05:50:21 -0700 (PDT) In-Reply-To: <2601191342CEEE43887BDE71AB9772582142FA3B@irsmsx105.ger.corp.intel.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" On 18/05/15 13:41, Ananyev, Konstantin wrote: > > >> -----Original Message----- >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Zoltan Kiss >> Sent: Monday, May 18, 2015 1:28 PM >> To: dev@dpdk.org >> Subject: Re: [dpdk-dev] [PATCH] mempool: limit cache_size >> >> Hi, >> >> Any opinion on this patch? >> >> Regards, >> >> Zoltan >> >> On 13/05/15 19:59, Zoltan Kiss wrote: >>> Otherwise cache_flushthresh can be bigger than n, and >>> a consumer can starve others by keeping every element >>> either in use or in the cache. >>> >>> Signed-off-by: Zoltan Kiss >>> --- >>> lib/librte_mempool/rte_mempool.c | 3 ++- >>> lib/librte_mempool/rte_mempool.h | 2 +- >>> 2 files changed, 3 insertions(+), 2 deletions(-) >>> >>> diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c >>> index cf7ed76..ca6cd9c 100644 >>> --- a/lib/librte_mempool/rte_mempool.c >>> +++ b/lib/librte_mempool/rte_mempool.c >>> @@ -440,7 +440,8 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size, >>> mempool_list = RTE_TAILQ_CAST(rte_mempool_tailq.head, rte_mempool_list); >>> >>> /* asked cache too big */ >>> - if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE) { >>> + if (cache_size > RTE_MEMPOOL_CACHE_MAX_SIZE || >>> + (uint32_t) cache_size * CACHE_FLUSHTHRESH_MULTIPLIER > n) { >>> rte_errno = EINVAL; >>> return NULL; >>> } > > Why just no 'cache_size > n' then? The commit message says: "Otherwise cache_flushthresh can be bigger than n, and a consumer can starve others by keeping every element either in use or in the cache." > Konstantin > >>> diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h >>> index 9001312..a4a9610 100644 >>> --- a/lib/librte_mempool/rte_mempool.h >>> +++ b/lib/librte_mempool/rte_mempool.h >>> @@ -468,7 +468,7 @@ typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *); >>> * If cache_size is non-zero, the rte_mempool library will try to >>> * limit the accesses to the common lockless pool, by maintaining a >>> * per-lcore object cache. This argument must be lower or equal to >>> - * CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE. It is advised to choose >>> + * CONFIG_RTE_MEMPOOL_CACHE_MAX_SIZE and n / 1.5. It is advised to choose >>> * cache_size to have "n modulo cache_size == 0": if this is >>> * not the case, some elements will always stay in the pool and will >>> * never be used. The access to the per-lcore table is of course >>>