Commit 84d0ddd6b0e3187d85e609c2d10c36089cf0be04
Committed by
Linus Torvalds
1 parent
b8529907ba
Exists in
master
and in
13 other branches
slub: adjust memcg caches when creating cache alias
Otherwise, kzalloc() called from a memcg won't clear the whole object. Signed-off-by: Vladimir Davydov <vdavydov@parallels.com> Cc: Michal Hocko <mhocko@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: David Rientjes <rientjes@google.com> Cc: Pekka Enberg <penberg@kernel.org> Cc: Glauber Costa <glommer@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 13 additions and 0 deletions Side-by-side Diff
mm/slub.c
... | ... | @@ -3748,13 +3748,26 @@ |
3748 | 3748 | |
3749 | 3749 | s = find_mergeable(size, align, flags, name, ctor); |
3750 | 3750 | if (s) { |
3751 | + int i; | |
3752 | + struct kmem_cache *c; | |
3753 | + | |
3751 | 3754 | s->refcount++; |
3755 | + | |
3752 | 3756 | /* |
3753 | 3757 | * Adjust the object sizes so that we clear |
3754 | 3758 | * the complete object on kzalloc. |
3755 | 3759 | */ |
3756 | 3760 | s->object_size = max(s->object_size, (int)size); |
3757 | 3761 | s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); |
3762 | + | |
3763 | + for_each_memcg_cache_index(i) { | |
3764 | + c = cache_from_memcg_idx(s, i); | |
3765 | + if (!c) | |
3766 | + continue; | |
3767 | + c->object_size = s->object_size; | |
3768 | + c->inuse = max_t(int, c->inuse, | |
3769 | + ALIGN(size, sizeof(void *))); | |
3770 | + } | |
3758 | 3771 | |
3759 | 3772 | if (sysfs_slab_alias(s, name)) { |
3760 | 3773 | s->refcount--; |