From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: [PATCH 4/5] memzone: add iterator function Date: Fri, 02 May 2014 16:42:55 -0700 Message-ID: <20140502234406.153584277@vyatta.com> References: <20140502234251.707598579@vyatta.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 To: dev-VfR2kkLFssw@public.gmane.org Return-path: Content-Disposition: inline; filename=memzone-walk.patch List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces-VfR2kkLFssw@public.gmane.org Sender: "dev" When doing diagnostic function, it is useful to have a ability to iterate over all memzones. Signed-off-by: Stephen Hemminger --- a/lib/librte_eal/common/eal_common_memzone.c 2014-05-02 16:31:15.375587103 -0700 +++ b/lib/librte_eal/common/eal_common_memzone.c 2014-05-02 16:31:15.375587103 -0700 @@ -505,3 +505,20 @@ rte_eal_memzone_init(void) return 0; } + +/* Walk all reserved memory zones */ +void rte_memzone_walk(void (*func)(const struct rte_memzone *, void *), + void *arg) +{ + struct rte_mem_config *mcfg; + unsigned i; + + mcfg = rte_eal_get_configuration()->mem_config; + + rte_rwlock_read_lock(&mcfg->mlock); + for (i=0; imemzone[i].addr != NULL) + (*func)(&mcfg->memzone[i], arg); + } + rte_rwlock_read_unlock(&mcfg->mlock); +} --- a/lib/librte_eal/common/include/rte_memzone.h 2014-05-02 16:31:15.375587103 -0700 +++ b/lib/librte_eal/common/include/rte_memzone.h 2014-05-02 16:31:15.375587103 -0700 @@ -248,6 +248,17 @@ const struct rte_memzone *rte_memzone_lo */ void rte_memzone_dump(void); +/** + * Walk list of all memzones + * + * @param func + * Iterator function + * @param arg + * Argument passed to iterator + */ +void rte_memzone_walk(void (*func)(const struct rte_memzone *, void *arg), + void *arg); + #ifdef __cplusplus } #endif