app/testpmd: log the largest free block when dumping socket memory

Message ID da0dc3b3ba2695d1ff1798fc6c921da6079f00d3.1640585898.git.wangyunjian@huawei.com (mailing list archive)
State Changes Requested, archived
Delegated to: Ferruh Yigit
Headers
Series app/testpmd: log the largest free block when dumping socket memory |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional fail Functional Testing issues
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing warning Testing issues
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS

Commit Message

Yunjian Wang Dec. 27, 2021, 10:49 a.m. UTC
  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 <wangyunjian@huawei.com>
---
 app/test-pmd/cmdline.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
  

Comments

Ferruh Yigit Jan. 18, 2022, 4:17 p.m. UTC | #1
On 12/27/2021 10:49 AM, Yunjian Wang wrote:
> Add log print of the largest free block in dump_socket_mem.

1) What do you mean with "largest free block", is largest continuous block?
    If so is this physically continuous, or vfio continious?

2) Why this value is good for? Why we want to display it?

> It is useful to also log when dumping socket memory.
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>   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",

'max' is not clear what that value is, can you please update it?

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

This is not displaying the total value, but last value. Need to gather values in loop
to be able to display the total value.

>   		n_alloc, n_free);
>   	if (last_allocs)
>   		fprintf(stdout, "Memory total change: %.6lf(M), allocation change: %.6lf(M)\n",
  

Patch

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",