diff options
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slab.c | 38 |
1 files changed, 22 insertions, 16 deletions
@@ -1833,6 +1833,27 @@ static void set_up_list3s(struct kmem_cache *cachep, int index) | |||
1833 | } | 1833 | } |
1834 | } | 1834 | } |
1835 | 1835 | ||
1836 | static 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 | */ |
2405 | int kmem_cache_destroy(struct kmem_cache *cachep) | 2426 | int 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 | } |