diff options
author | Christoph Lameter <cl@linux.com> | 2012-09-04 19:18:33 -0400 |
---|---|---|
committer | Pekka Enberg <penberg@kernel.org> | 2012-09-05 05:00:35 -0400 |
commit | 945cf2b6199be70ff03102b9e642c3bb05d01de9 (patch) | |
tree | b0deef56b1d79af1054f0cf1bd91c6fb00ce31a5 /mm/slob.c | |
parent | 7c9adf5a5471647f392169ef19d3e81dcfa76045 (diff) |
mm/sl[aou]b: Extract a common function for kmem_cache_destroy
kmem_cache_destroy does basically the same in all allocators.
Extract common code which is easy since we already have common mutex
handling.
Reviewed-by: Glauber Costa <glommer@parallels.com>
Signed-off-by: Christoph Lameter <cl@linux.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
Diffstat (limited to 'mm/slob.c')
-rw-r--r-- | mm/slob.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -538,18 +538,11 @@ struct kmem_cache *__kmem_cache_create(const char *name, size_t size, | |||
538 | return c; | 538 | return c; |
539 | } | 539 | } |
540 | 540 | ||
541 | void kmem_cache_destroy(struct kmem_cache *c) | 541 | void __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 | |||
547 | kmemleak_free(c); | 543 | kmemleak_free(c); |
548 | if (c->flags & SLAB_DESTROY_BY_RCU) | ||
549 | rcu_barrier(); | ||
550 | slob_free(c, sizeof(struct kmem_cache)); | 544 | slob_free(c, sizeof(struct kmem_cache)); |
551 | } | 545 | } |
552 | EXPORT_SYMBOL(kmem_cache_destroy); | ||
553 | 546 | ||
554 | void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node) | 547 | void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node) |
555 | { | 548 | { |
@@ -617,6 +610,12 @@ unsigned int kmem_cache_size(struct kmem_cache *c) | |||
617 | } | 610 | } |
618 | EXPORT_SYMBOL(kmem_cache_size); | 611 | EXPORT_SYMBOL(kmem_cache_size); |
619 | 612 | ||
613 | int __kmem_cache_shutdown(struct kmem_cache *c) | ||
614 | { | ||
615 | /* No way to check for remaining objects */ | ||
616 | return 0; | ||
617 | } | ||
618 | |||
620 | int kmem_cache_shrink(struct kmem_cache *d) | 619 | int kmem_cache_shrink(struct kmem_cache *d) |
621 | { | 620 | { |
622 | return 0; | 621 | return 0; |