mempool: enhance dump function to print ops name

Message ID 20200711095936.11535-1-hemant.agrawal@nxp.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series mempool: enhance dump function to print ops name |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Performance-Testing fail build patch failure
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS

Commit Message

Hemant Agrawal July 11, 2020, 9:59 a.m. UTC
  Enhance the dump function to also print the ops index
and associated mempool ops name

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 lib/librte_mempool/rte_mempool.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Olivier Matz July 31, 2020, 12:55 p.m. UTC | #1
Hi Hemant,

Thank you for submitting this improvement. Minor comments
below.

On Sat, Jul 11, 2020 at 03:29:36PM +0530, Hemant Agrawal wrote:
> Enhance the dump function to also print the ops index
> and associated mempool ops name
> 
> Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
> ---
>  lib/librte_mempool/rte_mempool.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
> index 5b23e2ae78..462ea850a1 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -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");
> +

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

>  	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
  

Patch

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 5b23e2ae78..462ea850a1 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -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);
 }