From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43]) by dpdk.org (Postfix) with ESMTP id D362AAFD8 for ; Sat, 3 May 2014 01:44:01 +0200 (CEST) Received: by mail-pa0-f43.google.com with SMTP id rd3so6215743pab.2 for ; Fri, 02 May 2014 16:44:06 -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=jkkBMiRNseMeDPGOIqv2hDgUP5Du0Su+eiJs6k+VoFc=; b=Bk1Ww+E0NJrExnZ0p61A5qJ6iC45HSqBmyGVDEB7mqzj6KR2NJH8dBSgOx6r04Lo1I chgA6sJ/RrUlboE/zGcHhnB3aM/eBlD68i6YT4HnqZr+eicMwxgrxrnHf3i0Ka9L7L39 sl4qWN4zx0moXuTcjbJnt1Z6kgPG34t/VvhOtM+mpvSZoBYOF/Je7Cuy4ArLJgXPkoPj BB77XienE+49A2BNFJa7aAouuLM1gecekaY/qc93kZngFI07mSKU4e9+zHluAz3JLR/1 otIptV3SqraHDK0xVR/5XXqwd+7UxljkdnxmqeFATMiWu53Wds9f5jTtyALcUU8VRbSr xcrA== X-Gm-Message-State: ALoCoQmp4XOeNUHBCAo/oPnQgq0gu7VWc//5V0QS488OMHE2hbfpZgFPJfPFmhwfvC2fHsCA6N8Y X-Received: by 10.66.251.101 with SMTP id zj5mr9534415pac.154.1399074246107; Fri, 02 May 2014 16:44:06 -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 ry10sm3168491pab.38.2014.05.02.16.44.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 02 May 2014 16:44:05 -0700 (PDT) Message-Id: <20140502234404.328560724@vyatta.com> User-Agent: quilt/0.61-1 Date: Fri, 02 May 2014 16:42:54 -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=mempool-walk.patch Subject: [dpdk-dev] [PATCH 3/5] mempool: add walk iterator 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:02 -0000 Add function to iterate over mempool. Useful for diagnostic code that wants to look at mempool usage patterns. Signed-off-by: Stephen Hemminger --- a/lib/librte_mempool/rte_mempool.c 2014-05-02 16:31:13.279574637 -0700 +++ b/lib/librte_mempool/rte_mempool.c 2014-05-02 16:31:13.279574637 -0700 @@ -857,3 +857,24 @@ rte_mempool_lookup(const char *name) return mp; } + +void rte_mempool_walk(void (*func)(const struct rte_mempool *, void *), + void *arg) +{ + struct rte_mempool *mp = NULL; + struct rte_mempool_list *mempool_list; + + if ((mempool_list = + RTE_TAILQ_LOOKUP_BY_IDX(RTE_TAILQ_MEMPOOL, rte_mempool_list)) == NULL) { + rte_errno = E_RTE_NO_TAILQ; + return; + } + + rte_rwlock_read_lock(RTE_EAL_MEMPOOL_RWLOCK); + + TAILQ_FOREACH(mp, mempool_list, next) { + (*func)(mp, arg); + } + + rte_rwlock_read_unlock(RTE_EAL_MEMPOOL_RWLOCK); +} --- a/lib/librte_mempool/rte_mempool.h 2014-05-02 16:31:13.279574637 -0700 +++ b/lib/librte_mempool/rte_mempool.h 2014-05-02 16:31:13.279574637 -0700 @@ -1374,6 +1374,17 @@ size_t rte_mempool_xmem_size(uint32_t el ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num, size_t elt_sz, const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift); +/** + * Walk list of all memory pools + * + * @param func + * Iterator function + * @param arg + * Argument passed to iterator + */ +void rte_mempool_walk(void (*func)(const struct rte_mempool *, void *arg), + void *arg); + #ifdef __cplusplus } #endif