Skip to content

Commit 93030d8

Browse files
Vladimir Davydovtorvalds
authored andcommitted
slub: fix memcg_propagate_slab_attrs
After creating a cache for a memcg we should initialize its sysfs attrs with the values from its parent. That's what memcg_propagate_slab_attrs is for. Currently it's broken - we clearly muddled root-vs-memcg caches there. Let's fix it up. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Cc: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: Michal Hocko <mhocko@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3573839 commit 93030d8

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

‎mm/slub.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5071,15 +5071,18 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s)
50715071
#ifdef CONFIG_MEMCG_KMEM
50725072
int i;
50735073
char *buffer = NULL;
5074+
struct kmem_cache *root_cache;
50745075

5075-
if (!is_root_cache(s))
5076+
if (is_root_cache(s))
50765077
return;
50775078

5079+
root_cache = s->memcg_params->root_cache;
5080+
50785081
/*
50795082
* This mean this cache had no attribute written. Therefore, no point
50805083
* in copying default values around
50815084
*/
5082-
if (!s->max_attr_size)
5085+
if (!root_cache->max_attr_size)
50835086
return;
50845087

50855088
for (i = 0; i < ARRAY_SIZE(slab_attrs); i++) {
@@ -5101,7 +5104,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s)
51015104
*/
51025105
if (buffer)
51035106
buf = buffer;
5104-
else if (s->max_attr_size < ARRAY_SIZE(mbuf))
5107+
else if (root_cache->max_attr_size < ARRAY_SIZE(mbuf))
51055108
buf = mbuf;
51065109
else {
51075110
buffer = (char *) get_zeroed_page(GFP_KERNEL);
@@ -5110,7 +5113,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s)
51105113
buf = buffer;
51115114
}
51125115

5113-
attr->show(s->memcg_params->root_cache, buf);
5116+
attr->show(root_cache, buf);
51145117
attr->store(s, buf, strlen(buf));
51155118
}
51165119

0 commit comments

Comments
 (0)