[RFC PATCH 3/6] slab: add kmalloc_align()

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

 



ALIGN_OF_LAST_BIT(sizes[INDEX_AC].cs_size) is used instead of
ARCH_KMALLOC_MINALIGN when kmalloc kmem_caches are created.

No behavior changed except debug.

Signed-off-by: Lai Jiangshan <laijs@xxxxxxxxxxxxxx>
---
 include/linux/slab_def.h |    6 ++++++
 mm/slab.c                |    8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
index fbd1117..fb0c8ab 100644
--- a/include/linux/slab_def.h
+++ b/include/linux/slab_def.h
@@ -159,6 +159,12 @@ found:
 	return __kmalloc(size, flags);
 }
 
+static __always_inline
+void *kmalloc_align(size_t size, gfp_t flags, size_t align)
+{
+	return kmalloc(ALIGN(size, align), flags);
+}
+
 #ifdef CONFIG_NUMA
 extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
diff --git a/mm/slab.c b/mm/slab.c
index f0bd785..df8edbe 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1587,7 +1587,7 @@ void __init kmem_cache_init(void)
 
 	sizes[INDEX_AC].cs_cachep = kmem_cache_create(names[INDEX_AC].name,
 					sizes[INDEX_AC].cs_size,
-					ARCH_KMALLOC_MINALIGN,
+					ALIGN_OF_LAST_BIT(sizes[INDEX_AC].cs_size),
 					ARCH_KMALLOC_FLAGS|SLAB_PANIC,
 					NULL);
 
@@ -1595,7 +1595,7 @@ void __init kmem_cache_init(void)
 		sizes[INDEX_L3].cs_cachep =
 			kmem_cache_create(names[INDEX_L3].name,
 				sizes[INDEX_L3].cs_size,
-				ARCH_KMALLOC_MINALIGN,
+				ALIGN_OF_LAST_BIT(sizes[INDEX_L3].cs_size),
 				ARCH_KMALLOC_FLAGS|SLAB_PANIC,
 				NULL);
 	}
@@ -1613,7 +1613,7 @@ void __init kmem_cache_init(void)
 		if (!sizes->cs_cachep) {
 			sizes->cs_cachep = kmem_cache_create(names->name,
 					sizes->cs_size,
-					ARCH_KMALLOC_MINALIGN,
+					ALIGN_OF_LAST_BIT(sizes->cs_size),
 					ARCH_KMALLOC_FLAGS|SLAB_PANIC,
 					NULL);
 		}
@@ -1621,7 +1621,7 @@ void __init kmem_cache_init(void)
 		sizes->cs_dmacachep = kmem_cache_create(
 					names->name_dma,
 					sizes->cs_size,
-					ARCH_KMALLOC_MINALIGN,
+					ALIGN_OF_LAST_BIT(sizes->cs_size),
 					ARCH_KMALLOC_FLAGS|SLAB_CACHE_DMA|
 						SLAB_PANIC,
 					NULL);
-- 
1.7.4.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]