From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 79E534CE7 for ; Thu, 14 Apr 2016 12:20:25 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id D644828F4A; Thu, 14 Apr 2016 12:19:41 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Cc: bruce.richardson@intel.com, stephen@networkplumber.org Date: Thu, 14 Apr 2016 12:19:52 +0200 Message-Id: <1460629199-32489-30-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1460629199-32489-1-git-send-email-olivier.matz@6wind.com> References: <1457540381-20274-1-git-send-email-olivier.matz@6wind.com> <1460629199-32489-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 29/36] mempool: create the internal ring when populating 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: Thu, 14 Apr 2016 10:20:26 -0000 Instead of creating the internal ring at mempool creation, do it when populating the mempool with the first memory chunk. The objective here is to simplify the change of external handler when it will be introduced. For instance, this will be possible: mp = rte_mempool_create_empty(...) rte_mempool_set_ext_handler(mp, my_handler) rte_mempool_populate_default() Signed-off-by: Olivier Matz --- lib/librte_mempool/rte_mempool.c | 12 +++++++++--- lib/librte_mempool/rte_mempool.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 5f9ec63..eaae5a0 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -324,6 +324,7 @@ rte_mempool_ring_create(struct rte_mempool *mp) return -rte_errno; mp->ring = r; + mp->flags |= MEMPOOL_F_RING_CREATED; return 0; } @@ -372,6 +373,14 @@ rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr, unsigned i = 0; size_t off; struct rte_mempool_memhdr *memhdr; + int ret; + + /* create the internal ring if not already done */ + if ((mp->flags & MEMPOOL_F_RING_CREATED) == 0) { + ret = rte_mempool_ring_create(mp); + if (ret < 0) + return ret; + } /* mempool is already populated */ if (mp->populated_size >= mp->size) @@ -696,9 +705,6 @@ rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, STAILQ_INIT(&mp->elt_list); STAILQ_INIT(&mp->mem_list); - if (rte_mempool_ring_create(mp) < 0) - goto exit_unlock; - /* * local_cache pointer is set even if cache_size is zero. * The local_cache points to just past the elt_pa[] array. diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 658d4a2..721d8e7 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -234,6 +234,7 @@ struct rte_mempool { #define MEMPOOL_F_NO_CACHE_ALIGN 0x0002 /**< Do not align objs on cache lines.*/ #define MEMPOOL_F_SP_PUT 0x0004 /**< Default put is "single-producer".*/ #define MEMPOOL_F_SC_GET 0x0008 /**< Default get is "single-consumer".*/ +#define MEMPOOL_F_RING_CREATED 0x0010 /**< Internal: ring is created */ /** * @internal When debug is enabled, store some statistics. -- 2.1.4