From 5ce3b934571906c012567d898d83c652fad30567 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Sun, 20 Nov 2016 17:12:18 +0000 Subject: Get clib2 slab usage Calling ARexx function "SLABSTATS" will dump the current stats to the ns log --- frontends/amiga/memory.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'frontends/amiga/memory.c') diff --git a/frontends/amiga/memory.c b/frontends/amiga/memory.c index 901d616f2..cf42c1e42 100755 --- a/frontends/amiga/memory.c +++ b/frontends/amiga/memory.c @@ -16,12 +16,11 @@ * along with this program. If not, see . */ +#ifndef __amigaos4__ #include -#include - #include "amiga/memory.h" +#include "utils/log.h" -#ifndef __amigaos4__ ULONG __slab_max_size = 8192; /* Enable clib2's slab allocator */ /* Special clear (ie. non-zero) */ @@ -31,5 +30,35 @@ void *ami_memory_clear_alloc(size_t size, UBYTE value) if (mem) memset(mem, value, size); return mem; } + +/* clib2 slab allocator stats */ +static int ami_memory_slab_callback(const struct __slab_usage_information * sui) +{ + if(sui->sui_slab_index <= 1) { + LOG("clib2 slab usage:"); + LOG(" The size of all slabs, in bytes: %ld", sui->sui_slab_size); + LOG(" Number of allocations which are not managed by slabs: %ld", + sui->sui_num_single_allocations); + LOG(" Total number of bytes allocated for memory not managed by slabs: %ld", + sui->sui_total_single_allocation_size); + LOG(" Number of slabs currently in play: %ld", sui->sui_num_slabs); + LOG(" Number of currently unused slabs: %ld", sui->sui_num_empty_slabs); + LOG(" Number of slabs in use which are completely filled with data: %ld", + sui->sui_num_full_slabs); + LOG(" Total number of bytes allocated for all slabs: %ld", + sui->sui_total_slab_allocation_size); + } + LOG("Slab %d", sui->sui_slab_index); + LOG(" Memory chunk size managed by this slab: %ld", sui->sui_chunk_size); + LOG(" Number of memory chunks that fit in this slab: %ld", sui->sui_num_chunks); + LOG(" Number of memory chunks used in this slab: %ld", sui->sui_num_chunks_used); + + return 0; +} + +void ami_memory_slab_dump(void) +{ + __get_slab_usage(ami_memory_slab_callback); +} #endif -- cgit v1.2.3