Good idea. But have you tried to look at slabinfo?
Try to run
slabinfo -t
which will calculate the allocation overhead of the currently allocated
objects in all slab caches.
One problem: The actual size of kmalloc'ed objects is not available so it
does not calculate the overhead that comes about because of rounding. Your
approach would cover that as well but I think we could also add a debug
mode in which we store the actual size of a kmalloc object and export the
information via sysfs. Would be nicer than adding this whole additional
layer.
--