From a606d92107d4bf0107c3f54e2c87d39311f82075 Mon Sep 17 00:00:00 2001 From: Ole Troan Date: Wed, 5 May 2021 09:23:17 +0200 Subject: stats: memory heap counters - Add counters for the main-heap - Add additional counters per heap: STAT_MEM_TOTAL STAT_MEM_USED, STAT_MEM_FREE, STAT_MEM_USED_MMAP, STAT_MEM_TOTAL_ALLOC, STAT_MEM_FREE_CHUNKS, STAT_MEM_RELEASABLE, The per-heap counters are organised as a two dimensional vector. total, used and free are directly available via symlinks. vpp_get_stats ls "^/mem/" /mem/stat segment /mem/stat segment/total /mem/stat segment/used /mem/stat segment/free /mem/main heap /mem/main heap/total /mem/main heap/used /mem/main heap/free vpp_get_stats dump "^/mem/main\ heap$" [0 @ 0]: 1073741776 packets /mem/main heap [1 @ 0]: 91586688 packets /mem/main heap [2 @ 0]: 982155088 packets /mem/main heap [3 @ 0]: 0 packets /mem/main heap [4 @ 0]: 1073741776 packets /mem/main heap [5 @ 0]: 433 packets /mem/main heap [6 @ 0]: 981708688 packets /mem/main heap Type: feature Signed-off-by: Ole Troan Change-Id: I36725dde3b4b3befd27a8b4d3ba931f2d3b627cc --- src/vppinfra/mem_dlmalloc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/vppinfra') diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c index bc6561a738e..f8d4ca19fd8 100644 --- a/src/vppinfra/mem_dlmalloc.c +++ b/src/vppinfra/mem_dlmalloc.c @@ -474,14 +474,17 @@ clib_mem_get_heap_usage (clib_mem_heap_t * heap, clib_mem_usage_t * usage) { struct dlmallinfo mi = mspace_mallinfo (heap->mspace); - /* TODO: Fill in some more values */ + usage->bytes_total = mi.arena; /* non-mmapped space allocated from system */ + usage->bytes_used = mi.uordblks; /* total allocated space */ + usage->bytes_free = mi.fordblks; /* total free space */ + usage->bytes_used_mmap = mi.hblkhd; /* space in mmapped regions */ + usage->bytes_max = mi.usmblks; /* maximum total allocated space */ + usage->bytes_free_reclaimed = mi.ordblks; /* number of free chunks */ + usage->bytes_overhead = mi.keepcost; /* releasable (via malloc_trim) space */ + + /* Not supported */ + usage->bytes_used_sbrk = 0; usage->object_count = 0; - usage->bytes_total = mi.arena; - usage->bytes_overhead = 0; - usage->bytes_max = 0; - usage->bytes_used = mi.uordblks; - usage->bytes_free = mi.fordblks; - usage->bytes_free_reclaimed = 0; } /* Call serial number for debugger breakpoints. */ -- cgit 1.2.3-korg