[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] [PATCH 1/2] bio: use kmalloc alignment for bio slab


Here I'm sending the patches to avoid mempool allocations from dm-crypt.

It needs a small patch to fs/bio.c that makes bio slab cache aligned, so 
I'm posting this to Jens.

From: Mikulas Patocka <mpatocka redhat com>

Various subsystems can ask the bio subsystem to create a bio slab cache
with some free space before the bio. This free space can be used for any
purpose. Device mapper uses this feature to place some target-specific and
device-mapper specific data before the bio, so that the target-specific
data doesn't have to be allocated separatedly.

This mechanism is used in place of kmalloc, so we need that the allocated
slab have the same memory alignment as memory allocated with kmalloc.

This patch changes the function bio_find_or_create_slab so that it uses
ARCH_KMALLOC_MINALIGN alignment when creating the slab cache. This patch
is needed so that dm-crypt can use per-bio data for encryption - the
crypto subsystem assumes that these data have the same alignment as
kmallocated memory.

Signed-off-by: Mikulas Patocka <mpatocka redhat com>

 fs/bio.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Index: linux-3.14-rc3/fs/bio.c
--- linux-3.14-rc3.orig/fs/bio.c	2014-02-23 23:53:50.000000000 +0100
+++ linux-3.14-rc3/fs/bio.c	2014-02-23 23:55:00.000000000 +0100
@@ -112,7 +112,8 @@ static struct kmem_cache *bio_find_or_cr
 	bslab = &bio_slabs[entry];
 	snprintf(bslab->name, sizeof(bslab->name), "bio-%d", entry);
-	slab = kmem_cache_create(bslab->name, sz, 0, SLAB_HWCACHE_ALIGN, NULL);
+	slab = kmem_cache_create(bslab->name, sz, ARCH_KMALLOC_MINALIGN,
 	if (!slab)
 		goto out_unlock;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]