]> git.proxmox.com Git - mirror_spl.git/commit - module/spl/spl-kmem.c
Linux 2.6.31 kmem cache alignment fixes and cleanup.
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 13 Nov 2009 19:12:43 +0000 (11:12 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 13 Nov 2009 19:12:43 +0000 (11:12 -0800)
commit8b45dda2bc82ee821992b928ea9d7278a953e8f9
tree1919ad6df8bea1089d7d0ec7778e3a8265ba649c
parentc89fdee4d3530e22270ec2b700f697c5e0d46d71
Linux 2.6.31 kmem cache alignment fixes and cleanup.

The big fix here is the removal of kmalloc() in kv_alloc().  It used
to be true in previous kernels that kmallocs over PAGE_SIZE would
always be pages aligned.  This is no longer true atleast in 2.6.31
there are no longer any alignment expectations.  Since kv_alloc()
requires the resulting address to be page align we no only either
directly allocate pages in the KMC_KMEM case, or directly call
__vmalloc() both of which will always return a page aligned address.
Additionally, to avoid wasting memory size is always a power of two.

As for cleanup several helper functions were introduced to calculate
the aligned sizes of various data structures.  This helps ensure no
case is accidentally missed where the alignment needs to be taken in
to account.  The helpers now use P2ROUNDUP_TYPE instead of P2ROUNDUP
which is safer since the type will be explict and we no longer count
on the compiler to auto promote types hopefully as we expected.

Always wnforce minimum (SPL_KMEM_CACHE_ALIGN) and maximum (PAGE_SIZE)
alignment restrictions at cache creation time.

Use SPL_KMEM_CACHE_ALIGN in splat alignment test.
include/sys/sysmacros.h
module/spl/spl-kmem.c
module/splat/splat-kmem.c