aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/slab_common.c')
-rw-r--r--mm/slab_common.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/mm/slab_common.c b/mm/slab_common.c
index 2834bc2886fd..2dd920dc3776 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -205,6 +205,8 @@ kmem_cache_create(const char *name, size_t size, size_t align,
205 int err; 205 int err;
206 206
207 get_online_cpus(); 207 get_online_cpus();
208 get_online_mems();
209
208 mutex_lock(&slab_mutex); 210 mutex_lock(&slab_mutex);
209 211
210 err = kmem_cache_sanity_check(name, size); 212 err = kmem_cache_sanity_check(name, size);
@@ -239,6 +241,8 @@ kmem_cache_create(const char *name, size_t size, size_t align,
239 241
240out_unlock: 242out_unlock:
241 mutex_unlock(&slab_mutex); 243 mutex_unlock(&slab_mutex);
244
245 put_online_mems();
242 put_online_cpus(); 246 put_online_cpus();
243 247
244 if (err) { 248 if (err) {
@@ -272,6 +276,8 @@ void kmem_cache_create_memcg(struct mem_cgroup *memcg, struct kmem_cache *root_c
272 char *cache_name; 276 char *cache_name;
273 277
274 get_online_cpus(); 278 get_online_cpus();
279 get_online_mems();
280
275 mutex_lock(&slab_mutex); 281 mutex_lock(&slab_mutex);
276 282
277 /* 283 /*
@@ -295,6 +301,8 @@ void kmem_cache_create_memcg(struct mem_cgroup *memcg, struct kmem_cache *root_c
295 301
296out_unlock: 302out_unlock:
297 mutex_unlock(&slab_mutex); 303 mutex_unlock(&slab_mutex);
304
305 put_online_mems();
298 put_online_cpus(); 306 put_online_cpus();
299} 307}
300 308
@@ -328,6 +336,8 @@ void slab_kmem_cache_release(struct kmem_cache *s)
328void kmem_cache_destroy(struct kmem_cache *s) 336void kmem_cache_destroy(struct kmem_cache *s)
329{ 337{
330 get_online_cpus(); 338 get_online_cpus();
339 get_online_mems();
340
331 mutex_lock(&slab_mutex); 341 mutex_lock(&slab_mutex);
332 342
333 s->refcount--; 343 s->refcount--;
@@ -359,15 +369,36 @@ void kmem_cache_destroy(struct kmem_cache *s)
359#else 369#else
360 slab_kmem_cache_release(s); 370 slab_kmem_cache_release(s);
361#endif 371#endif
362 goto out_put_cpus; 372 goto out;
363 373
364out_unlock: 374out_unlock:
365 mutex_unlock(&slab_mutex); 375 mutex_unlock(&slab_mutex);
366out_put_cpus: 376out:
377 put_online_mems();
367 put_online_cpus(); 378 put_online_cpus();
368} 379}
369EXPORT_SYMBOL(kmem_cache_destroy); 380EXPORT_SYMBOL(kmem_cache_destroy);
370 381
382/**
383 * kmem_cache_shrink - Shrink a cache.
384 * @cachep: The cache to shrink.
385 *
386 * Releases as many slabs as possible for a cache.
387 * To help debugging, a zero exit status indicates all slabs were released.
388 */
389int kmem_cache_shrink(struct kmem_cache *cachep)
390{
391 int ret;
392
393 get_online_cpus();
394 get_online_mems();
395 ret = __kmem_cache_shrink(cachep);
396 put_online_mems();
397 put_online_cpus();
398 return ret;
399}
400EXPORT_SYMBOL(kmem_cache_shrink);
401
371int slab_is_available(void) 402int slab_is_available(void)
372{ 403{
373 return slab_state >= UP; 404 return slab_state >= UP;