|
Description
|
A new ::kmem_slabs dcmd makes it possible to observe fragmentation in the kmem slab layer, enabling work on a kmem callback to remedy that fragmentation; see
6554564 slab allocator cannot release slabs with lonely buffers
The command displays all kmem caches by default, or it can act on a specific cache address:
> fffffffec0022a08::kmem_slabs
Partial Unused
Cache Name Slabs Slabs Buffers Buffers Waste
------------------------- -------- -------- --------- --------- ------
kmem_bufctl_cache 322 1 54096 6 0.0%
or you can specify a cache by name:
> ::kmem_slabs -n kmem_bufctl_cache
Partial Unused
Cache Name Slabs Slabs Buffers Buffers Waste
------------------------- -------- -------- --------- --------- ------
kmem_bufctl_cache 325 1 54600 126 0.2%
The command includes a -v option to show how well slabs are ordered by usage, and also -b and -B options to display the -v output as a distribution. See the attached kmem_slabs.out for sample verbose output. Following is the command help:
> ::help kmem_slabs
NAME
kmem_slabs - display slab usage per kmem cache
SYNOPSIS
[ addr ] ::kmem_slabs [-v] [-n cache] [-b maxbins] [-B minbinsize]
DESCRIPTION
Display slab usage per kmem cache.
OPTIONS
-n name
name of kmem cache (or matching partial name)
-b maxbins
Print a distribution of allocated buffers per slab using at
most maxbins bins. The first bin is reserved for completely
allocated slabs. Setting maxbins to zero (-b 0) has the same
effect as specifying the maximum allocated buffers per slab
or setting minbinsize to 1 (-B 1).
-B minbinsize
Print a distribution of allocated buffers per slab, making
all bins (except the first, reserved for completely allocated
slabs) at least minbinsize buffers apart.
-v verbose output: List the allocated buffer count of each partial
slab on the free list in order from front to back to show how
closely the slabs are ordered by usage. For example
10 complete, 3 partial (8): 7 3 1
means there are thirteen slabs with eight buffers each, including
three partially allocated slabs with less than all eight buffers
allocated.
Buffer allocations are always from the front of the partial slab
list. When a buffer is freed from a completely used slab, that
slab is added to the front of the partial slab list. Assuming
that all buffers are equally likely to be freed soon, the
desired order of partial slabs is most-used at the front of the
list and least-used at the back (as in the example above).
However, if a slab contains an allocated buffer that will not
soon be freed, it would be better for that slab to be at the
front where it can get used up. Taking a slab off the partial
slab list (either with all buffers freed or all buffers
allocated) reduces cache fragmentation.
Column Description
Cache Name name of kmem cache
Slabs total slab count
Partial Slabs count of partially allocated slabs on the free list
Buffers total buffer count (Slabs * (buffers per slab))
Unused Buffers count of unallocated buffers across all partial slabs
Waste (Unused Buffers / Buffers) does not include space
for accounting structures (debug mode), slab
coloring (incremental small offsets to stagger
buffer alignment), or the per-CPU magazine layer
ATTRIBUTES
Target: kvm
Module: genunix
Interface Stability: Unstable
|