From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 959241B4A7 for ; Mon, 3 Dec 2018 06:54:01 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Dec 2018 21:54:01 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,309,1539673200"; d="scan'208";a="280400344" Received: from unknown (HELO saesrv02-S2600CWR.intel.com) ([10.224.122.203]) by orsmga005.jf.intel.com with ESMTP; 02 Dec 2018 21:53:58 -0800 From: Vipin Varghese To: konstantin.ananyev@intel.com, stephen@networkplumber.org, reshma.pattan@intel.com, dev@dpdk.org, john.mcnamara@intel.com Cc: thomas@monjalon.net, stephen1.byrne@intel.com, amol.patel@intel.com, Vipin Varghese Date: Mon, 3 Dec 2018 11:19:59 +0530 Message-Id: <20181203055000.39012-9-vipin.varghese@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181203055000.39012-1-vipin.varghese@intel.com> References: <20181122141543.37067-1-vipin.varghese@intel.com> <20181203055000.39012-1-vipin.varghese@intel.com> Subject: [dpdk-dev] [PATCH v6 8/9] app/procinfo: add support for show iter mempool X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Dec 2018 05:54:02 -0000 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 00b2d85f7..7a7e7372e 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