Skip to contentSkip to conversation

mempool: enhance dump function to print ops name

PATCH Superseded Hemant Agrawal 4 participants 6 messages Jul 11, 2020 – Oct 6, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mempool: enhance dump function to print ops name

Enhance the dump function to also print the ops index and associated mempool ops name

---
 lib/librte_mempool/rte_mempool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/librte_mempool/rte_mempool.c +5 -1
index 5b23e2ae78..462ea850a1 100644
@@ -1186,6 +1186,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 	unsigned lcore_id;
 #endif
 	struct rte_mempool_memhdr *memhdr;
+	struct rte_mempool_ops *ops;
 	unsigned common_count;
 	unsigned cache_count;
 	size_t mem_len = 0;
@@ -1208,6 +1209,10 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 
 	fprintf(f, "  private_data_size=%"PRIu32"\n", mp->private_data_size);
 
+	ops = rte_mempool_get_ops(mp->ops_index);
+	fprintf(f, "  ops_index=%d ops_name: <%s>\n",
+		mp->ops_index, ops ? ops->name:"NA");
+
 	STAILQ_FOREACH(memhdr, &mp->mem_list, next)
 		mem_len += memhdr->len;
 	if (mem_len != 0) {
@@ -1250,7 +1255,6 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 #else
 	fprintf(f, "  no statistics available\n");
 #endif
-
 	rte_mempool_audit(mp);
 }
 
Signature · 1 line
2.17.1
#1 lore raw

Hi Hemant,

Thank you for submitting this improvement. Minor comments below.

Quoted 21 lines · Hemant Agrawal

Enhance the dump function to also print the ops index and associated mempool ops name

---
 lib/librte_mempool/rte_mempool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/librte_mempool/rte_mempool.c +1 -0
index 5b23e2ae78..462ea850a1 100644
@@ -1186,6 +1186,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 	unsigned lcore_id;
 #endif
 	struct rte_mempool_memhdr *memhdr;
+	struct rte_mempool_ops *ops;
 	unsigned common_count;
 	unsigned cache_count;
 	size_t mem_len = 0;

lib/librte_mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp) · line 1215

Quoted 7 lines
lib/librte_mempool/rte_mempool.c +4 -0
@@ -1208,6 +1209,10 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 
 	fprintf(f, "  private_data_size=%"PRIu32"\n", mp->private_data_size);
 
+	ops = rte_mempool_get_ops(mp->ops_index);
+	fprintf(f, "  ops_index=%d ops_name: <%s>\n",
+		mp->ops_index, ops ? ops->name:"NA");
+

Could you have 2 printed lines for it? One for index, and another for the name.

About the ternary operator, even if checkpatch does not complain, I prefer having one space on each side around the colon (this form is more common in dpdk).

lib/librte_mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp) · line 1259

Quoted 10 lines
lib/librte_mempool/rte_mempool.c +0 -1
 	STAILQ_FOREACH(memhdr, &mp->mem_list, next)
 		mem_len += memhdr->len;
 	if (mem_len != 0) {
@@ -1250,7 +1255,6 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 #else
 	fprintf(f, "  no statistics available\n");
 #endif
-
 	rte_mempool_audit(mp);
 }

Uneeded line removal there.

Thanks!
Olivier

#2 lore raw

PATCH v2 1/1 mempool: enhance dump function to print ops name

In reply to Hemant Agrawal

Enhance the dump function to also print the ops index and associated mempool ops name

---
 lib/librte_mempool/rte_mempool.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/librte_mempool/rte_mempool.c +5 -0
index 7774f0c8da..10c5cb708f 100644
@@ -1266,6 +1266,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 	unsigned lcore_id;
 #endif
 	struct rte_mempool_memhdr *memhdr;
+	struct rte_mempool_ops *ops;
 	unsigned common_count;
 	unsigned cache_count;
 	size_t mem_len = 0;
@@ -1288,6 +1289,10 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 
 	fprintf(f, "  private_data_size=%"PRIu32"\n", mp->private_data_size);
 
+	fprintf(f, "  ops_index=%d\n", mp->ops_index);
+	ops = rte_mempool_get_ops(mp->ops_index);
+	fprintf(f, "  ops_name: <%s>\n", ops ? ops->name : "NA");
+
 	STAILQ_FOREACH(memhdr, &mp->mem_list, next)
 		mem_len += memhdr->len;
 	if (mem_len != 0) {
Signature · 1 line
2.17.1
Acked-by on v2 1/1
#3 lore raw
Quoted 4 lines · Hemant Agrawal

Enhance the dump function to also print the ops index and associated mempool ops name

with a nit below

Quoted 17 lines
---
 lib/librte_mempool/rte_mempool.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/librte_mempool/rte_mempool.c +1 -0
index 7774f0c8da..10c5cb708f 100644
@@ -1266,6 +1266,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 	unsigned lcore_id;
 #endif
 	struct rte_mempool_memhdr *memhdr;
+	struct rte_mempool_ops *ops;
 	unsigned common_count;
 	unsigned cache_count;
 	size_t mem_len = 0;

lib/librte_mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp) · line 1294

Quoted 6 lines
lib/librte_mempool/rte_mempool.c +3 -0
@@ -1288,6 +1289,10 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 
 	fprintf(f, "  private_data_size=%"PRIu32"\n", mp->private_data_size);
 
+	fprintf(f, "  ops_index=%d\n", mp->ops_index);
+	ops = rte_mempool_get_ops(mp->ops_index);
+	fprintf(f, "  ops_name: <%s>\n", ops ? ops->name : "NA");

DPDK coding style suggests to use explicit comparison vs NULL, i.e. ops != NULL ? ops->name : "NA"

Quoted 4 lines
lib/librte_mempool/rte_mempool.c +1 -0
+
 	STAILQ_FOREACH(memhdr, &mp->mem_list, next)
 		mem_len += memhdr->len;
 	if (mem_len != 0) {
#4 lore raw

PATCH v3 1/1 mempool: enhance dump function to print ops name

In reply to Hemant Agrawal

Enhance the dump function to also print the ops index and associated mempool ops name

---
 lib/librte_mempool/rte_mempool.c | 5 +++++
 1 file changed, 5 insertions(+)
lib/librte_mempool/rte_mempool.c +5 -0
index 7774f0c8da..d72056d28d 100644
@@ -1266,6 +1266,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 	unsigned lcore_id;
 #endif
 	struct rte_mempool_memhdr *memhdr;
+	struct rte_mempool_ops *ops;
 	unsigned common_count;
 	unsigned cache_count;
 	size_t mem_len = 0;
@@ -1288,6 +1289,10 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
 
 	fprintf(f, "  private_data_size=%"PRIu32"\n", mp->private_data_size);
 
+	fprintf(f, "  ops_index=%d\n", mp->ops_index);
+	ops = rte_mempool_get_ops(mp->ops_index);
+	fprintf(f, "  ops_name: <%s>\n", (ops != NULL) ? ops->name : "NA");
+
 	STAILQ_FOREACH(memhdr, &mp->mem_list, next)
 		mem_len += memhdr->len;
 	if (mem_len != 0) {
Signature · 1 line
2.17.1