From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by dpdk.org (Postfix) with ESMTP id 427493775 for ; Wed, 13 May 2015 20:59:30 +0200 (CEST) Received: by wicmx19 with SMTP id mx19so17718586wic.0 for ; Wed, 13 May 2015 11:59:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=QiLe7HAjw56T3L/T8WxbAyGyT5/b9HhMiWDxcRa2/oU=; b=XoIdLmYjfKKE2r3xBMwm9+OSat1kv8EOM/wmAv6dXhYrJqaSrZS9WHrVKg+9++tnHf 8vD8f38tl6QkLSp9FzJUb09c6y5CHiGoWEuObnUAIQNiTHov4RJ8Dfm27BGkPlJ3/6fm 53z4Xpg9iT3RTY1NO4UKlCcH+S3ikFrW42OQIX/C8vNxLpEEQ0MjfytJQ0Z7FKwtgMFg N4rpZxK3Ah/7vgiRTr9pMrNHYOGueDQ/zECFIzuXu7PZ1G+xotVlSTyoXiEhKnYegJAS UYI9A02ECbXza5BsOXKErfnMnFOwj77vPIbeJTZXawCSzZMfP+wwBGp6khg5Akf1+T/C VY9w== X-Gm-Message-State: ALoCoQlqhPN/195xxTyU9HmV7OTypN2Czm8gxZ0wY7P++Xa/vjDthmfDZo4I9o2U2wJw2wgGEA3B X-Received: by 10.194.236.225 with SMTP id ux1mr735723wjc.52.1431543570097; Wed, 13 May 2015 11:59:30 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id gt10sm5876270wib.20.2015.05.13.11.59.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 13 May 2015 11:59:29 -0700 (PDT) From: Zoltan Kiss To: dev@dpdk.org Date: Wed, 13 May 2015 19:59:14 +0100 Message-Id: <1431543554-442-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [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: Wed, 13 May 2015 18:59:30 -0000 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 -- 1.9.1