[dpdk-dev] [PATCH v1 8/9] app/procinfo: add code for debug mempool

Vipin Varghese vipin.varghese at intel.com
Tue Oct 23 15:57:50 CEST 2018


Function debug_mempool is used for displaying the MEMPOOL of the
primary process. For valid mempool name elements are iterated for max
of 256 bytes.

Signed-off-by: Vipin Varghese <vipin.varghese at intel.com>
---
 app/proc-info/main.c | 47 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index f8b28d47f..764ef5731 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
@@ -1103,10 +1104,54 @@ debug_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("  - name %s, obj_idx %u opaque %p obj %p\n",
+	       mp->name, obj_idx, opaque, obj);
+
+	if (obj)
+		rte_hexdump(stdout, " Mempool Obj Content",
+			obj, (mp->elt_size > 256)?256:mp->elt_size);
+}
+
 static void
 debug_mempool(char *name)
 {
-	printf(" mempools Name (%s)", name);
+	snprintf(bdr_str, 100, "debug - 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) {
+			printf("  - Name: %s on socket %d flags %u\n",
+			       ptr->name, ptr->socket_id, ptr->flags);
+			printf("  - Size %u Cache %u element %u"
+			       " header %u trailer %u "
+			       " 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);
+
+			/* iterate each object */
+			int ret = rte_mempool_obj_iter(ptr,
+				mempool_itr_obj, NULL);
+			printf("  - iterated %u objects\n", ret);
+
+			STATS_BDR_STR(50, "");
+			return;
+		}
+	}
+
+	rte_mempool_list_dump(stdout);
+	STATS_BDR_STR(50, "");
 }
 
 int
-- 
2.17.1



More information about the dev mailing list