aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/slab.c7
-rw-r--r--mm/slab_common.c7
-rw-r--r--mm/slob.c4
-rw-r--r--mm/slub.c2
4 files changed, 16 insertions, 4 deletions
diff --git a/mm/slab.c b/mm/slab.c
index 3b4587bb7b19..a69903168497 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1680,6 +1680,7 @@ void __init kmem_cache_init(void)
1680 ARCH_KMALLOC_FLAGS|SLAB_PANIC, 1680 ARCH_KMALLOC_FLAGS|SLAB_PANIC,
1681 NULL); 1681 NULL);
1682 1682
1683 list_add(&sizes[INDEX_AC].cs_cachep->list, &slab_caches);
1683 if (INDEX_AC != INDEX_L3) { 1684 if (INDEX_AC != INDEX_L3) {
1684 sizes[INDEX_L3].cs_cachep = 1685 sizes[INDEX_L3].cs_cachep =
1685 __kmem_cache_create(names[INDEX_L3].name, 1686 __kmem_cache_create(names[INDEX_L3].name,
@@ -1687,6 +1688,7 @@ void __init kmem_cache_init(void)
1687 ARCH_KMALLOC_MINALIGN, 1688 ARCH_KMALLOC_MINALIGN,
1688 ARCH_KMALLOC_FLAGS|SLAB_PANIC, 1689 ARCH_KMALLOC_FLAGS|SLAB_PANIC,
1689 NULL); 1690 NULL);
1691 list_add(&sizes[INDEX_L3].cs_cachep->list, &slab_caches);
1690 } 1692 }
1691 1693
1692 slab_early_init = 0; 1694 slab_early_init = 0;
@@ -1705,6 +1707,7 @@ void __init kmem_cache_init(void)
1705 ARCH_KMALLOC_MINALIGN, 1707 ARCH_KMALLOC_MINALIGN,
1706 ARCH_KMALLOC_FLAGS|SLAB_PANIC, 1708 ARCH_KMALLOC_FLAGS|SLAB_PANIC,
1707 NULL); 1709 NULL);
1710 list_add(&sizes->cs_cachep->list, &slab_caches);
1708 } 1711 }
1709#ifdef CONFIG_ZONE_DMA 1712#ifdef CONFIG_ZONE_DMA
1710 sizes->cs_dmacachep = __kmem_cache_create( 1713 sizes->cs_dmacachep = __kmem_cache_create(
@@ -1714,6 +1717,7 @@ void __init kmem_cache_init(void)
1714 ARCH_KMALLOC_FLAGS|SLAB_CACHE_DMA| 1717 ARCH_KMALLOC_FLAGS|SLAB_CACHE_DMA|
1715 SLAB_PANIC, 1718 SLAB_PANIC,
1716 NULL); 1719 NULL);
1720 list_add(&sizes->cs_dmacachep->list, &slab_caches);
1717#endif 1721#endif
1718 sizes++; 1722 sizes++;
1719 names++; 1723 names++;
@@ -2583,6 +2587,7 @@ __kmem_cache_create (const char *name, size_t size, size_t align,
2583 } 2587 }
2584 cachep->ctor = ctor; 2588 cachep->ctor = ctor;
2585 cachep->name = name; 2589 cachep->name = name;
2590 cachep->refcount = 1;
2586 2591
2587 if (setup_cpu_cache(cachep, gfp)) { 2592 if (setup_cpu_cache(cachep, gfp)) {
2588 __kmem_cache_destroy(cachep); 2593 __kmem_cache_destroy(cachep);
@@ -2599,8 +2604,6 @@ __kmem_cache_create (const char *name, size_t size, size_t align,
2599 slab_set_debugobj_lock_classes(cachep); 2604 slab_set_debugobj_lock_classes(cachep);
2600 } 2605 }
2601 2606
2602 /* cache setup completed, link it into the list */
2603 list_add(&cachep->list, &slab_caches);
2604 return cachep; 2607 return cachep;
2605} 2608}
2606 2609
diff --git a/mm/slab_common.c b/mm/slab_common.c
index fe8dc943c285..5190a7cd02bd 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -111,6 +111,13 @@ struct kmem_cache *kmem_cache_create(const char *name, size_t size, size_t align
111 if (!s) 111 if (!s)
112 err = -ENOSYS; /* Until __kmem_cache_create returns code */ 112 err = -ENOSYS; /* Until __kmem_cache_create returns code */
113 113
114 /*
115 * Check if the slab has actually been created and if it was a
116 * real instatiation. Aliases do not belong on the list
117 */
118 if (s && s->refcount == 1)
119 list_add(&s->list, &slab_caches);
120
114out_locked: 121out_locked:
115 mutex_unlock(&slab_mutex); 122 mutex_unlock(&slab_mutex);
116 put_online_cpus(); 123 put_online_cpus();
diff --git a/mm/slob.c b/mm/slob.c
index 45d4ca79933a..5225d28f2694 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -540,6 +540,10 @@ struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
540 540
541void kmem_cache_destroy(struct kmem_cache *c) 541void kmem_cache_destroy(struct kmem_cache *c)
542{ 542{
543 mutex_lock(&slab_mutex);
544 list_del(&c->list);
545 mutex_unlock(&slab_mutex);
546
543 kmemleak_free(c); 547 kmemleak_free(c);
544 if (c->flags & SLAB_DESTROY_BY_RCU) 548 if (c->flags & SLAB_DESTROY_BY_RCU)
545 rcu_barrier(); 549 rcu_barrier();
diff --git a/mm/slub.c b/mm/slub.c
index c66908983218..24aa362edef7 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3975,7 +3975,6 @@ struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
3975 size, align, flags, ctor)) { 3975 size, align, flags, ctor)) {
3976 int r; 3976 int r;
3977 3977
3978 list_add(&s->list, &slab_caches);
3979 mutex_unlock(&slab_mutex); 3978 mutex_unlock(&slab_mutex);
3980 r = sysfs_slab_add(s); 3979 r = sysfs_slab_add(s);
3981 mutex_lock(&slab_mutex); 3980 mutex_lock(&slab_mutex);
@@ -3983,7 +3982,6 @@ struct kmem_cache *__kmem_cache_create(const char *name, size_t size,
3983 if (!r) 3982 if (!r)
3984 return s; 3983 return s;
3985 3984
3986 list_del(&s->list);
3987 kmem_cache_close(s); 3985 kmem_cache_close(s);
3988 } 3986 }
3989 kmem_cache_free(kmem_cache, s); 3987 kmem_cache_free(kmem_cache, s);