From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by dpdk.org (Postfix) with ESMTP id A0B99AFD8 for ; Sat, 3 May 2014 01:44:03 +0200 (CEST) Received: by mail-pa0-f50.google.com with SMTP id rd3so6150141pab.23 for ; Fri, 02 May 2014 16:44:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-type:content-disposition; bh=h4vV8kV8uPHCUugUR0w4MXNmrlsmKTyMYPSCmPtpK5c=; b=aM4AKFtN1B1pKQ/JBL2BE1ZmOMubEe413miVonG0gdOWf1qo77DmXYm9hvLiVBqjX0 IqNARc48HSB4h0Uh1JMouNkbNG8MDCp/DstD1w1haBjzuK0nV6MPrO6JWvQkVTxqAf8U RSEd+/fcefr6SSpB2N+9pWBA1+4LM5UII4eugJ8tt4Pttz+5MMnDKQn3yxQNm8sojXZ2 7T+XsFJVSzwbz2uiGFXxIl4eor7nPlrBnbXAXv0N0JaDlchTwCuwwqBnIBeSb9zTxCcG F0CjBq5uwALc9HTCh52JQW8Kis/+0sNH7Fbvqkl1q8j9Tq8N9rmPGFHmGeMe87xVNzlt DsGg== X-Gm-Message-State: ALoCoQk8VI6gnHiMwI5IkZYbM9J1PVPTm/rOE4gqE+SxaISCTMvW1Zc4u5zM8tibsEflrAo9NYXv X-Received: by 10.66.149.231 with SMTP id ud7mr41276700pab.8.1399074247786; Fri, 02 May 2014 16:44:07 -0700 (PDT) Received: from localhost (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id xg8sm3225087pac.26.2014.05.02.16.44.06 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 02 May 2014 16:44:07 -0700 (PDT) Message-Id: <20140502234406.153584277@vyatta.com> User-Agent: quilt/0.61-1 Date: Fri, 02 May 2014 16:42:55 -0700 From: Stephen Hemminger To: dev@dpdk.org References: <20140502234251.707598579@vyatta.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=memzone-walk.patch Subject: [dpdk-dev] [PATCH 4/5] memzone: add iterator function 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: Fri, 02 May 2014 23:44:04 -0000 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