aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.c
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2006-09-26 02:31:37 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-26 11:48:50 -0400
commit117f6eb1d8b8deb6f19fc88fc15bdb413c2a0c79 (patch)
tree471f09cb6223d8241c7edbc283c438414d7cf34e /mm/slab.c
parentdbe5e69d2d6e591996ea2b817b887d03b60bb143 (diff)
[PATCH] slab: extract __kmem_cache_destroy from kmem_cache_destroy
The ability to free memory allocated to a slab cache is also useful if an error occurs during setup of a slab. So extract the function. Signed-off-by: Christoph Lameter <clameter@sgi.com> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Cc: Manfred Spraul <manfred@colorfullife.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r--mm/slab.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/mm/slab.c b/mm/slab.c
index 5e59ce7a46c8..c714741b253b 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -1833,6 +1833,27 @@ static void set_up_list3s(struct kmem_cache *cachep, int index)
1833 } 1833 }
1834} 1834}
1835 1835
1836static void __kmem_cache_destroy(struct kmem_cache *cachep)
1837{
1838 int i;
1839 struct kmem_list3 *l3;
1840
1841 for_each_online_cpu(i)
1842 kfree(cachep->array[i]);
1843
1844 /* NUMA: free the list3 structures */
1845 for_each_online_node(i) {
1846 l3 = cachep->nodelists[i];
1847 if (l3) {
1848 kfree(l3->shared);
1849 free_alien_cache(l3->alien);
1850 kfree(l3);
1851 }
1852 }
1853 kmem_cache_free(&cache_cache, cachep);
1854}
1855
1856
1836/** 1857/**
1837 * calculate_slab_order - calculate size (page order) of slabs 1858 * calculate_slab_order - calculate size (page order) of slabs
1838 * @cachep: pointer to the cache that is being created 1859 * @cachep: pointer to the cache that is being created
@@ -2404,9 +2425,6 @@ EXPORT_SYMBOL(kmem_cache_shrink);
2404 */ 2425 */
2405int kmem_cache_destroy(struct kmem_cache *cachep) 2426int kmem_cache_destroy(struct kmem_cache *cachep)
2406{ 2427{
2407 int i;
2408 struct kmem_list3 *l3;
2409
2410 BUG_ON(!cachep || in_interrupt()); 2428 BUG_ON(!cachep || in_interrupt());
2411 2429
2412 /* Don't let CPUs to come and go */ 2430 /* Don't let CPUs to come and go */
@@ -2432,19 +2450,7 @@ int kmem_cache_destroy(struct kmem_cache *cachep)
2432 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU)) 2450 if (unlikely(cachep->flags & SLAB_DESTROY_BY_RCU))
2433 synchronize_rcu(); 2451 synchronize_rcu();
2434 2452
2435 for_each_online_cpu(i) 2453 __kmem_cache_destroy(cachep);
2436 kfree(cachep->array[i]);
2437
2438 /* NUMA: free the list3 structures */
2439 for_each_online_node(i) {
2440 l3 = cachep->nodelists[i];
2441 if (l3) {
2442 kfree(l3->shared);
2443 free_alien_cache(l3->alien);
2444 kfree(l3);
2445 }
2446 }
2447 kmem_cache_free(&cache_cache, cachep);
2448 unlock_cpu_hotplug(); 2454 unlock_cpu_hotplug();
2449 return 0; 2455 return 0;
2450} 2456}