[v2,2/2] eal: add total memory size in memory dump APIs

Message ID 20240730110313.2555473-3-g.singh@nxp.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series proc-info memory dump enhancement |

Checks

Context Check Description
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS

Commit Message

Gagandeep Singh July 30, 2024, 11:03 a.m. UTC
This patch add total memory size dump in memzone and
memsegments dump APIs.

Signed-off-by: Gagandeep Singh <g.singh@nxp.com>
---
 lib/eal/common/eal_common_memory.c  |  2 ++
 lib/eal/common/eal_common_memzone.c | 18 ++++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)
  

Patch

diff --git a/lib/eal/common/eal_common_memory.c b/lib/eal/common/eal_common_memory.c
index 60ddc30580..c6b9c16617 100644
--- a/lib/eal/common/eal_common_memory.c
+++ b/lib/eal/common/eal_common_memory.c
@@ -531,6 +531,8 @@  void
 rte_dump_physmem_layout(FILE *f)
 {
 	rte_memseg_walk(dump_memseg, f);
+	fprintf(f, "Total Memory Segments size = %uM\n",
+			(unsigned int) rte_eal_get_physmem_size() / (1024 * 1024));
 }
 
 static int
diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c
index 2d9b6aa3e3..4cd077d8d8 100644
--- a/lib/eal/common/eal_common_memzone.c
+++ b/lib/eal/common/eal_common_memzone.c
@@ -58,6 +58,11 @@  rte_memzone_max_get(void)
 	return mcfg->max_memzone;
 }
 
+struct memzone_info {
+	FILE *f;
+	uint64_t t_size;
+};
+
 static inline const struct rte_memzone *
 memzone_lookup_thread_unsafe(const char *name)
 {
@@ -367,7 +372,8 @@  dump_memzone(const struct rte_memzone *mz, void *arg)
 	struct rte_memseg *ms;
 	int mz_idx, ms_idx;
 	size_t page_sz;
-	FILE *f = arg;
+	struct memzone_info *info = arg;
+	FILE *f = info->f;
 
 	mz_idx = rte_fbarray_find_idx(&mcfg->memzones, mz);
 
@@ -380,6 +386,7 @@  dump_memzone(const struct rte_memzone *mz, void *arg)
 			mz->socket_id,
 			mz->flags);
 
+	info->t_size += mz->len;
 	/* go through each page occupied by this memzone */
 	msl = rte_mem_virt2memseg_list(mz->addr);
 	if (!msl) {
@@ -412,7 +419,14 @@  dump_memzone(const struct rte_memzone *mz, void *arg)
 void
 rte_memzone_dump(FILE *f)
 {
-	rte_memzone_walk(dump_memzone, f);
+	struct memzone_info info;
+
+	memset(&info, 0, sizeof(info));
+	info.f = f;
+
+	rte_memzone_walk(dump_memzone, &info);
+	fprintf(f, "Total Memory Zones size = %uM\n", (unsigned int)info.t_size
+			/ (1024 * 1024));
 }
 
 /*