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 D4CEA1BBE for ; Thu, 14 Apr 2016 12:20:23 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 70E0228F34; Thu, 14 Apr 2016 12:19:40 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Cc: bruce.richardson@intel.com, stephen@networkplumber.org Date: Thu, 14 Apr 2016 12:19:30 +0200 Message-Id: <1460629199-32489-8-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 07/36] mempool: list objects when added in the mempool 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:24 -0000 Introduce a list entry in object header so they can be listed and browsed. The objective is to introduce a more simple way to browse the elements of a mempool. The next commits will update rte_mempool_obj_iter() to use this list, and remove the previous complex implementation. Signed-off-by: Olivier Matz --- lib/librte_mempool/rte_mempool.c | 2 ++ lib/librte_mempool/rte_mempool.h | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 99b3eab..83afda8 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -138,6 +138,7 @@ mempool_add_elem(struct rte_mempool *mp, void *obj, uint32_t obj_idx, /* set mempool ptr in header */ hdr = RTE_PTR_SUB(obj, sizeof(*hdr)); hdr->mp = mp; + STAILQ_INSERT_TAIL(&mp->elt_list, hdr, next); #ifdef RTE_LIBRTE_MEMPOOL_DEBUG hdr->cookie = RTE_MEMPOOL_HEADER_COOKIE2; @@ -585,6 +586,7 @@ rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size, mp->cache_size = cache_size; mp->cache_flushthresh = CALC_CACHE_FLUSHTHRESH(cache_size); mp->private_data_size = private_data_size; + STAILQ_INIT(&mp->elt_list); /* * local_cache pointer is set even if cache_size is zero. diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index da04021..469bcbc 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -150,11 +150,13 @@ struct rte_mempool_objsz { * Mempool object header structure * * Each object stored in mempools are prefixed by this header structure, - * it allows to retrieve the mempool pointer from the object. When debug - * is enabled, a cookie is also added in this structure preventing - * corruptions and double-frees. + * it allows to retrieve the mempool pointer from the object and to + * iterate on all objects attached to a mempool. When debug is enabled, + * a cookie is also added in this structure preventing corruptions and + * double-frees. */ struct rte_mempool_objhdr { + STAILQ_ENTRY(rte_mempool_objhdr) next; /**< Next in list. */ struct rte_mempool *mp; /**< The mempool owning the object. */ #ifdef RTE_LIBRTE_MEMPOOL_DEBUG uint64_t cookie; /**< Debug cookie. */ @@ -162,6 +164,11 @@ struct rte_mempool_objhdr { }; /** + * A list of object headers type + */ +STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr); + +/** * Mempool object trailer structure * * In debug mode, each object stored in mempools are suffixed by this @@ -194,6 +201,8 @@ struct rte_mempool { struct rte_mempool_cache *local_cache; /**< Per-lcore local cache */ + struct rte_mempool_objhdr_list elt_list; /**< List of objects in pool */ + #ifdef RTE_LIBRTE_MEMPOOL_DEBUG /** Per-lcore statistics. */ struct rte_mempool_debug_stats stats[RTE_MAX_LCORE]; -- 2.1.4