From: Christoph Lameter <cl@linux.com>
To: Pekka Enberg <penberg@kernel.org>
Cc: Joonsoo Kim <js1304@gmail.com>,
Glauber Costa <glommer@parallels.com>,
linux-mm@kvack.org, David Rientjes <rientjes@google.com>
Subject: CK2 [15/15] Move kmalloc_node functions to common code
Date: Fri, 28 Sep 2012 19:23:55 +0000 [thread overview]
Message-ID: <0000013a0e55c74b-04e82728-332d-48cb-be5c-95c769f5ba4d-000000@email.amazonses.com> (raw)
In-Reply-To: <20120928191715.368450474@linux.com>
Kmalloc_node functions are rather similar now so lets move them
into slab.h.
Signed-off-by: Christoph Lameter <cl@linux.com>
Index: linux/include/linux/slab.h
===================================================================
--- linux.orig/include/linux/slab.h 2012-09-28 13:41:04.541431894 -0500
+++ linux/include/linux/slab.h 2012-09-28 13:41:14.677643504 -0500
@@ -262,6 +262,41 @@ static __always_inline int kmalloc_size(
return 0;
}
+
+#ifdef CONFIG_NUMA
+void *__kmalloc_node(size_t size, gfp_t flags, int node);
+void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
+
+#ifdef CONFIG_TRACING
+extern void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
+ gfp_t gfpflags,
+ int node);
+#else
+static __always_inline void *
+kmem_cache_alloc_node_trace(struct kmem_cache *s,
+ gfp_t gfpflags,
+ int node)
+{
+ return kmem_cache_alloc_node(s, gfpflags, node);
+}
+#endif
+
+static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
+{
+ if (__builtin_constant_p(size) &&
+ size <= KMALLOC_MAX_CACHE_SIZE && !(flags & SLAB_CACHE_DMA)) {
+ int i = kmalloc_index(size);
+
+ if (!i)
+ return ZERO_SIZE_PTR;
+
+ return kmem_cache_alloc_node_trace(kmalloc_caches[i],
+ flags, node);
+ }
+ return __kmalloc_node(size, flags, node);
+}
+#endif
+
#endif /* !CONFIG_SLOB */
/*
Index: linux/include/linux/slub_def.h
===================================================================
--- linux.orig/include/linux/slub_def.h 2012-09-28 13:41:13.073610015 -0500
+++ linux/include/linux/slub_def.h 2012-09-28 13:41:14.677643504 -0500
@@ -200,37 +200,4 @@ static __always_inline void *kmalloc(siz
return __kmalloc(size, flags);
}
-#ifdef CONFIG_NUMA
-void *__kmalloc_node(size_t size, gfp_t flags, int node);
-void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
-
-#ifdef CONFIG_TRACING
-extern void *kmem_cache_alloc_node_trace(struct kmem_cache *s,
- gfp_t gfpflags,
- int node, size_t size);
-#else
-static __always_inline void *
-kmem_cache_alloc_node_trace(struct kmem_cache *s,
- gfp_t gfpflags,
- int node, size_t size)
-{
- return kmem_cache_alloc_node(s, gfpflags, node);
-}
-#endif
-
-static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
-{
- if (__builtin_constant_p(size) &&
- size <= KMALLOC_MAX_CACHE_SIZE && !(flags & SLUB_DMA)) {
- struct kmem_cache *s = kmalloc_slab_inline(size);
-
- if (!s)
- return ZERO_SIZE_PTR;
-
- return kmem_cache_alloc_node_trace(s, flags, node, size);
- }
- return __kmalloc_node(size, flags, node);
-}
-#endif
-
#endif /* _LINUX_SLUB_DEF_H */
Index: linux/mm/slab.c
===================================================================
--- linux.orig/mm/slab.c 2012-09-28 13:41:13.069609936 -0500
+++ linux/mm/slab.c 2012-09-28 13:41:14.677643504 -0500
@@ -3673,8 +3673,7 @@ void *kmem_cache_alloc_node(struct kmem_
EXPORT_SYMBOL(kmem_cache_alloc_node);
#ifdef CONFIG_TRACING
-void *kmem_cache_alloc_node_trace(size_t size,
- struct kmem_cache *cachep,
+void *kmem_cache_alloc_node_trace(struct kmem_cache *cachep,
gfp_t flags,
int nodeid)
{
@@ -3683,7 +3682,7 @@ void *kmem_cache_alloc_node_trace(size_t
ret = __cache_alloc_node(cachep, flags, nodeid,
__builtin_return_address(0));
trace_kmalloc_node(_RET_IP_, ret,
- size, slab_buffer_size(cachep),
+ s->size, slab_buffer_size(cachep),
flags, nodeid);
return ret;
}
@@ -3698,7 +3697,7 @@ __do_kmalloc_node(size_t size, gfp_t fla
cachep = kmalloc_slab(size, flags);
if (unlikely(ZERO_OR_NULL_PTR(cachep)))
return cachep;
- return kmem_cache_alloc_node_trace(size, cachep, flags, node);
+ return kmem_cache_alloc_node_trace(cachep, flags, node);
}
#if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_TRACING)
Index: linux/include/linux/slab_def.h
===================================================================
--- linux.orig/include/linux/slab_def.h 2012-09-28 13:41:00.493347386 -0500
+++ linux/include/linux/slab_def.h 2012-09-28 13:41:14.681643583 -0500
@@ -144,50 +144,4 @@ static __always_inline void *kmalloc(siz
return __kmalloc(size, 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);
-
-#ifdef CONFIG_TRACING
-extern void *kmem_cache_alloc_node_trace(size_t size,
- struct kmem_cache *cachep,
- gfp_t flags,
- int nodeid);
-#else
-static __always_inline void *
-kmem_cache_alloc_node_trace(size_t size,
- struct kmem_cache *cachep,
- gfp_t flags,
- int nodeid)
-{
- return kmem_cache_alloc_node(cachep, flags, nodeid);
-}
-#endif
-
-static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
-{
- struct kmem_cache *cachep;
-
- if (__builtin_constant_p(size)) {
- int i;
-
- if (!size)
- return ZERO_SIZE_PTR;
-
- i = kmalloc_index(size);
-
-#ifdef CONFIG_ZONE_DMA
- if (flags & GFP_DMA)
- cachep = kmalloc_dma_caches[i];
- else
-#endif
- cachep = kmalloc_caches[i];
-
- return kmem_cache_alloc_node_trace(size, cachep, flags, node);
- }
- return __kmalloc_node(size, flags, node);
-}
-
-#endif /* CONFIG_NUMA */
-
#endif /* _LINUX_SLAB_DEF_H */
--
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/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2012-09-28 19:23 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20120928191715.368450474@linux.com>
2012-09-28 19:18 ` CK2 [02/15] create common functions for boot slab creation Christoph Lameter
2012-09-28 19:18 ` CK2 [01/15] slab: Simplify bootstrap Christoph Lameter
2012-09-28 19:23 ` Christoph Lameter [this message]
2012-09-28 19:24 ` CK2 [14/15] Common Kmalloc cache determination Christoph Lameter
2012-09-28 19:24 ` CK2 [07/15] slab: Use common kmalloc_index/kmalloc_size functions Christoph Lameter
2012-10-02 15:10 ` JoonSoo Kim
2012-10-03 15:06 ` Christoph Lameter
2012-09-28 19:24 ` CK2 [12/15] Common function to create the kmalloc array Christoph Lameter
2012-09-28 19:25 ` CK2 [11/15] Common definition for the array of kmalloc caches Christoph Lameter
2012-09-28 19:25 ` CK2 [04/15] slab: Use the new create_boot_cache function to simplify bootstrap Christoph Lameter
2012-10-02 14:56 ` JoonSoo Kim
2012-10-03 14:55 ` Christoph Lameter
2012-09-28 19:25 ` CK2 [05/15] Common alignment code Christoph Lameter
2012-09-28 19:34 ` CK2 [03/15] slub: Use a statically allocated kmem_cache boot structure for bootstrap Christoph Lameter
2012-10-02 14:47 ` JoonSoo Kim
2012-10-03 14:50 ` Christoph Lameter
2012-09-28 19:34 ` CK2 [10/15] Common constants for kmalloc boundaries Christoph Lameter
2012-09-28 19:34 ` CK2 [08/15] slab: Common name for the per node structures Christoph Lameter
2012-09-28 19:39 ` CK2 [06/15] Common kmalloc slab index determination Christoph Lameter
2012-09-28 19:39 ` CK2 [13/15] stat: Use size_t for sizes instead of unsigned Christoph Lameter
2012-09-28 19:59 ` CK2 [09/15] slab: rename nodelists to node Christoph Lameter
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=0000013a0e55c74b-04e82728-332d-48cb-be5c-95c769f5ba4d-000000@email.amazonses.com \
--to=cl@linux.com \
--cc=glommer@parallels.com \
--cc=js1304@gmail.com \
--cc=linux-mm@kvack.org \
--cc=penberg@kernel.org \
--cc=rientjes@google.com \
/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