mempool: dump includes list of memory chunks
PATCH 1/1 mempool: dump includes list of memory chunks
Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
--- lib/mempool/rte_mempool.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
lib/mempool/rte_mempool.c +10 -0
@@ -1230,6 +1230,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)#endif struct rte_mempool_memhdr *memhdr;struct rte_mempool_ops *ops; +unsigned int n;unsigned common_count;unsigned cache_count;size_t mem_len =0 ;
@@ -1264,6 +1265,15 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) (long double)mem_len / mp->size); } +fprintf (f," mem_list:\n" ); + n =0 ; + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," addr[%u]=%p\n" , n, memhdr->addr); +fprintf (f," iova[%u]=0x%" PRIx64"\n" , n, memhdr->iova); +fprintf (f," len[%u]=%zu\n" , n, memhdr->len); + n++; + } + cache_count =rte_mempool_dump_cache (f, mp); common_count =rte_mempool_ops_get_count (mp);if ((cache_count + common_count) > mp->size)
Signature · 1 line
2.17.1
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp) · line 1275
Quoted 8 lines · On Thu, 16 May 2024 10:59:40 +0200 Morten Brørup <[email protected]>…
lib/mempool/rte_mempool.c +8
-0+fprintf (f," mem_list:\n" ); + n =0 ; + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," addr[%u]=%p\n" , n, memhdr->addr); +fprintf (f," iova[%u]=0x%" PRIx64"\n" , n, memhdr->iova); +fprintf (f," len[%u]=%zu\n" , n, memhdr->len); + n++; + }
The output would look better if it was a table with one line per mempool, and the name first and column headers, and n is redundant
mem_list:
Addr Iova Len
...
Quoted 19 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Thursday, 16 May 2024 17.21lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp) · line 1275
Quoted 8 lines · On Thu, 16 May 2024 10:59:40 +0200 Morten Brørup <[email protected]>…
lib/mempool/rte_mempool.c +8
-0+fprintf (f," mem_list:\n" ); + n =0 ; + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," addr[%u]=%p\n" , n, memhdr->addr); +fprintf (f," iova[%u]=0x%" PRIx64"\n" , n, memhdr->iova); +fprintf (f," len[%u]=%zu\n" , n, memhdr->len); + n++; + }The output would look better if it was a table with one line per mempool, and the name first
and column headers, and n is redundant
Quoted 3 lines
mem_list:
Addr Iova Len
...
I agree, but I followed the existing convention for how the dump output is formatted.
That's also why I show the index in the mem_list; without it, the output would look silly, showing the same fields multiple times with different values.
Quoted 26 lines · Morten Brørup
Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
Signed-off-by Morten Brørup <[email protected]>--- lib/mempool/rte_mempool.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/mempool/rte_mempool.c +3
-0@@ -1230,6 +1230,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)#endif struct rte_mempool_memhdr *memhdr;struct rte_mempool_ops *ops; +unsigned int n;unsigned common_count;unsigned cache_count;size_t mem_len =0 ;@@ -1264,6 +1265,15 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) (long double)mem_len / mp->size); } +fprintf (f," mem_list:\n" ); + n =0 ;
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp) · line 1279
Quoted 10 lines
lib/mempool/rte_mempool.c +7
-0+ STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," addr[%u]=%p\n" , n, memhdr->addr); +fprintf (f," iova[%u]=0x%" PRIx64"\n" , n, memhdr->iova); +fprintf (f," len[%u]=%zu\n" , n, memhdr->len); + n++; + } + cache_count =rte_mempool_dump_cache (f, mp); common_count =rte_mempool_ops_get_count (mp);if ((cache_count + common_count) > mp->size)
It's useful information to dump. Maybe consider adding something akin to RTE_LIBRTE_MEMPOOL_STATS to gate this in case the prints are overwhelming due to high list element number.
Quoted 28 lines
From: Paul Szczepanek [mailto:[email protected]]
Sent: Wednesday, 29 May 2024 14.55Quoted 24 lines · Morten Brørup
Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
Signed-off-by Morten Brørup <[email protected]>--- lib/mempool/rte_mempool.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/mempool/rte_mempool.c +1
-0@@ -1230,6 +1230,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)#endif struct rte_mempool_memhdr *memhdr;struct rte_mempool_ops *ops; +unsigned int n;unsigned common_count;unsigned cache_count;size_t mem_len =0 ;@@ -1264,6 +1265,15 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) (long double)mem_len / mp->size); }
Quoted 16 lines
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp) · line 1279
Quoted 12 lines
lib/mempool/rte_mempool.c +9
-0+fprintf (f," mem_list:\n" ); + n =0 ; + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," addr[%u]=%p\n" , n, memhdr->addr); +fprintf (f," iova[%u]=0x%" PRIx64"\n" , n, memhdr->iova); +fprintf (f," len[%u]=%zu\n" , n, memhdr->len); + n++; + } + cache_count =rte_mempool_dump_cache (f, mp); common_count =rte_mempool_ops_get_count (mp);if ((cache_count + common_count) > mp->size)It's useful information to dump. Maybe consider adding something akin to
RTE_LIBRTE_MEMPOOL_STATSto gate this in case the prints are overwhelming due to high list element number.
The dumps are often very verbose, and there are no means to control that.
The only reason the mempool stats are gated by RTE_LIBRTE_MEMPOOL_STATS is because they are an build time optional feature, and don't exist if built without.
Quoted 2 lines
Reviewed-by Paul Szczepanek <[email protected]>
Thanks.
PING (again) for review.
It's only 10 lines of very simple code to dump some info. And it follows existing dump conventions.
-Morten
Quoted 41 lines
From: Morten Brørup [mailto:[email protected]]
Sent: Thursday, 16 May 2024 11.00Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
Signed-off-by Morten Brørup <[email protected]>--- lib/mempool/rte_mempool.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/mempool/rte_mempool.c +10
-1@@ -1230,6 +1230,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)#endif struct rte_mempool_memhdr *memhdr;struct rte_mempool_ops *ops; +unsigned int n;unsigned common_count;unsigned cache_count;size_t mem_len =0 ;@@ -1264,6 +1265,15 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) (long double)mem_len / mp->size); } +fprintf (f," mem_list:\n" ); + n =0 ; + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," addr[%u]=%p\n" , n, memhdr->addr); +fprintf (f," iova[%u]=0x%" PRIx64"\n" , n, memhdr->iova); +fprintf (f," len[%u]=%zu\n" , n, memhdr->len); + n++; + } + cache_count =rte_mempool_dump_cache (f, mp); common_count =rte_mempool_ops_get_count (mp);if ((cache_count + common_count) > mp->size) --2.17.1
Quoted 4 lines · Morten Brørup
Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
Signed-off-by Morten Brørup <[email protected]>
Quoted 29 lines
Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
Signed-off-by Morten Brørup <[email protected]>--- lib/mempool/rte_mempool.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/mempool/rte_mempool.c +4
-0@@ -1230,6 +1230,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)#endif struct rte_mempool_memhdr *memhdr;struct rte_mempool_ops *ops; +unsigned int n;unsigned common_count;unsigned cache_count;size_t mem_len =0 ;@@ -1264,6 +1265,15 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) (long double)mem_len / mp->size); } +fprintf (f," mem_list:\n" ); + n =0 ; + STAILQ_FOREACH(memhdr, &mp->mem_list, next) {
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp)
Quoted 10 lines
lib/mempool/rte_mempool.c +6
-1+fprintf (f," addr[%u]=%p\n" , n, memhdr->addr); +fprintf (f," iova[%u]=0x%" PRIx64"\n" , n, memhdr->iova); +fprintf (f," len[%u]=%zu\n" , n, memhdr->len); + n++; + } + cache_count =rte_mempool_dump_cache (f, mp); common_count =rte_mempool_ops_get_count (mp);if ((cache_count + common_count) > mp->size) --
Just as a thought: do we want to print something (N/A?) when mp->mem_list is empty?
Quoted 1 line
2.17.1
Quoted 27 lines
From: Konstantin Ananyev [mailto:[email protected]]
Sent: Monday, 10 June 2024 15.45Quoted 24 lines
Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
Signed-off-by Morten Brørup <[email protected]>--- lib/mempool/rte_mempool.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/mempool/rte_mempool.c +1
-0@@ -1230,6 +1230,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)#endif struct rte_mempool_memhdr *memhdr;struct rte_mempool_ops *ops; +unsigned int n;unsigned common_count;unsigned cache_count;size_t mem_len =0 ;@@ -1264,6 +1265,15 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) (long double)mem_len / mp->size); }
Quoted 16 lines
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp)
Quoted 13 lines
lib/mempool/rte_mempool.c +9
-1+fprintf (f," mem_list:\n" ); + n =0 ; + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," addr[%u]=%p\n" , n, memhdr->addr); +fprintf (f," iova[%u]=0x%" PRIx64"\n" , n, memhdr->iova); +fprintf (f," len[%u]=%zu\n" , n, memhdr->len); + n++; + } + cache_count =rte_mempool_dump_cache (f, mp); common_count =rte_mempool_ops_get_count (mp);if ((cache_count + common_count) > mp->size) --Just as a thought: do we want to print something (N/A?) when
mp->mem_listis empty?
Good idea, Konstantin.
Your feedback made me check what other dump functions print when the list is empty, and I saw that the mbuf library's dump function prints segments with multiple fields on the same line [1], as previously suggested by Stephen (and rejected by me, because I thought it was breaking conventions).
[1]: https://elixir.bootlin.com/dpdk/v24.03/source/lib/mbuf/rte_mbuf.c#L694
Admitting that Stephen was on the right track with his suggestion, and I was wrong to reject it, we could omit the "mem_list:" header and print the list like this instead:
STAILQ_FOREACH(memhdr, &mp->mem_list, next)
fprintf(f, " memory chunk at %p, addr=%p, iova=0x%" PRIx64 ", len=%zu\n", memhdr, memhdr->addr, memhdr->iova, memhdr->len);
The patch will be just these three lines of code, and nothing will be printed if the list is empty.
What do you think?
Quoted 5 lines
Quoted 1 line
2.17.1
Hi Morten,
Quoted 52 lines
Quoted 24 lines
Quoted 24 lines
Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
Signed-off-by Morten Brørup <[email protected]>--- lib/mempool/rte_mempool.c | 10 ++++++++++ 1 file changed, 10 insertions(+)lib/mempool/rte_mempool.c +1
-0@@ -1230,6 +1230,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)#endif struct rte_mempool_memhdr *memhdr;struct rte_mempool_ops *ops; +unsigned int n;unsigned common_count;unsigned cache_count;size_t mem_len =0 ;@@ -1264,6 +1265,15 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) (long double)mem_len / mp->size); }Quoted 16 lines
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp)
Quoted 13 lines
lib/mempool/rte_mempool.c +9
-1+fprintf (f," mem_list:\n" ); + n =0 ; + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," addr[%u]=%p\n" , n, memhdr->addr); +fprintf (f," iova[%u]=0x%" PRIx64"\n" , n, memhdr->iova); +fprintf (f," len[%u]=%zu\n" , n, memhdr->len); + n++; + } + cache_count =rte_mempool_dump_cache (f, mp); common_count =rte_mempool_ops_get_count (mp);if ((cache_count + common_count) > mp->size) --Just as a thought: do we want to print something (N/A?) when
mp->mem_listis empty?Good idea, Konstantin.
Your feedback made me check what other dump functions print when the list is empty, and I saw that the mbuf library's dump function prints segments with multiple fields on the same line [1], as previously suggested by Stephen (and rejected by me, because I thought it was breaking conventions).
[1]: https://elixir.bootlin.com/dpdk/v24.03/source/lib/mbuf/rte_mbuf.c#L694
Admitting that Stephen was on the right track with his suggestion, and I was wrong to reject it, we could omit the "
mem_list:" header and print the list like this instead:
Quoted 7 lines
STAILQ_FOREACH(memhdr, &mp->mem_list, next)fprintf(f, " memory chunk at %p, addr=%p, iova=0x%" PRIx64 ", len=%zu\n", memhdr, memhdr->addr, memhdr->iova, memhdr->len);The patch will be just these three lines of code, and nothing will be printed if the list is empty.
What do you think?
Sounds reasonable to me.
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
2.17.1
PATCH v2 1/1 mempool: dump includes list of memory chunks
In reply to Morten BrørupAdded information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
---
v2:
* Dump one line per entry. Remove headline and index number. (Stephen, Konstantin.)
* Changed reviewed-by to acked-by.
--- lib/mempool/rte_mempool.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/mempool/rte_mempool.c +4 -0
@@ -1264,6 +1264,10 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) (long double)mem_len / mp->size); } + STAILQ_FOREACH(memhdr, &mp->mem_list, next) +fprintf (f," memory chunk at %p, addr=%p, iova=0x%" PRIx64", len=%zu\n" , + memhdr, memhdr->addr, memhdr->iova, memhdr->len); + cache_count =rte_mempool_dump_cache (f, mp); common_count =rte_mempool_ops_get_count (mp);if ((cache_count + common_count) > mp->size)
Signature · 1 line
2.17.1
PATCH v2 1/1 mempool: dump includes list of memory chunks
In reply to Morten BrørupAdded information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
---
v2:
* Dump one line per entry. Remove headline and index number. (Stephen, Konstantin.)
* Changed reviewed-by to acked-by.
--- lib/mempool/rte_mempool.c | 4 ++++ 1 file changed, 4 insertions(+)
lib/mempool/rte_mempool.c +4 -0
@@ -1264,6 +1264,10 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) (long double)mem_len / mp->size); } + STAILQ_FOREACH(memhdr, &mp->mem_list, next) +fprintf (f," memory chunk at %p, addr=%p, iova=0x%" PRIx64", len=%zu\n" , + memhdr, memhdr->addr, memhdr->iova, memhdr->len); + cache_count =rte_mempool_dump_cache (f, mp); common_count =rte_mempool_ops_get_count (mp);if ((cache_count + common_count) > mp->size)
Signature · 1 line
2.17.1
PATCH v3 1/1 mempool: dump includes list of memory chunks
In reply to Morten BrørupAdded information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
---
v3:
* Fix output indentation.
* Print in existing loop, instead of adding a new loop. v2:
* Dump one line per entry. Remove index number and headline. (Stephen, Konstantin.)
* Changed reviewed-by to acked-by.
--- lib/mempool/rte_mempool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/mempool/rte_mempool.c +4 -1
@@ -1257,8 +1257,11 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) 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) + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," memory chunk at %p, addr=%p, iova=0x%" PRIx64", len=%zu\n" , + memhdr, memhdr->addr, memhdr->iova, memhdr->len); mem_len += memhdr->len; + }if (mem_len !=0 ) {fprintf (f," avg bytes/object=%#Lf\n" , (long double )mem_len / mp->size);
Signature · 1 line
2.17.1
Quoted 26 lines · Morten Brørup
Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
Signed-off-by Morten Brørup <[email protected]>Acked-by Paul Szczepanek <[email protected]>Acked-by Andrew Rybchenko <[email protected]>---
v3:
* Fix output indentation.
* Print in existing loop, instead of adding a new loop. v2:
* Dump one line per entry. Remove index number and headline. (Stephen, Konstantin.)
* Changed reviewed-by to acked-by.--- lib/mempool/rte_mempool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)lib/mempool/rte_mempool.c +0
-0@@ -1257,8 +1257,11 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp) ops =rte_mempool_get_ops (mp->ops_index);fprintf (f," ops_name: <%s>\n" , (ops !=NULL ) ? ops->name :"NA" );
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp) · line 1267
Quoted 10 lines
lib/mempool/rte_mempool.c +4
-1-STAILQ_FOREACH (memhdr, &mp->mem_list, next) + STAILQ_FOREACH(memhdr, &mp->mem_list, next) { +fprintf (f," memory chunk at %p, addr=%p, iova=0x%" PRIx64", len=%zu\n" , + memhdr, memhdr->addr, memhdr->iova, memhdr->len); mem_len += memhdr->len; + }if (mem_len !=0 ) {fprintf (f," avg bytes/object=%#Lf\n" , (long double )mem_len / mp->size);
Quoted 8 lines · Morten Brørup
Added information about the memory chunks holding the objects in the mempool when dumping the status of the mempool to a file.
Signed-off-by Morten Brørup <[email protected]>Acked-by Paul Szczepanek <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
Applied, thanks.
Signature · 1 line
David Marchand