mempool: introduce statistics reset function
PATCH 1/1 mempool: introduce statistics reset function
Populating a mempool with objects is accounted for in the statistics. When analyzing mempool cache statistics, this may distort the data. In order to simplify mempool cache statistics analysis, a mempool statistics reset function was added.
Furthermore, details about average burst sizes and mempool cache miss rates were added to the statistics shown when dumping a mempool.
--- lib/mempool/mempool_trace.h | 7 +++++ lib/mempool/mempool_trace_points.c | 4 +++ lib/mempool/rte_mempool.c | 50 ++++++++++++++++++++++++++++-- lib/mempool/rte_mempool.h | 12 +++++++ 4 files changed, 71 insertions(+), 2 deletions(-)
lib/mempool/mempool_trace.h +7 -0
@@ -104,6 +104,13 @@ RTE_TRACE_POINT(rte_trace_point_emit_string (mempool->name); ) +RTE_TRACE_POINT ( + rte_mempool_trace_stats_reset, + RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool), + rte_trace_point_emit_ptr(mempool); +rte_trace_point_emit_string (mempool->name); +) + RTE_TRACE_POINT( rte_mempool_trace_cache_create, RTE_TRACE_POINT_ARGS(uint32_t size, int socket_id,
lib/mempool/mempool_trace_points.c +4 -0
@@ -60,6 +60,10 @@ RTE_TRACE_POINT_REGISTER(rte_mempool_trace_populate_default,RTE_TRACE_POINT_REGISTER (rte_mempool_trace_populate_anon, lib.mempool.populate.anon) +RTE_EXPORT_EXPERIMENTAL_SYMBOL(__rte_mempool_trace_stats_reset, 26.03) +RTE_TRACE_POINT_REGISTER (rte_mempool_trace_stats_reset, + lib.mempool.stats_reset) +RTE_TRACE_POINT_REGISTER (rte_mempool_trace_cache_create, lib.mempool.cache_create)
lib/mempool/rte_mempool.c +48 -2
64 lines not on this page · raw message
lib/mempool/rte_mempool.h +12 -0
@@ -1288,6 +1288,18 @@ uint32_t rte_mempool_obj_iter(struct rte_mempool *mp,uint32_t rte_mempool_mem_iter (struct rte_mempool *mp,rte_mempool_mem_cb_t *mem_cb,void *mem_cb_arg); +/** +* @warning +* @b EXPERIMENTAL: This API may change, or be removed, without prior notice. +* +* Reset the statistics of a mempool. +* +* @param mp +* A pointer to the mempool structure. +*/ +__rte_experimental +void rte_mempool_stats_reset(struct rte_mempool *mp); +/** * Dump the status of the mempool to a file. *
Signature · 1 line
2.43.0
Quoted 15 lines · On Mon, 23 Feb 2026 10:20:54 +0000 Morten Brørup <[email protected]>…
lib/mempool/rte_mempool.c +15
-0+fprintf (f," avg objs/bulk put=%#Lf, get=%#Lf, get_fail=%#Lf\n" , + sum.put_bulk !=0 ? (long double )sum.put_objs / sum.put_bulk :0 , + sum.get_success_bulk !=0 ? + (long double )sum.get_success_objs / sum.get_success_bulk :0 , + sum.get_fail_bulk !=0 ? + (long double )sum.get_fail_objs / sum.get_fail_bulk :0 ); +fprintf (f," avg common_pool objs/bulk put=%#Lf, get=%#Lf\n" , + sum.put_common_pool_bulk !=0 ? + (long double )sum.put_common_pool_objs / sum.put_common_pool_bulk :0 , + sum.get_common_pool_bulk !=0 ? + (long double )sum.get_common_pool_objs / sum.get_common_pool_bulk :0 ); + fprintf(f, " avg cache miss rate put_objs=%s%#Lf, get_objs=%s%#Lf\n", + sum.put_common_pool_objs != 0 ? "1/" : "", + sum.put_common_pool_objs != 0 ? + (long double)sum.put_objs / sum.put_common_pool_objs : 0,
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp) · line 1379
Quoted 10 lines
lib/mempool/rte_mempool.c +10
-0+ sum.get_common_pool_objs !=0 ?"1/" :"" , + sum.get_common_pool_objs !=0 ? + (long double)sum.get_success_objs / sum.get_common_pool_objs : 0); +fprintf (f," avg cache miss rate put_bulk=%s%#Lf, get_bulk=%s%#Lf\n" , + sum.put_common_pool_bulk !=0 ?"1/" :"" , + sum.put_common_pool_bulk !=0 ? + (long double )sum.put_bulk / sum.put_common_pool_bulk :0 , + sum.get_common_pool_bulk !=0 ?"1/" :"" , + sum.get_common_pool_bulk !=0 ? + (long double )sum.get_success_bulk / sum.get_common_pool_bulk :0 );
This is getting verbose, would look better as function or better yet table driven.
Quoted 39 lines
From: Stephen Hemminger [mailto:[email protected]]
Sent: Monday, 23 February 2026 18.21Review
Quoted 1 line · On Mon, 23 Feb 2026 10:20:54 +0000 Morten Brørup <[email protected]>…
(quoted diff) +1
-0+ fprintf(f, " avg objs/bulk put=%#Lf, get=%#Lf,get_fail=%#Lf\n",
Review
Quoted 1 line
(quoted diff) +1
-0+ sum.put_bulk != 0 ? (long double)sum.put_objs /sum.put_bulk : 0,
Review
Quoted 2 lines
(quoted diff) +2
-0+ sum.get_success_bulk != 0 ? + (long double)sum.get_success_objs /sum.get_success_bulk : 0,
Review
Quoted 2 lines
(quoted diff) +2
-0+ sum.get_fail_bulk != 0 ? + (long double)sum.get_fail_objs / sum.get_fail_bulk :0);
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp)
Quoted 3 lines
lib/mempool/rte_mempool.c +3
-0+ fprintf(f, " avg common_pool objs/bulk put=%#Lf, get=%#Lf\n", + sum.put_common_pool_bulk != 0 ? + (long double)sum.put_common_pool_objs /sum.put_common_pool_bulk : 0,
Review
Quoted 2 lines
(quoted diff) +2
-0+ sum.get_common_pool_bulk != 0 ? + (long double)sum.get_common_pool_objs /sum.get_common_pool_bulk : 0);
Review
Quoted 1 line
(quoted diff) +1
-0+ fprintf(f, " avg cache miss rate put_objs=%s%#Lf,get_objs=%s%#Lf\n",
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp)
Quoted 3 lines
lib/mempool/rte_mempool.c +3
-0+ sum.put_common_pool_objs !=0 ?"1/" :"" , + sum.put_common_pool_objs != 0 ? + (long double)sum.put_objs / sum.put_common_pool_objs: 0,
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp)
Quoted 3 lines
lib/mempool/rte_mempool.c +3
-0+ sum.get_common_pool_objs !=0 ?"1/" :"" , + sum.get_common_pool_objs != 0 ? + (long double)sum.get_success_objs /sum.get_common_pool_objs : 0);
Review
Quoted 1 line
(quoted diff) +1
-0+ fprintf(f, " avg cache miss rate put_bulk=%s%#Lf,get_bulk=%s%#Lf\n",
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp)
Quoted 3 lines
lib/mempool/rte_mempool.c +3
-0+ sum.put_common_pool_bulk !=0 ?"1/" :"" , + sum.put_common_pool_bulk != 0 ? + (long double)sum.put_bulk / sum.put_common_pool_bulk: 0,
Quoted 7 lines
lib/mempool/rte_mempool.c rte_mempool_dump(FILE *f, struct rte_mempool *mp)
Quoted 3 lines
lib/mempool/rte_mempool.c +3
-0+ sum.get_common_pool_bulk !=0 ?"1/" :"" , + sum.get_common_pool_bulk != 0 ? + (long double)sum.get_success_bulk /sum.get_common_pool_bulk : 0);
This is getting verbose, would look better as function or better yet table driven.
Dump outputs are formatted as hierarchy, like this, so table is a no-go.
Only the last two are similar, and could share a macro/function, but I think it would make the code less readable.
Quoted 9 lines · Morten Brørup
Populating a mempool with objects is accounted for in the statistics. When analyzing mempool cache statistics, this may distort the data. In order to simplify mempool cache statistics analysis, a mempool statistics reset function was added.
Furthermore, details about average burst sizes and mempool cache miss rates were added to the statistics shown when dumping a mempool.
Signed-off-by Morten Brørup <[email protected]>
I'd like to see thoughts about consistency after reset taking into account that reset will likely to be done from control core whereas stats are updated from data cores. Results could be very interesting. I guess it is not the reason to introduce locking or any other kind of synchronization, but user should be warned as the bare minimum.
Quoted 12 lines
From: Andrew Rybchenko [mailto:[email protected]]
Sent: Tuesday, 24 February 2026 07.29Quoted 8 lines · Morten Brørup
Populating a mempool with objects is accounted for in the statistics. When analyzing mempool cache statistics, this may distort the data. In order to simplify mempool cache statistics analysis, a mempool statistics reset function was added.
Furthermore, details about average burst sizes and mempool cache miss rates were added to the statistics shown when dumping a mempool.
Quoted 7 lines
Quoted 1 line
Signed-off-by Morten Brørup <[email protected]>I'd like to see thoughts about consistency after reset taking into account that reset will likely to be done from control core whereas stats are updated from data cores. Results could be very interesting. I guess it is not the reason to introduce locking or any other kind of synchronization, but user should be warned as the bare minimum.
When used for cache statistics analysis, the reset function will be called once only: After everything has been initialized (mempool created and populated, and ethdev Rx queues preloaded with mbufs), but before the data plane is started.
I don't think the end user should be warned; this may be normal behavior for an application. In addition to the trace event, I'll add a DEBUG level log message in the function.
And a warning about potential inconsistency in the function description.
Good feedback, Andrew!
Quoted 14 lines · Morten Brørup
Quoted 14 lines
From: Andrew Rybchenko [mailto:[email protected]]
Sent: Tuesday, 24 February 2026 07.29Quoted 9 lines · Morten Brørup
Populating a mempool with objects is accounted for in the statistics. When analyzing mempool cache statistics, this may distort the data. In order to simplify mempool cache statistics analysis, a mempool statistics reset function was added.
Furthermore, details about average burst sizes and mempool cache miss rates were added to the statistics shown when dumping a mempool.
Signed-off-by Morten Brørup <[email protected]>
Quoted 7 lines
Quoted 5 lines
I'd like to see thoughts about consistency after reset taking into account that reset will likely to be done from control core whereas stats are updated from data cores. Results could be very interesting. I guess it is not the reason to introduce locking or any other kind of synchronization, but user should be warned as the bare minimum.
When used for cache statistics analysis, the reset function will be called once only: After everything has been initialized (mempool created and populated, and ethdev Rx queues preloaded with mbufs), but before the data plane is started.
Thanks I see now. May be these assumptions should be mentioned in the function description? Or is it too much?
Quoted 3 lines
I don't think the end user should be warned; this may be normal behavior for an application. In addition to the trace event, I'll add a DEBUG level log message in the function.>> And a warning about potential inconsistency in the function description.
Sounds good.
Quoted 2 lines
Good feedback, Andrew!
PATCH v2 1/1 mempool: introduce statistics reset function
In reply to Morten BrørupPopulating a mempool with objects is accounted for in the statistics. When analyzing mempool cache statistics, this may distort the data. In order to simplify mempool cache statistics analysis, a mempool statistics reset function was added.
Furthermore, details about average burst sizes and mempool cache miss rates were added to the statistics shown when dumping a mempool.
---
v2:
* Added detailed usage instructions to the function description. (Andrew)
* Added DEBUG log message to the function. (Andrew)
--- lib/mempool/mempool_trace.h | 7 ++++ lib/mempool/mempool_trace_points.c | 4 +++ lib/mempool/rte_mempool.c | 51 ++++++++++++++++++++++++++++-- lib/mempool/rte_mempool.h | 29 +++++++++++++++++ 4 files changed, 89 insertions(+), 2 deletions(-)
lib/mempool/mempool_trace.h +7 -0
@@ -104,6 +104,13 @@ RTE_TRACE_POINT(rte_trace_point_emit_string (mempool->name); ) +RTE_TRACE_POINT ( + rte_mempool_trace_stats_reset, + RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool), + rte_trace_point_emit_ptr(mempool); +rte_trace_point_emit_string (mempool->name); +) + RTE_TRACE_POINT( rte_mempool_trace_cache_create, RTE_TRACE_POINT_ARGS(uint32_t size, int socket_id,
lib/mempool/mempool_trace_points.c +4 -0
@@ -60,6 +60,10 @@ RTE_TRACE_POINT_REGISTER(rte_mempool_trace_populate_default,RTE_TRACE_POINT_REGISTER (rte_mempool_trace_populate_anon, lib.mempool.populate.anon) +RTE_EXPORT_EXPERIMENTAL_SYMBOL(__rte_mempool_trace_stats_reset, 26.03) +RTE_TRACE_POINT_REGISTER (rte_mempool_trace_stats_reset, + lib.mempool.stats_reset) +RTE_TRACE_POINT_REGISTER (rte_mempool_trace_cache_create, lib.mempool.cache_create)
lib/mempool/rte_mempool.c +49 -2
65 lines not on this page · raw message
lib/mempool/rte_mempool.h +29 -0
@@ -1288,6 +1288,35 @@ uint32_t rte_mempool_obj_iter(struct rte_mempool *mp,uint32_t rte_mempool_mem_iter (struct rte_mempool *mp,rte_mempool_mem_cb_t *mem_cb,void *mem_cb_arg); +/** +* @warning +* @b EXPERIMENTAL: This API may change, or be removed, without prior notice. +* +* Reset the statistics of a mempool. +* +* This function is intended for use when analyzing mempool statistics +* without counting any mempool operations performed during application +* initialization. +* For example, populating the mempool counts as put operations into the +* common pool, and setting up ethdev Rx queues counts as get operations. +* +* This function should only be called after application initialization, +* before the data path is started; otherwise, the mempool statistics may +* become inconsistent. +* +* For a perfectly clean slate, the local caches of the mempools used +* during application initialization should be flushed before resetting +* the mempool statistics. +* For example, mbuf pools used by ethdev Rx queues. +* +* @see rte_mempool_cache_flush() +* +* @param mp +* A pointer to the mempool structure. +*/ +__rte_experimental +void rte_mempool_stats_reset(struct rte_mempool *mp); +/** * Dump the status of the mempool to a file. *
Signature · 1 line
2.43.0
Quoted 9 lines · Morten Brørup
Populating a mempool with objects is accounted for in the statistics. When analyzing mempool cache statistics, this may distort the data. In order to simplify mempool cache statistics analysis, a mempool statistics reset function was added.
Furthermore, details about average burst sizes and mempool cache miss rates were added to the statistics shown when dumping a mempool.
Signed-off-by Morten Brørup <[email protected]>
24/02/2026 10:57, Andrew Rybchenko:
Quoted 6 lines · Morten Brørup
Quoted 5 lines
Populating a mempool with objects is accounted for in the statistics. When analyzing mempool cache statistics, this may distort the data. In order to simplify mempool cache statistics analysis, a mempool statistics reset function was added.
Quoted 6 lines
Quoted 4 lines
Furthermore, details about average burst sizes and mempool cache miss rates were added to the statistics shown when dumping a mempool.
Signed-off-by Morten Brørup <[email protected]>Acked-by Andrew Rybchenko <[email protected]>
Applied with version changed to 26.07, thanks.
Another question:
How about the overload of mempool stats, If the cost is low, can we remove the debug macro? As far as I know, some DPDK applications enable mempool statistics (maybe self-impl) in the production environment, which is mainly used to help locate problems.
Quoted 164 lines · Morten Brørup
Populating a mempool with objects is accounted for in the statistics. When analyzing mempool cache statistics, this may distort the data. In order to simplify mempool cache statistics analysis, a mempool statistics reset function was added.
Furthermore, details about average burst sizes and mempool cache miss rates were added to the statistics shown when dumping a mempool.
Signed-off-by Morten Brørup <[email protected]>---
v2:
* Added detailed usage instructions to the function description. (Andrew)
* Added DEBUG log message to the function. (Andrew)--- lib/mempool/mempool_trace.h | 7 ++++ lib/mempool/mempool_trace_points.c | 4 +++ lib/mempool/rte_mempool.c | 51 ++++++++++++++++++++++++++++-- lib/mempool/rte_mempool.h | 29 +++++++++++++++++ 4 files changed, 89 insertions(+), 2 deletions(-)lib/mempool/mempool_trace.h +7
-0@@ -104,6 +104,13 @@ RTE_TRACE_POINT(rte_trace_point_emit_string (mempool->name); ) +RTE_TRACE_POINT ( + rte_mempool_trace_stats_reset, + RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool), + rte_trace_point_emit_ptr(mempool); +rte_trace_point_emit_string (mempool->name); +) + RTE_TRACE_POINT( rte_mempool_trace_cache_create, RTE_TRACE_POINT_ARGS(uint32_t size, int socket_id,lib/mempool/mempool_trace_points.c +4
-0@@ -60,6 +60,10 @@ RTE_TRACE_POINT_REGISTER(rte_mempool_trace_populate_default,RTE_TRACE_POINT_REGISTER (rte_mempool_trace_populate_anon, lib.mempool.populate.anon) +RTE_EXPORT_EXPERIMENTAL_SYMBOL(__rte_mempool_trace_stats_reset, 26.03) +RTE_TRACE_POINT_REGISTER (rte_mempool_trace_stats_reset, + lib.mempool.stats_reset) +RTE_TRACE_POINT_REGISTER (rte_mempool_trace_cache_create, lib.mempool.cache_create)lib/mempool/rte_mempool.c +49
-2@@ -1049,6 +1049,29 @@ rte_mempool_in_use_count(const struct rte_mempool *mp)return mp->size -rte_mempool_avail_count (mp); } +/* Reset the statistics of a mempool. */ +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_mempool_stats_reset, 26.03) +void +rte_mempool_stats_reset (struct rte_mempool *mp) +{ +RTE_ASSERT (mp !=NULL ); + +#ifdef RTE_LIBRTE_MEMPOOL_STATS +memset (&mp->stats,0 ,sizeof (mp->stats)); +if (mp->cache_size !=0 ) { +for (unsigned int lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { +memset (&mp->local_cache[lcore_id].stats,0 , +sizeof (mp->local_cache[lcore_id].stats)); + } + } + +RTE_MEMPOOL_LOG (DEBUG ,"<%s>@%p: statistics reset" , mp->name, mp); +rte_mempool_trace_stats_reset (mp); +#else +RTE_SET_USED (mp); +#endif +} +/* dump the cache status */ static unsigned rte_mempool_dump_cache (FILE *f,const struct rte_mempool *mp)@@ -1327,10 +1350,34 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)fprintf (f," get_fail_bulk=%" PRIu64"\n" , sum.get_fail_bulk);fprintf (f," get_fail_objs=%" PRIu64"\n" , sum.get_fail_objs);if (info.contig_block_size >0 ) { -fprintf (f," get_success_blks=%" PRIu64"\n" , - sum.get_success_blks); +fprintf (f," get_success_blks=%" PRIu64"\n" , sum.get_success_blks);fprintf (f," get_fail_blks=%" PRIu64"\n" , sum.get_fail_blks); } +fprintf (f," avg objs/bulk put=%#Lf, get=%#Lf, get_fail=%#Lf\n" , + sum.put_bulk !=0 ? (long double )sum.put_objs / sum.put_bulk :0 , + sum.get_success_bulk !=0 ? + (long double )sum.get_success_objs / sum.get_success_bulk :0 , + sum.get_fail_bulk !=0 ? + (long double )sum.get_fail_objs / sum.get_fail_bulk :0 ); +fprintf (f," avg common_pool objs/bulk put=%#Lf, get=%#Lf\n" , + sum.put_common_pool_bulk !=0 ? + (long double )sum.put_common_pool_objs / sum.put_common_pool_bulk :0 , + sum.get_common_pool_bulk !=0 ? + (long double )sum.get_common_pool_objs / sum.get_common_pool_bulk :0 ); +fprintf (f," avg cache miss rate put_objs=%s%#Lf, get_objs=%s%#Lf\n" , + sum.put_common_pool_objs !=0 ?"1/" :"" , + sum.put_common_pool_objs !=0 ? + (long double )sum.put_objs / sum.put_common_pool_objs :0 , + sum.get_common_pool_objs !=0 ?"1/" :"" , + sum.get_common_pool_objs !=0 ? + (long double )sum.get_success_objs / sum.get_common_pool_objs :0 ); +fprintf (f," avg cache miss rate put_bulk=%s%#Lf, get_bulk=%s%#Lf\n" , + sum.put_common_pool_bulk !=0 ?"1/" :"" , + sum.put_common_pool_bulk !=0 ? + (long double )sum.put_bulk / sum.put_common_pool_bulk :0 , + sum.get_common_pool_bulk !=0 ?"1/" :"" , + sum.get_common_pool_bulk !=0 ? + (long double )sum.get_success_bulk / sum.get_common_pool_bulk :0 );#else fprintf (f," no statistics available\n" );#endif lib/mempool/rte_mempool.h +29
-0@@ -1288,6 +1288,35 @@ uint32_t rte_mempool_obj_iter(struct rte_mempool *mp,uint32_t rte_mempool_mem_iter (struct rte_mempool *mp,rte_mempool_mem_cb_t *mem_cb,void *mem_cb_arg); +/** +* @warning +* @b EXPERIMENTAL: This API may change, or be removed, without prior notice. +* +* Reset the statistics of a mempool. +* +* This function is intended for use when analyzing mempool statistics +* without counting any mempool operations performed during application +* initialization. +* For example, populating the mempool counts as put operations into the +* common pool, and setting up ethdev Rx queues counts as get operations. +* +* This function should only be called after application initialization, +* before the data path is started; otherwise, the mempool statistics may +* become inconsistent. +* +* For a perfectly clean slate, the local caches of the mempools used +* during application initialization should be flushed before resetting +* the mempool statistics. +* For example, mbuf pools used by ethdev Rx queues. +* +* @see rte_mempool_cache_flush() +* +* @param mp +* A pointer to the mempool structure. +*/ +__rte_experimental +void rte_mempool_stats_reset(struct rte_mempool *mp); +/** * Dump the status of the mempool to a file. *
Quoted 11 lines
From: fengchengwen [mailto:[email protected]]
Sent: Friday, 27 February 2026 10.20Acked-by Chengwen Feng <[email protected]>Another question:
How about the overload of mempool stats, If the cost is low, can we remove the debug macro? As far as I know, some DPDK applications
enable
mempool statistics (maybe self-impl) in the production environment, which is mainly used to help locate problems.
Mempool is a core library, so even though the overhead of the mempool statistics is relatively low cost, it is a debug-only facility, and the extra overhead should be not be forced upon users. IMO, we should keep it build time configurable.
You do raise a good point about the balance tradeoff!
Maybe enabling it for production is worth it for the majority of users. In SmartShare Systems, we enable it for production too.
We should discuss changing the default from disabled to enabled.
Thomas,
This patch is ready for merge, but didn't make it into 26.03.
Will you replace 26.03 in the two instances of RTE_EXPORT_EXPERIMENTAL_SYMBOL() with 26.07 while merging, or do you prefer that I submit a new version?
Venlig hilsen / Kind regards,
-Morten Brørup
Quoted 199 lines
-----Original Message-----
From: Morten Brørup [mailto:[email protected]]
Sent: Tuesday, 24 February 2026 10.28Populating a mempool with objects is accounted for in the statistics. When analyzing mempool cache statistics, this may distort the data. In order to simplify mempool cache statistics analysis, a mempool statistics reset function was added.
Furthermore, details about average burst sizes and mempool cache miss rates were added to the statistics shown when dumping a mempool.
Signed-off-by Morten Brørup <[email protected]>---
v2:
* Added detailed usage instructions to the function description. (Andrew)
* Added DEBUG log message to the function. (Andrew)--- lib/mempool/mempool_trace.h | 7 ++++ lib/mempool/mempool_trace_points.c | 4 +++ lib/mempool/rte_mempool.c | 51 ++++++++++++++++++++++++++++-- lib/mempool/rte_mempool.h | 29 +++++++++++++++++ 4 files changed, 89 insertions(+), 2 deletions(-)lib/mempool/mempool_trace.h +7
-0@@ -104,6 +104,13 @@ RTE_TRACE_POINT(rte_trace_point_emit_string (mempool->name); ) +RTE_TRACE_POINT ( + rte_mempool_trace_stats_reset, + RTE_TRACE_POINT_ARGS(struct rte_mempool *mempool), + rte_trace_point_emit_ptr(mempool); +rte_trace_point_emit_string (mempool->name); +) + RTE_TRACE_POINT( rte_mempool_trace_cache_create, RTE_TRACE_POINT_ARGS(uint32_t size, int socket_id,lib/mempool/mempool_trace_points.c +4
-0@@ -60,6 +60,10 @@RTE_TRACE_POINT_REGISTER (rte_mempool_trace_populate_default, RTE_TRACE_POINT_REGISTER(rte_mempool_trace_populate_anon, lib.mempool.populate.anon) +RTE_EXPORT_EXPERIMENTAL_SYMBOL(__rte_mempool_trace_stats_reset, 26.03) +RTE_TRACE_POINT_REGISTER(rte_mempool_trace_stats_reset, + lib.mempool.stats_reset) +RTE_TRACE_POINT_REGISTER (rte_mempool_trace_cache_create, lib.mempool.cache_create)lib/mempool/rte_mempool.c +23
-0@@ -1049,6 +1049,29 @@ rte_mempool_in_use_count(const struct rte_mempool *mp)return mp->size -rte_mempool_avail_count (mp); } +/* Reset the statistics of a mempool. */ +RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_mempool_stats_reset, 26.03) +void +rte_mempool_stats_reset (struct rte_mempool *mp) +{ +RTE_ASSERT (mp !=NULL ); + +#ifdef RTE_LIBRTE_MEMPOOL_STATS +memset (&mp->stats,0 ,sizeof (mp->stats)); +if (mp->cache_size !=0 ) { +for (unsigned int lcore_id =0 ; lcore_id <RTE_MAX_LCORE ; lcore_id++) { +memset (&mp->local_cache[lcore_id].stats,0 , +sizeof (mp->local_cache[lcore_id].stats)); + } + } + +RTE_MEMPOOL_LOG (DEBUG ,"<%s>@%p: statistics reset" , mp->name, mp); +rte_mempool_trace_stats_reset (mp); +#else +RTE_SET_USED (mp); +#endif +} +/* dump the cache status */
static unsigned
rte_mempool_dump_cache(FILE *f, const struct rte_mempool *mp)lib/mempool/rte_mempool.c +2
-2@@ -1327,10 +1350,34 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)fprintf (f," get_fail_bulk=%" PRIu64"\n" , sum.get_fail_bulk);fprintf (f," get_fail_objs=%" PRIu64"\n" , sum.get_fail_objs);if (info.contig_block_size >0 ) { -fprintf (f," get_success_blks=%" PRIu64"\n" , - sum.get_success_blks); +fprintf (f," get_success_blks=%" PRIu64"\n" , sum.get_success_blks);fprintf (f," get_fail_blks=%" PRIu64"\n" , sum.get_fail_blks); } + fprintf(f, " avg objs/bulk put=%#Lf, get=%#Lf,get_fail=%#Lf\n",
lib/mempool/rte_mempool.c +1
-0+ sum.put_bulk != 0 ? (long double)sum.put_objs /sum.put_bulk : 0,
lib/mempool/rte_mempool.c +2
-0+ sum.get_success_bulk != 0 ? + (long double)sum.get_success_objs /sum.get_success_bulk : 0,
lib/mempool/rte_mempool.c +2
-0+ sum.get_fail_bulk !=0 ? + (long double)sum.get_fail_objs / sum.get_fail_bulk :0);
lib/mempool/rte_mempool.c +3
-0+ fprintf(f, " avg common_pool objs/bulk put=%#Lf, get=%#Lf\n", + sum.put_common_pool_bulk != 0 ? + (long double)sum.put_common_pool_objs /sum.put_common_pool_bulk : 0,
lib/mempool/rte_mempool.c +2
-0+ sum.get_common_pool_bulk != 0 ? + (long double)sum.get_common_pool_objs /sum.get_common_pool_bulk : 0);
lib/mempool/rte_mempool.c +1
-0+ fprintf(f, " avg cache miss rate put_objs=%s%#Lf,get_objs=%s%#Lf\n",
lib/mempool/rte_mempool.c +3
-0+ sum.put_common_pool_objs !=0 ?"1/" :"" , + sum.put_common_pool_objs != 0 ? + (long double)sum.put_objs / sum.put_common_pool_objs: 0,
lib/mempool/rte_mempool.c +3
-0+ sum.get_common_pool_objs !=0 ?"1/" :"" , + sum.get_common_pool_objs != 0 ? + (long double)sum.get_success_objs /sum.get_common_pool_objs : 0);
lib/mempool/rte_mempool.c +1
-0+ fprintf(f, " avg cache miss rate put_bulk=%s%#Lf,get_bulk=%s%#Lf\n",
lib/mempool/rte_mempool.c +3
-0+ sum.put_common_pool_bulk !=0 ?"1/" :"" , + sum.put_common_pool_bulk != 0 ? + (long double)sum.put_bulk / sum.put_common_pool_bulk: 0,
lib/mempool/rte_mempool.c +3
-0+ sum.get_common_pool_bulk !=0 ?"1/" :"" , + sum.get_common_pool_bulk != 0 ? + (long double)sum.get_success_bulk /sum.get_common_pool_bulk : 0);
#elselib/mempool/rte_mempool.c +0
-0fprintf (f," no statistics available\n" );#endif lib/mempool/rte_mempool.h +3
-0@@ -1288,6 +1288,35 @@ uint32_t rte_mempool_obj_iter(struct rte_mempool *mp,uint32_t rte_mempool_mem_iter (struct rte_mempool *mp,rte_mempool_mem_cb_t *mem_cb,void *mem_cb_arg); +/** +* @warning +* @b EXPERIMENTAL: This API may change, or be removed, without prior notice.
+ *
+ * Reset the statistics of a mempool.
+ *
+ * This function is intended for use when analyzing mempool statistics
+ * without counting any mempool operations performed during application
+ * initialization.
+ * For example, populating the mempool counts as put operations into the
+ * common pool, and setting up ethdev Rx queues counts as get operations.
+ *
+ * This function should only be called after application initialization,
+ * before the data path is started; otherwise, the mempool statistics may
+ * become inconsistent.
+ *
+ * For a perfectly clean slate, the local caches of the mempools used
+ * during application initialization should be flushed before resetting
+ * the mempool statistics.
+ * For example, mbuf pools used by ethdev Rx queues.
+ *
+ * @seerte_mempool_cache_flush()
+ *
+ * @param mp
+ * A pointer to the mempool structure.
+ */lib/mempool/rte_mempool.h +3
-1+__rte_experimental +void rte_mempool_stats_reset(struct rte_mempool *mp); +/** * Dump the status of the mempool to a file. * -- 2.43.0
04/05/2026 12:50, Morten Brørup:
Quoted 4 lines
Thomas,
This patch is ready for merge, but didn't make it into 26.03.
Will you replace 26.03 in the two instances ofRTE_EXPORT_EXPERIMENTAL_SYMBOL()with 26.07 while merging, or do you prefer that I submit a new version?
I can replace while merging, no problem.