HomeFreeBSD

Linux: Set spl_kmem_cache_slab_limit when page size !4K

Description

Linux: Set spl_kmem_cache_slab_limit when page size !4K

For small objects the kernel's slab implementation is very fast and
space efficient. However, as the allocation size increases to
require multiple pages performance suffers. The SPL kmem cache
allocator was designed to better handle these large allocation
sizes. Therefore, on Linux the kmem_cache_* compatibility wrappers
prefer to use the kernel's slab allocator for small objects and
the custom SPL kmem cache allocator for larger objects.

This logic was effectively disabled for all architectures using
a non-4K page size which caused all kmem caches to only use the
SPL implementation. Functionally this is fine, but the SPL code
which calculates the target number of objects per-slab does not
take in to account that __vmalloc() always returns page-aligned
memory. This can result in a massive amount of wasted space when
allocating tiny objects on a platform using large pages (64k).

To resolve this issue we set the spl_kmem_cache_slab_limit cutoff
to 16K for all architectures.

This particular change does not attempt to update the logic used
to calculate the optimal number of pages per slab. This remains
an issue which should be addressed in a future change.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Tony Nguyen <tony.nguyen@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #12152
Closes #11429
Closes #11574
Closes #12150

Details

Provenance
Brian Behlendorf <behlendorf1@llnl.gov>Authored on Jun 3 2021, 8:37 PM
GitHub <noreply@github.com>Committed on Jun 3 2021, 8:37 PM
Parents
rG739cfb965b00: libzfs: convert to -fvisibility=hidden
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rG783784582225: Linux: Set spl_kmem_cache_slab_limit when page size !4K (authored by Brian Behlendorf <behlendorf1@llnl.gov>).Jun 3 2021, 8:37 PM