aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab_common.c
diff options
context:
space:
mode:
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{