[RFC PATCH 3/6] slab: add kmalloc_align()
From: Lai Jiangshan
Date: Tue Mar 20 2012 - 06:16:24 EST
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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/