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 BAAA137AA for ; Wed, 9 Mar 2016 17:22:15 +0100 (CET) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id B2D53249A0 for ; Wed, 9 Mar 2016 17:21:32 +0100 (CET) From: Olivier Matz To: dev@dpdk.org Date: Wed, 9 Mar 2016 17:19:35 +0100 Message-Id: <1457540381-20274-30-git-send-email-olivier.matz@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1457540381-20274-1-git-send-email-olivier.matz@6wind.com> References: <1457540381-20274-1-git-send-email-olivier.matz@6wind.com> Subject: [dpdk-dev] [RFC 29/35] 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: Wed, 09 Mar 2016 16:22:17 -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 0f4cb4e..2546740 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -326,6 +326,7 @@ rte_mempool_ring_create(struct rte_mempool *mp) return -rte_errno; mp->ring = r; + mp->flags |= MEMPOOL_F_RING_CREATED; return 0; } @@ -374,6 +375,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) @@ -698,9 +707,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 47743a6..e0549c6 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