[v6,8/9] app/procinfo: add support for show iter mempool

Message ID 20181203055000.39012-9-vipin.varghese@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series app/proc-info: improve debug of proc-info tool |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Varghese, Vipin Dec. 3, 2018, 5:49 a.m. UTC
  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 <vipin.varghese@intel.com>
---

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(-)
  

Comments

Pattan, Reshma Dec. 12, 2018, 4:10 p.m. UTC | #1
> -----Original Message-----
> From: Varghese, Vipin
> Sent: Monday, December 3, 2018 5:50 AM

Since this patch displaying mepool and its elements both , edit heading to suit both? 

( or)

What about having iter mempool support as separate patch after this patch?  That looks more logical as iter-mempool is separate command option now.

Thanks,
Reshma
  
Varghese, Vipin Dec. 13, 2018, 2:26 a.m. UTC | #2
Hi Reshma,

snipped
> 
> Since this patch displaying mepool and its elements both , edit heading to suit
> both?
> 
> ( or)
> 
> What about having iter mempool support as separate patch after this patch?
> That looks more logical as iter-mempool is separate command option now.


This is good suggestion, but depending upon the function and debug option in my humble opinion it has to go with the current patch series.

> 
> Thanks,
> Reshma
  

Patch

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 <rte_security.h>
 #include <rte_cryptodev.h>
 #include <rte_tm.h>
+#include <rte_hexdump.h>
 
 /* 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