[dpdk-dev] [PATCH] app/testpmd: log the largest free block when dumping socket memory
From: Yunjian Wang <hidden>
Date: 2021-12-27 10:49:56
Subsystem:
the rest · Maintainer:
Linus Torvalds
Add log print of the largest free block in dump_socket_mem. It is useful to also log when dumping socket memory. Signed-off-by: Yunjian Wang <redacted> --- app/test-pmd/cmdline.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 6e10afeedd..d7bddf065a 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c@@ -9825,6 +9825,7 @@ dump_socket_mem(FILE *f) size_t total = 0; size_t alloc = 0; size_t free = 0; + size_t greatest_free_size = 0; unsigned int n_alloc = 0; unsigned int n_free = 0; static size_t last_allocs;
@@ -9840,22 +9841,27 @@ dump_socket_mem(FILE *f) free += socket_stats.heap_freesz_bytes; n_alloc += socket_stats.alloc_count; n_free += socket_stats.free_count; + greatest_free_size = RTE_MAX(greatest_free_size, socket_stats.greatest_free_size); fprintf(f, - "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", + "Socket %u: size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf max: %.6lf \t" + "count alloc: %-4u free: %u\n", i, (double)socket_stats.heap_totalsz_bytes / (1024 * 1024), (double)socket_stats.heap_allocsz_bytes / (1024 * 1024), (double)socket_stats.heap_allocsz_bytes * 100 / (double)socket_stats.heap_totalsz_bytes, (double)socket_stats.heap_freesz_bytes / (1024 * 1024), + (double)socket_stats.greatest_free_size / (1024 * 1024), socket_stats.alloc_count, socket_stats.free_count); } fprintf(f, - "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf \tcount alloc: %-4u free: %u\n", + "Total : size(M) total: %.6lf alloc: %.6lf(%.3lf%%) free: %.6lf max: %.6lf \t" + "count alloc: %-4u free: %u\n", (double)total / (1024 * 1024), (double)alloc / (1024 * 1024), total ? ((double)alloc * 100 / (double)total) : 0, (double)free / (1024 * 1024), + (double)greatest_free_size / (1024 * 1024), n_alloc, n_free); if (last_allocs) fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
--
2.27.0