diff options
author | Damjan Marion <damarion@cisco.com> | 2020-10-06 17:46:06 +0200 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2020-10-06 23:47:33 +0200 |
commit | bfa75d6b922ee15d2f0d00999fd36b03a85eda8c (patch) | |
tree | ddd1341db08ae2020c37333d31c949d883ef6bc2 /src/vppinfra/mem.c | |
parent | ab1a50cf7407e31097b550226c2b6954d6371bea (diff) |
vppinfra: add heap header in front of dlmalloc space
This patch adds smal header in front of dlmalloc space, and it stores
some additional information about the heap.
Immediate benefit of this patch is that we know the underlying page size
si we can display heap page statistics / real memory usage.
Type: improvement
Change-Id: Ibd6989cc2f2f64630ab08734c9552e15029c5f3f
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/vppinfra/mem.c')
-rw-r--r-- | src/vppinfra/mem.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/vppinfra/mem.c b/src/vppinfra/mem.c index b417b8503ad..1f8b6bfe618 100644 --- a/src/vppinfra/mem.c +++ b/src/vppinfra/mem.c @@ -71,6 +71,30 @@ clib_mem_vm_map_shared (void *base, uword size, int fd, uword offset, return rv; } +u8 * +format_clib_mem_page_stats (u8 * s, va_list * va) +{ + clib_mem_page_stats_t *stats = va_arg (*va, clib_mem_page_stats_t *); + u32 indent = format_get_indent (s) + 2; + + s = format (s, "page stats: page-size %U, total %lu, mapped %lu, " + "not-mapped %lu", format_log2_page_size, stats->log2_page_sz, + stats->total, stats->mapped, stats->not_mapped); + + if (stats->unknown) + s = format (s, ", unknown %lu", stats->unknown); + + for (int i = 0; i < CLIB_MAX_NUMAS; i++) + if (stats->per_numa[i]) + s = format (s, "\n%Unuma %u: %lu pages, %U bytes", + format_white_space, indent, i, + stats->per_numa[i], + format_memory_size, + stats->per_numa[i] << stats->log2_page_sz); + + return s; +} + /* * fd.io coding-style-patch-verification: ON * |