diff mbox series

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

Message ID 20181106124912.40700-8-vipin.varghese@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers show
Series [v4,1/9] app/procinfo: add usage for new debug | expand

Checks

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

Commit Message

Varghese, Vipin Nov. 6, 2018, 12:49 p.m. UTC
Function show_mempool is used for displaying the MEMPOOL of the
primary process. For valid mempool elements are iterated for max
of 256 bytes.

Signed-off-by: Vipin Varghese <vipin.varghese@intel.com>
---

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 | 67 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 66 insertions(+), 1 deletion(-)

Comments

Pattan, Reshma Nov. 21, 2018, 5:23 p.m. UTC | #1
> -----Original Message-----
> From: Varghese, Vipin
> Sent: Tuesday, November 6, 2018 12:49 PM
> To: dev@dpdk.org; thomas@monjalon.net; Pattan, Reshma
> <reshma.pattan@intel.com>; stephen@networkplumber.org; Mcnamara, John
> <john.mcnamara@intel.com>
> Cc: Byrne, Stephen1 <stephen1.byrne@intel.com>; Glynn, Michael J
> <michael.j.glynn@intel.com>; Patel, Amol <amol.patel@intel.com>; Varghese,
> Vipin <vipin.varghese@intel.com>
> +			/* iterate each object */
> +			int ret = rte_mempool_obj_iter(ptr,
> +				mempool_itr_obj, NULL);

rte_mempool_obj_iter returns uint32_t,  so good to use  "ret" type to be uint32_t. So it will be in synch with below printf too.

> +			printf("  - iterated %u objects\n", ret);

Thanks,
Reshma
Varghese, Vipin Nov. 22, 2018, 2:21 p.m. UTC | #2
> > +			/* iterate each object */
> > +			int ret = rte_mempool_obj_iter(ptr,
> > +				mempool_itr_obj, NULL);
> 
> rte_mempool_obj_iter returns uint32_t,  so good to use  "ret" type to be
> uint32_t. So it will be in synch with below printf too.
> 
> > +			printf("  - iterated %u objects\n", ret);

Done for v5
diff mbox series

Patch

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index b97668d7f..bd28556ed 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
@@ -1154,10 +1155,74 @@  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(" mempools 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));
+
+			/* 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