Chapter3:MemoryManagement
and freed usingkmem_cache_allocandkmem_cache_free. The slab allocator is automatically responsible
for interaction with the buddy system to reserve the required pages.
A list of all active caches is held in/proc/slabinfo(the output below omits a few less important columns
for reasons of space).^28
wolfgang@meitner>cat /proc/slabinfo
slabinfo - version: 2.1
name : tunables
nf_conntrack_expect 0 0 224 18 1 : tunables 0 0 0 : slabdata 0 0 0
UDPv6 16 16 960 4 1 : tunables 0 0 0 : slabdata 4 4 0
TCPv6 19 20 1792 4 2 : tunables 0 0 0 : slabdata 5 5 0
xfs_inode 25721 25725 576 7 1 : tunables 0 0 0 : slabdata 3675 3675 0
xfs_efi_item 44 44 352 11 1 : tunables 0 0 0 : slabdata 4 4 0
xfs_efd_item 44 44 360 11 1 : tunables 0 0 0 :
slabdata 4 4 0
...
kmalloc-128 795 992 128 32 1 : tunables 0 0 0 : slabdata 31 31 0
kmalloc-64 19469 19584 64 64 1 : tunables 0 0 0 : slabdata 306 306 0
kmalloc-32 2942 2944 32 128 1 : tunables 0 0 0 : slabdata 23 23 0
kmalloc-16 2869 3072 16 256 1 : tunables 0 0 0 : slabdata 12 12 0
kmalloc-8 4075 4096 8 512 1 : tunables 0 0 0 : slabdata 8 8 0
kmalloc-192 2940 3276 192 21 1 : tunables 0 0 0 : slabdata 156 156 0
kmalloc-96 754 798 96 42 1 : tunables 0 0 0 : slabdata 19 19 0
The file columns contain the following information in addition to a string that identifies each cache (and
also ensures that no identical caches are created):
❑ Number of active objects in the cache.
❑ Total number of objects in the cache (used and unused).
❑ Size of the managed objects in bytes.
❑ Number of objects in a slab.
❑ Pages per slab.
❑ Number of active slabs.
❑ Object number allocated when the kernel decides to make more memory available to a cache. (A
larger memory block is allocated in one chunk so that the required interaction with the buddy
system is worthwhile.) This value is also used as the block size when shrinking the cache.
(^28) Additional information on slab allocator statistics is output if theCONFIG_DEBUG_SLABoption is set at compilation time.