Skip to content

Commit f100836

Browse files
Vladimir Davydovtorvalds
authored andcommitted
slab: use css id for naming per memcg caches
Currently, we use mem_cgroup->kmemcg_id to guarantee kmem_cache->name uniqueness. This is correct, because kmemcg_id is only released on css free after destroying all per memcg caches. However, I am going to change that and release kmemcg_id on css offline, because it is not wise to keep it for so long, wasting valuable entries of memcg_cache_params->memcg_caches arrays. Therefore, to preserve cache name uniqueness, let us switch to css->id. Signed-off-by: Vladimir Davydov <[email protected]> Cc: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Pekka Enberg <[email protected]> Cc: David Rientjes <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Dave Chinner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 01e5865 commit f100836

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

mm/slab_common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg,
488488
struct kmem_cache *root_cache)
489489
{
490490
static char memcg_name_buf[NAME_MAX + 1]; /* protected by slab_mutex */
491+
struct cgroup_subsys_state *css = mem_cgroup_css(memcg);
491492
struct memcg_cache_array *arr;
492493
struct kmem_cache *s = NULL;
493494
char *cache_name;
@@ -510,10 +511,9 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg,
510511
if (arr->entries[idx])
511512
goto out_unlock;
512513

513-
cgroup_name(mem_cgroup_css(memcg)->cgroup,
514-
memcg_name_buf, sizeof(memcg_name_buf));
514+
cgroup_name(css->cgroup, memcg_name_buf, sizeof(memcg_name_buf));
515515
cache_name = kasprintf(GFP_KERNEL, "%s(%d:%s)", root_cache->name,
516-
idx, memcg_name_buf);
516+
css->id, memcg_name_buf);
517517
if (!cache_name)
518518
goto out_unlock;
519519

0 commit comments

Comments
 (0)