aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab_common.c
diff options
context:
space:
mode:
authorChristoph Lameter <cl@linux.com>2012-11-28 11:23:07 -0500
committerPekka Enberg <penberg@kernel.org>2012-12-11 05:14:27 -0500
commit45530c4474d258b822e2639c786606d8257aad8b (patch)
tree87b6569f777987037c490b9660826a02e17e228d /mm/slab_common.c
parent3c58346525d82625e68e24f071804c2dc057b6f4 (diff)
mm, sl[au]b: create common functions for boot slab creation
Use a special function to create kmalloc caches and use that function in SLAB and SLUB. Acked-by: Joonsoo Kim <js1304@gmail.com> Reviewed-by: Glauber Costa <glommer@parallels.com> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Christoph Lameter <cl@linux.com> Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slab_common.c')
-rw-r--r--mm/slab_common.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/mm/slab_common.c b/mm/slab_common.c
index b705be7faa48..497b45c25bae 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -202,6 +202,42 @@ int slab_is_available(void)
202 return slab_state >= UP; 202 return slab_state >= UP;
203} 203}
204 204
205#ifndef CONFIG_SLOB
206/* Create a cache during boot when no slab services are available yet */
207void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t size,
208 unsigned long flags)
209{
210 int err;
211
212 s->name = name;
213 s->size = s->object_size = size;
214 s->align = ARCH_KMALLOC_MINALIGN;
215 err = __kmem_cache_create(s, flags);
216
217 if (err)
218 panic("Creation of kmalloc slab %s size=%zd failed. Reason %d\n",
219 name, size, err);
220
221 s->refcount = -1; /* Exempt from merging for now */
222}
223
224struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
225 unsigned long flags)
226{
227 struct kmem_cache *s = kmem_cache_zalloc(kmem_cache, GFP_NOWAIT);
228
229 if (!s)
230 panic("Out of memory when creating slab %s\n", name);
231
232 create_boot_cache(s, name, size, flags);
233 list_add(&s->list, &slab_caches);
234 s->refcount = 1;
235 return s;
236}
237
238#endif /* !CONFIG_SLOB */
239
240
205#ifdef CONFIG_SLABINFO 241#ifdef CONFIG_SLABINFO
206static void print_slabinfo_header(struct seq_file *m) 242static void print_slabinfo_header(struct seq_file *m)
207{ 243{