DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gagandeep Singh <g.singh@nxp.com>
To: dev@dpdk.org, Anatoly Burakov <anatoly.burakov@intel.com>,
	Tyler Retzlaff <roretzla@linux.microsoft.com>
Cc: hemant.agrawal@nxp.com
Subject: [PATCH 2/2] eal: add total memory size in memory dump APIs
Date: Tue,  2 Jul 2024 18:44:36 +0530	[thread overview]
Message-ID: <20240702131436.2873832-2-g.singh@nxp.com> (raw)
In-Reply-To: <20240702131436.2873832-1-g.singh@nxp.com>

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

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 32e6b78f87..1d12ccc443 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)
 {
@@ -369,7 +374,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);
 
@@ -382,6 +388,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) {
@@ -414,7 +421,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));
 }
 
 /*
-- 
2.25.1


  reply	other threads:[~2024-07-02 13:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-02 13:14 [PATCH 1/2] app/proc-info: add memory heap dump Gagandeep Singh
2024-07-02 13:14 ` Gagandeep Singh [this message]
2024-07-03  8:33 ` Hemant Agrawal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240702131436.2873832-2-g.singh@nxp.com \
    --to=g.singh@nxp.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=roretzla@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).