I'm having trouble understanding the purpose of a couple of statistics
recorded in the calls to malloc(9) and free(9).

The first is displayed by 'systat malloc' under the KERN LIMIT column.
The value is taken from ks_mapblocks. From kmemstats structure in
sys/malloc.h:

u_short ks_mapblocks;   /* number of times blocked for kernel map */

The comment suggests it's something that would be incremented when a
call to uvm_km_kmemalloc_pla returns NULL because the map is full.
This doesn't happen though, and as far as I can tell ks_mapblocks
isn't referenced/used anywhere outside of its declaration except for
systat/sysctl. Is its usage deprecated perhaps? 

The second variable is kb_couldfree.  This is more puzzling.  It's
only incremented in free().  From struct kmembuckets:

u_int64_t kb_couldfree; /* over high water mark and could free */ 

This sounds like excess items in the bucket which could be reclaimed
if needed elsewhere; but that seems unlikely given that 1) the
variable isn't decremented anywhere that I can find, and 2) some of
the values reported by 'systat buckets', when multiplied by the size
of the bucket item, exceed the size of the entire malloc arena.

What does kb_couldfree actually mean? (or what am I not getting?)

Reply via email to