From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Christoph Lameter <cl@linux-foundation.org>,
Pekka Enberg <penberg@kernel.org>, Matt Mackall <mpm@selenic.com>,
Tejun Heo <tj@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Lai Jiangshan <laijs@cn.fujitsu.com>
Subject: [RFC PATCH 3/6] slab: add kmalloc_align()
Date: Tue, 20 Mar 2012 18:21:21 +0800 [thread overview]
Message-ID: <1332238884-6237-4-git-send-email-laijs@cn.fujitsu.com> (raw)
In-Reply-To: <1332238884-6237-1-git-send-email-laijs@cn.fujitsu.com>
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@cn.fujitsu.com>
---
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@kvack.org. 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@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-03-20 10:16 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-20 10:21 [RFC PATCH 0/6] add kmalloc_align() Lai Jiangshan
2012-03-20 10:21 ` [RFC PATCH 1/6] kenrel.h: add ALIGN_OF_LAST_BIT() Lai Jiangshan
2012-03-20 11:32 ` Michal Nazarewicz
2012-03-20 14:03 ` Alexey Dobriyan
2012-03-20 14:08 ` Christoph Lameter
2012-03-20 14:20 ` Peter Seebach
2012-03-20 10:21 ` [RFC PATCH 2/6] slub: add kmalloc_align() Lai Jiangshan
2012-03-20 14:14 ` Christoph Lameter
2012-03-20 14:21 ` Christoph Lameter
2012-03-20 10:21 ` Lai Jiangshan [this message]
2012-03-20 10:21 ` [RFC PATCH 4/6] slob: don't couple the header size with the alignment Lai Jiangshan
2012-03-20 10:21 ` [RFC PATCH 5/6] slob: add kmalloc_align() Lai Jiangshan
2012-03-20 10:21 ` [RFC PATCH 6/6] workqueue: use kmalloc_align() instead of hacking Lai Jiangshan
2012-03-20 15:15 ` Christoph Lameter
2012-03-20 15:46 ` Tejun Heo
2012-03-21 3:02 ` Lai Jiangshan
2012-03-21 5:14 ` Tejun Heo
2012-03-21 14:12 ` Patch workqueue: create new slab cache " Christoph Lameter
2012-03-21 14:49 ` Eric Dumazet
2012-03-21 15:03 ` Christoph Lameter
2012-03-21 16:04 ` Eric Dumazet
2012-03-21 17:54 ` Christoph Lameter
2012-03-21 18:05 ` Eric Dumazet
2012-03-21 18:20 ` Christoph Lameter
2012-03-21 16:09 ` Tejun Heo
2012-03-21 17:56 ` Christoph Lameter
2012-03-21 13:45 ` [RFC PATCH 6/6] workqueue: use kmalloc_align() " Christoph Lameter
2012-03-26 2:00 ` Lai Jiangshan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1332238884-6237-4-git-send-email-laijs@cn.fujitsu.com \
--to=laijs@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mpm@selenic.com \
--cc=penberg@kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).