diff options
author | Vladimir Davydov <vdavydov@parallels.com> | 2015-02-10 17:11:44 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-10 17:30:34 -0500 |
commit | 3e0350a36414a73c5c2d1e354f8c0ab4ace1296d (patch) | |
tree | 70d8c13dd7f32f684f0f3653fe5616c43b8726b5 /mm | |
parent | dbf22eb6d8675fc173154d9f1bd1bd0fda53a001 (diff) |
memcg: zap memcg_name argument of memcg_create_kmem_cache
Instead of passing the name of the memory cgroup which the cache is
created for in the memcg_name_argument, let's obtain it immediately in
memcg_create_kmem_cache.
Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memcontrol.c | 5 | ||||
-rw-r--r-- | mm/slab_common.c | 9 |
2 files changed, 6 insertions, 8 deletions
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index e229e3ad615c..baf7eb27e3ae 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
@@ -2607,8 +2607,6 @@ void memcg_update_array_size(int num) | |||
2607 | static void memcg_register_cache(struct mem_cgroup *memcg, | 2607 | static void memcg_register_cache(struct mem_cgroup *memcg, |
2608 | struct kmem_cache *root_cache) | 2608 | struct kmem_cache *root_cache) |
2609 | { | 2609 | { |
2610 | static char memcg_name_buf[NAME_MAX + 1]; /* protected by | ||
2611 | memcg_slab_mutex */ | ||
2612 | struct kmem_cache *cachep; | 2610 | struct kmem_cache *cachep; |
2613 | int id; | 2611 | int id; |
2614 | 2612 | ||
@@ -2624,8 +2622,7 @@ static void memcg_register_cache(struct mem_cgroup *memcg, | |||
2624 | if (cache_from_memcg_idx(root_cache, id)) | 2622 | if (cache_from_memcg_idx(root_cache, id)) |
2625 | return; | 2623 | return; |
2626 | 2624 | ||
2627 | cgroup_name(memcg->css.cgroup, memcg_name_buf, NAME_MAX + 1); | 2625 | cachep = memcg_create_kmem_cache(memcg, root_cache); |
2628 | cachep = memcg_create_kmem_cache(memcg, root_cache, memcg_name_buf); | ||
2629 | /* | 2626 | /* |
2630 | * If we could not create a memcg cache, do not complain, because | 2627 | * If we could not create a memcg cache, do not complain, because |
2631 | * that's not critical at all as we can always proceed with the root | 2628 | * that's not critical at all as we can always proceed with the root |
diff --git a/mm/slab_common.c b/mm/slab_common.c index 67f182c10f24..1b782a2d3b3d 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
@@ -430,16 +430,15 @@ EXPORT_SYMBOL(kmem_cache_create); | |||
430 | * memcg_create_kmem_cache - Create a cache for a memory cgroup. | 430 | * memcg_create_kmem_cache - Create a cache for a memory cgroup. |
431 | * @memcg: The memory cgroup the new cache is for. | 431 | * @memcg: The memory cgroup the new cache is for. |
432 | * @root_cache: The parent of the new cache. | 432 | * @root_cache: The parent of the new cache. |
433 | * @memcg_name: The name of the memory cgroup (used for naming the new cache). | ||
434 | * | 433 | * |
435 | * This function attempts to create a kmem cache that will serve allocation | 434 | * This function attempts to create a kmem cache that will serve allocation |
436 | * requests going from @memcg to @root_cache. The new cache inherits properties | 435 | * requests going from @memcg to @root_cache. The new cache inherits properties |
437 | * from its parent. | 436 | * from its parent. |
438 | */ | 437 | */ |
439 | struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg, | 438 | struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg, |
440 | struct kmem_cache *root_cache, | 439 | struct kmem_cache *root_cache) |
441 | const char *memcg_name) | ||
442 | { | 440 | { |
441 | static char memcg_name_buf[NAME_MAX + 1]; /* protected by slab_mutex */ | ||
443 | struct kmem_cache *s = NULL; | 442 | struct kmem_cache *s = NULL; |
444 | char *cache_name; | 443 | char *cache_name; |
445 | 444 | ||
@@ -448,8 +447,10 @@ struct kmem_cache *memcg_create_kmem_cache(struct mem_cgroup *memcg, | |||
448 | 447 | ||
449 | mutex_lock(&slab_mutex); | 448 | mutex_lock(&slab_mutex); |
450 | 449 | ||
450 | cgroup_name(mem_cgroup_css(memcg)->cgroup, | ||
451 | memcg_name_buf, sizeof(memcg_name_buf)); | ||
451 | cache_name = kasprintf(GFP_KERNEL, "%s(%d:%s)", root_cache->name, | 452 | cache_name = kasprintf(GFP_KERNEL, "%s(%d:%s)", root_cache->name, |
452 | memcg_cache_id(memcg), memcg_name); | 453 | memcg_cache_id(memcg), memcg_name_buf); |
453 | if (!cache_name) | 454 | if (!cache_name) |
454 | goto out_unlock; | 455 | goto out_unlock; |
455 | 456 | ||