On Tue, 30 Jul 2024 16:33:13 +0530 Gagandeep Singh <g.si...@nxp.com> wrote:
> This patch add total memory size dump in memzone and > memsegments dump APIs. > > Signed-off-by: Gagandeep Singh <g.si...@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)); > } You are going to get truncated result here because rte_eal_get_physmem_size() is uint64_t and unsigned int is 32 bit. The cast happens before the division which leads to truncation with 4G. Simplest fix would be fprintf(f, "Total Memory Segments size = %"PRIu64"M\n", rte_eal_get_physmem_size() / (1024 * 1024));