[v2] mempool: enhance dump function to print ops name

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

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Hemant Agrawal Aug. 17, 2020, 11:15 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 | 5 +++++
 1 file changed, 5 insertions(+)
  

Comments

Andrew Rybchenko Aug. 29, 2020, 11:29 a.m. UTC | #1
On 8/17/20 2:15 PM, 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>

Acked-by: Andrew Rybchenko <arybchenko@solarflare.com>

with a nit below

> ---
>  lib/librte_mempool/rte_mempool.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
> index 7774f0c8da..10c5cb708f 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -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");

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

> +
>  	STAILQ_FOREACH(memhdr, &mp->mem_list, next)
>  		mem_len += memhdr->len;
>  	if (mem_len != 0) {
  

Patch

diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 7774f0c8da..10c5cb708f 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -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) {