mm/sl[aou]b: Use "kmem_cache" name for slab cache with kmem_cache struct
[firefly-linux-kernel-4.4.55.git] / mm / slob.c
index 95d1c7dd88e0e2c8775cff9ec5f5491c03973e42..7d272c3dcc083263088460961b62f757c45ce68b 100644 (file)
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -59,6 +59,8 @@
 
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include "slab.h"
+
 #include <linux/mm.h>
 #include <linux/swap.h> /* struct reclaim_state */
 #include <linux/cache.h>
@@ -506,7 +508,7 @@ size_t ksize(const void *block)
 }
 EXPORT_SYMBOL(ksize);
 
-struct kmem_cache *kmem_cache_create(const char *name, size_t size,
+struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
        size_t align, unsigned long flags, void (*ctor)(void *))
 {
        struct kmem_cache *c;
@@ -516,7 +518,7 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
 
        if (c) {
                c->name = name;
-               c->size = c->object_size;
+               c->size = size;
                if (flags & SLAB_DESTROY_BY_RCU) {
                        /* leave room for rcu footer at the end of object */
                        c->size += sizeof(struct slob_rcu);
@@ -529,22 +531,18 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size,
                        c->align = ARCH_SLAB_MINALIGN;
                if (c->align < align)
                        c->align = align;
-       } else if (flags & SLAB_PANIC)
-               panic("Cannot create slab cache %s\n", name);
 
-       kmemleak_alloc(c, sizeof(struct kmem_cache), 1, GFP_KERNEL);
+               kmemleak_alloc(c, sizeof(struct kmem_cache), 1, GFP_KERNEL);
+               c->refcount = 1;
+       }
        return c;
 }
-EXPORT_SYMBOL(kmem_cache_create);
 
-void kmem_cache_destroy(struct kmem_cache *c)
+void __kmem_cache_destroy(struct kmem_cache *c)
 {
        kmemleak_free(c);
-       if (c->flags & SLAB_DESTROY_BY_RCU)
-               rcu_barrier();
        slob_free(c, sizeof(struct kmem_cache));
 }
-EXPORT_SYMBOL(kmem_cache_destroy);
 
 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
 {
@@ -612,25 +610,32 @@ unsigned int kmem_cache_size(struct kmem_cache *c)
 }
 EXPORT_SYMBOL(kmem_cache_size);
 
-int kmem_cache_shrink(struct kmem_cache *d)
+int __kmem_cache_shutdown(struct kmem_cache *c)
 {
+       /* No way to check for remaining objects */
        return 0;
 }
-EXPORT_SYMBOL(kmem_cache_shrink);
-
-static unsigned int slob_ready __read_mostly;
 
-int slab_is_available(void)
+int kmem_cache_shrink(struct kmem_cache *d)
 {
-       return slob_ready;
+       return 0;
 }
+EXPORT_SYMBOL(kmem_cache_shrink);
+
+struct kmem_cache kmem_cache_boot = {
+       .name = "kmem_cache",
+       .size = sizeof(struct kmem_cache),
+       .flags = SLAB_PANIC,
+       .align = ARCH_KMALLOC_MINALIGN,
+};
 
 void __init kmem_cache_init(void)
 {
-       slob_ready = 1;
+       kmem_cache = &kmem_cache_boot;
+       slab_state = UP;
 }
 
 void __init kmem_cache_init_late(void)
 {
-       /* Nothing to do */
+       slab_state = FULL;
 }