zfs/module/spl
Brian Behlendorf 3018bffa9b Refine slab cache sizing
This change is designed to improve the memory utilization of
slabs by more carefully setting their size.  The way the code
currently works is problematic for slabs which contain large
objects (>1MB).  This is due to slabs being unconditionally
rounded up to a power of two which may result in unused space
at the end of the slab.

The reason the existing code rounds up every slab is because it
assumes it will backed by the buddy allocator.  Since the buddy
allocator can only performs power of two allocations this is
desirable because it avoids wasting any space.  However, this
logic breaks down if slab is backed by vmalloc() which operates
at a page level granularity.  In this case, the optimal thing to
do is calculate the minimum required slab size given certain
constraints (object size, alignment, objects/slab, etc).

Therefore, this patch reworks the spl_slab_size() function so
that it sizes KMC_KMEM slabs differently than KMC_VMEM slabs.
KMC_KMEM slabs are rounded up to the nearest power of two, and
KMC_VMEM slabs are allowed to be the minimum required size.

This change also reduces the default number of objects per slab.
This reduces how much memory a single cache object can pin, which
can result in significant memory saving for highly fragmented
caches.  But depending on the workload it may result in slabs
being allocated and freed more frequently.  In practice, this
has been shown to be a better default for most workloads.

Also the maximum slab size has been reduced to 4MB on 32-bit
systems.  Due to the limited virtual address space it's critical
the we be as frugal as possible.  A limit of 4M still lets us
reasonably comfortably allocate a limited number of 1MB objects.

Finally, the kmem:slab_small and kmem:slab_large SPLAT tests
were extended to provide better test coverage of various object
sizes and alignments.  Caches are created with random parameters
and their basic functionality is verified by allocating several
slabs worth of objects.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
2015-01-16 13:55:09 -08:00
..
Makefile.in Refactor existing code 2015-01-16 13:55:08 -08:00
spl-atomic.c Refresh links to web site 2013-03-04 19:09:34 -08:00
spl-condvar.c Refactor existing code 2015-01-16 13:55:08 -08:00
spl-cred.c Remove credential configure checks. 2014-10-17 15:11:51 -07:00
spl-err.c Retire legacy debugging infrastructure 2014-11-19 10:35:07 -08:00
spl-generic.c Refactor existing code 2015-01-16 13:55:08 -08:00
spl-kmem-cache.c Refine slab cache sizing 2015-01-16 13:55:09 -08:00
spl-kmem.c Add hooks for disabling direct reclaim 2015-01-16 13:55:09 -08:00
spl-kobj.c Retire legacy debugging infrastructure 2014-11-19 10:35:07 -08:00
spl-kstat.c Refactor existing code 2015-01-16 13:55:08 -08:00
spl-mutex.c Remove adaptive mutex implementation 2014-10-17 15:07:28 -07:00
spl-proc.c Refactor generic memory allocation interfaces 2015-01-16 13:55:09 -08:00
spl-rwlock.c Refresh links to web site 2013-03-04 19:09:34 -08:00
spl-taskq.c Retire legacy debugging infrastructure 2014-11-19 10:35:07 -08:00
spl-thread.c Retire legacy debugging infrastructure 2014-11-19 10:35:07 -08:00
spl-tsd.c Refactor generic memory allocation interfaces 2015-01-16 13:55:09 -08:00
spl-vmem.c Add hooks for disabling direct reclaim 2015-01-16 13:55:09 -08:00
spl-vnode.c Refactor existing code 2015-01-16 13:55:08 -08:00
spl-xdr.c Retire legacy debugging infrastructure 2014-11-19 10:35:07 -08:00
spl-zlib.c Refactor existing code 2015-01-16 13:55:08 -08:00