diff options
author | Vladimir Davydov <vdavydov@parallels.com> | 2014-04-07 18:39:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-07 19:36:13 -0400 |
commit | 84d0ddd6b0e3187d85e609c2d10c36089cf0be04 (patch) | |
tree | 9b5fc606816eda4bf2ca5c980a876d149d3e4692 /mm | |
parent | b8529907ba35d625fa4b85d3e4dc8021be97c1f3 (diff) |
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>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/slub.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -3748,7 +3748,11 @@ __kmem_cache_alias(const char *name, size_t size, size_t align, | |||
3748 | 3748 | ||
3749 | s = find_mergeable(size, align, flags, name, ctor); | 3749 | s = find_mergeable(size, align, flags, name, ctor); |
3750 | if (s) { | 3750 | if (s) { |
3751 | int i; | ||
3752 | struct kmem_cache *c; | ||
3753 | |||
3751 | s->refcount++; | 3754 | s->refcount++; |
3755 | |||
3752 | /* | 3756 | /* |
3753 | * Adjust the object sizes so that we clear | 3757 | * Adjust the object sizes so that we clear |
3754 | * the complete object on kzalloc. | 3758 | * the complete object on kzalloc. |
@@ -3756,6 +3760,15 @@ __kmem_cache_alias(const char *name, size_t size, size_t align, | |||
3756 | s->object_size = max(s->object_size, (int)size); | 3760 | s->object_size = max(s->object_size, (int)size); |
3757 | s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); | 3761 | s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *))); |
3758 | 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 | } | ||
3771 | |||
3759 | if (sysfs_slab_alias(s, name)) { | 3772 | if (sysfs_slab_alias(s, name)) { |
3760 | s->refcount--; | 3773 | s->refcount--; |
3761 | s = NULL; | 3774 | s = NULL; |