From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vipin Varghese Subject: [PATCH v7 8/9] app/procinfo: add support for show iter mempool Date: Thu, 13 Dec 2018 10:38:41 +0530 Message-ID: <20181213050842.64587-9-vipin.varghese@intel.com> References: <20181203055000.39012-2-vipin.varghese@intel.com> <20181213050842.64587-1-vipin.varghese@intel.com> Cc: thomas@monjalon.net, stephen1.byrne@intel.com, amol.patel@intel.com, Vipin Varghese To: konstantin.ananyev@intel.com, stephen@networkplumber.org, reshma.pattan@intel.com, dev@dpdk.org, john.mcnamara@intel.com Return-path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 38EF51B4C7 for ; Thu, 13 Dec 2018 06:09:26 +0100 (CET) In-Reply-To: <20181213050842.64587-1-vipin.varghese@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Function show_mempool is used for displaying valid MEMPOOL. Function iter_mempool is used for iterating mempool elements for a mempool for max of 256 bytes. In case of show_mempool for invalid name, whole list is dump. Signed-off-by: Vipin Varghese --- V6: - split iter mempool - Vipin Varghese V5: - update ret to uint32_t - Reshma Pattan v4: - add spacing for flag compare - Vipin Varghese V3: - add avail and in use - Vipin Varghese - add flag split - Vipin Varghese --- app/proc-info/main.c | 80 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/app/proc-info/main.c b/app/proc-info/main.c index d9677959c..6dfd01d6e 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -33,6 +33,7 @@ #include #include #include +#include /* Maximum long option length for option parsing. */ #define MAX_LONG_OPT_SZ 64 @@ -1161,16 +1162,91 @@ show_ring(char *name) STATS_BDR_STR(50, ""); } +static void +mempool_itr_obj(struct rte_mempool *mp, + void *opaque, void *obj, + unsigned int obj_idx) +{ + printf(" - obj_idx %u opaque %p obj %p\n", + obj_idx, opaque, obj); + + if (obj) + rte_hexdump(stdout, " Obj Content", + obj, (mp->elt_size > 256)?256:mp->elt_size); +} + static void show_mempool(char *name) { - printf(" mempool Name (%s)\n", name); + uint64_t flags = 0; + + snprintf(bdr_str, MAX_STRING_LEN, " show - MEMPOOL %"PRIu64, + rte_get_tsc_hz()); + STATS_BDR_STR(10, bdr_str); + + if (name != NULL) { + struct rte_mempool *ptr = rte_mempool_lookup(name); + if (ptr != NULL) { + flags = ptr->flags; + printf(" - Name: %s on socket %d\n" + " - flags:\n" + "\t -- No spread (%c)\n" + "\t -- No cache align (%c)\n" + "\t -- SP put (%c), SC get (%c)\n" + "\t -- Pool created (%c)\n" + "\t -- No IOVA config (%c)\n", + ptr->name, + ptr->socket_id, + (flags & MEMPOOL_F_NO_SPREAD) ? 'y' : 'n', + (flags & MEMPOOL_F_NO_CACHE_ALIGN) ? 'y' : 'n', + (flags & MEMPOOL_F_SP_PUT) ? 'y' : 'n', + (flags & MEMPOOL_F_SC_GET) ? 'y' : 'n', + (flags & MEMPOOL_F_POOL_CREATED) ? 'y' : 'n', + (flags & MEMPOOL_F_NO_IOVA_CONTIG) ? 'y' : 'n'); + printf(" - Size %u Cache %u element %u\n" + " - header %u trailer %u\n" + " - private data size %u\n", + ptr->size, + ptr->cache_size, + ptr->elt_size, + ptr->header_size, + ptr->trailer_size, + ptr->private_data_size); + printf(" - memezone - socket %d\n", + ptr->mz->socket_id); + printf(" - Count: avail (%u), in use (%u)\n", + rte_mempool_avail_count(ptr), + rte_mempool_in_use_count(ptr)); + + STATS_BDR_STR(50, ""); + return; + } + } + + rte_mempool_list_dump(stdout); + STATS_BDR_STR(50, ""); } static void iter_mempool(char *name) { - printf(" Iter elements in mempool (%s)\n", name); + snprintf(bdr_str, MAX_STRING_LEN, " iter - MEMPOOL %"PRIu64, + rte_get_tsc_hz()); + STATS_BDR_STR(10, bdr_str); + + if (name != NULL) { + struct rte_mempool *ptr = rte_mempool_lookup(name); + if (ptr != NULL) { + /* iterate each object */ + uint32_t ret = rte_mempool_obj_iter(ptr, + mempool_itr_obj, NULL); + printf(" - iterated %u objects\n", ret); + STATS_BDR_STR(50, ""); + return; + } + } + + STATS_BDR_STR(50, ""); } int -- 2.17.1