提交 93030d83 编写于 作者: V Vladimir Davydov 提交者: Linus Torvalds

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: NVladimir 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 35738392
...@@ -5071,15 +5071,18 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s) ...@@ -5071,15 +5071,18 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s)
#ifdef CONFIG_MEMCG_KMEM #ifdef CONFIG_MEMCG_KMEM
int i; int i;
char *buffer = NULL; char *buffer = NULL;
struct kmem_cache *root_cache;
if (!is_root_cache(s)) if (is_root_cache(s))
return; return;
root_cache = s->memcg_params->root_cache;
/* /*
* This mean this cache had no attribute written. Therefore, no point * This mean this cache had no attribute written. Therefore, no point
* in copying default values around * in copying default values around
*/ */
if (!s->max_attr_size) if (!root_cache->max_attr_size)
return; return;
for (i = 0; i < ARRAY_SIZE(slab_attrs); i++) { for (i = 0; i < ARRAY_SIZE(slab_attrs); i++) {
...@@ -5101,7 +5104,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s) ...@@ -5101,7 +5104,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s)
*/ */
if (buffer) if (buffer)
buf = buffer; buf = buffer;
else if (s->max_attr_size < ARRAY_SIZE(mbuf)) else if (root_cache->max_attr_size < ARRAY_SIZE(mbuf))
buf = mbuf; buf = mbuf;
else { else {
buffer = (char *) get_zeroed_page(GFP_KERNEL); buffer = (char *) get_zeroed_page(GFP_KERNEL);
...@@ -5110,7 +5113,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s) ...@@ -5110,7 +5113,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s)
buf = buffer; buf = buffer;
} }
attr->show(s->memcg_params->root_cache, buf); attr->show(root_cache, buf);
attr->store(s, buf, strlen(buf)); attr->store(s, buf, strlen(buf));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册