Skip to content

Commit 17bb600

Browse files
Gagandeep Singhdavid-marchand
authored andcommitted
mem: add total memory size in dumps
This patch add total memory size dump in memzone and memory segments dump APIs. Signed-off-by: Gagandeep Singh <[email protected]> Acked-by: Stephen Hemminger <[email protected]>
1 parent 7775adc commit 17bb600

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

lib/eal/common/eal_common_memory.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,8 @@ void
531531
rte_dump_physmem_layout(FILE *f)
532532
{
533533
rte_memseg_walk(dump_memseg, f);
534+
fprintf(f, "Total Memory Segments size = %"PRIu64"M\n",
535+
rte_eal_get_physmem_size() / (1024 * 1024));
534536
}
535537

536538
static int

lib/eal/common/eal_common_memzone.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,18 +359,25 @@ rte_memzone_lookup(const char *name)
359359
return memzone;
360360
}
361361

362+
struct memzone_info {
363+
FILE *f;
364+
uint64_t total_size;
365+
};
366+
362367
static void
363368
dump_memzone(const struct rte_memzone *mz, void *arg)
364369
{
365370
struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
366371
struct rte_memseg_list *msl = NULL;
372+
struct memzone_info *info = arg;
367373
void *cur_addr, *mz_end;
368374
struct rte_memseg *ms;
369375
int mz_idx, ms_idx;
376+
FILE *f = info->f;
370377
size_t page_sz;
371-
FILE *f = arg;
372378

373379
mz_idx = rte_fbarray_find_idx(&mcfg->memzones, mz);
380+
info->total_size += mz->len;
374381

375382
fprintf(f, "Zone %u: name:<%s>, len:0x%zx, virt:%p, "
376383
"socket_id:%"PRId32", flags:%"PRIx32"\n",
@@ -413,7 +420,11 @@ dump_memzone(const struct rte_memzone *mz, void *arg)
413420
void
414421
rte_memzone_dump(FILE *f)
415422
{
416-
rte_memzone_walk(dump_memzone, f);
423+
struct memzone_info info = { .f = f };
424+
425+
rte_memzone_walk(dump_memzone, &info);
426+
fprintf(f, "Total Memory Zones size = %"PRIu64"M\n",
427+
info.total_size / (1024 * 1024));
417428
}
418429

419430
/*

0 commit comments

Comments
 (0)