From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f182.google.com (mail-wi0-f182.google.com [209.85.212.182]) by dpdk.org (Postfix) with ESMTP id 97B5DC312 for ; Mon, 18 May 2015 14:27:47 +0200 (CEST) Received: by wibt6 with SMTP id t6so67635254wib.0 for ; Mon, 18 May 2015 05:27:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=y9tTLPeY/snVCDwzQSFt/5CyNeLh2xy4xk6GvEJg7e4=; b=CLcfbVhd0MxRSJ/X+C/9+EF6eudCAVF6gnLnQgVIKvZ7JKzLV6r8XjF4ow/7RsCkSW IBGD5sKAJE4jszQT9LVzKkQ2CX43yjwL9iOVmiF9vVgr7UuyNB6rZYxke54oH7F1LYuw C8rvCQAINvQCS/jBAh62OkZ0OgTn7C0JMfOheDbURKkKL/R/U9QL+mM9JKwdaYcFP7Ig rJUGp+xE1TbBUYv9wgONxbcdEL9hc6/iulots4WchGmH1jXGAMr17eUxzwR2AqmBe0Be 1XYF6crYmwr4lOSxA0ixZSTkZJ9AsXHfTqLaDoD2mG+W79ufs9R4fv9zZT7mvfFBqXce j7Ow== X-Gm-Message-State: ALoCoQkimHsqy0CwsMDCNaVllvjSKgjVdcP3iO1i/iEmDHcr9BIWQBamuRaHkHoBLriYiA6T6q2L X-Received: by 10.194.122.105 with SMTP id lr9mr44615052wjb.153.1431952067426; Mon, 18 May 2015 05:27:47 -0700 (PDT) Received: from [192.168.0.101] ([90.152.119.35]) by mx.google.com with ESMTPSA id xy5sm16674629wjc.35.2015.05.18.05.27.46 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 May 2015 05:27:46 -0700 (PDT) Message-ID: <5559DAC1.8050106@linaro.org> Date: Mon, 18 May 2015 13:27:45 +0100 From: Zoltan Kiss User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: dev@dpdk.org References: <1431543554-442-1-git-send-email-zoltan.kiss@linaro.org> In-Reply-To: <1431543554-442-1-git-send-email-zoltan.kiss@linaro.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] mempool: limit cache_size 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: Mon, 18 May 2015 12:27:47 -0000 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; > } > 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 >