linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov@parallels.com>
To: mhocko@suse.cz, akpm@linux-foundation.org
Cc: rientjes@google.com, penberg@kernel.org, cl@linux.com,
	glommer@gmail.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, devel@openvz.org
Subject: [PATCH -mm v3 6/7] slub: adjust memcg caches when creating cache alias
Date: Thu, 20 Feb 2014 11:22:08 +0400	[thread overview]
Message-ID: <0677eab4fd5e0167d799961c95dc68a4df9abc48.1392879001.git.vdavydov@parallels.com> (raw)
In-Reply-To: <cover.1392879001.git.vdavydov@parallels.com>

Otherwise, kzalloc() called from a memcg won't clear the whole object.

Signed-off-by: Vladimir Davydov <vdavydov@parallels.com>
---
 mm/slub.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/mm/slub.c b/mm/slub.c
index 2f40e615368f..cac2ff7fd68c 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3748,7 +3748,11 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
 
 	s = find_mergeable(size, align, flags, name, ctor);
 	if (s) {
+		int i;
+		struct kmem_cache *c;
+
 		s->refcount++;
+
 		/*
 		 * Adjust the object sizes so that we clear
 		 * the complete object on kzalloc.
@@ -3756,6 +3760,15 @@ __kmem_cache_alias(const char *name, size_t size, size_t align,
 		s->object_size = max(s->object_size, (int)size);
 		s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
 
+		for_each_memcg_cache_index(i) {
+			c = cache_from_memcg_idx(s, i);
+			if (!c)
+				continue;
+			c->object_size = s->object_size;
+			c->inuse = max_t(int, c->inuse,
+					 ALIGN(size, sizeof(void *)));
+		}
+
 		if (sysfs_slab_alias(s, name)) {
 			s->refcount--;
 			s = NULL;
-- 
1.7.10.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2014-02-20  7:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-20  7:22 [PATCH -mm v3 0/7] memcg-vs-slab related fixes, improvements, cleanups Vladimir Davydov
2014-02-20  7:22 ` [PATCH -mm v3 1/7] memcg, slab: never try to merge memcg caches Vladimir Davydov
2014-02-20  7:22 ` [PATCH -mm v3 2/7] memcg, slab: cleanup memcg cache creation Vladimir Davydov
2014-02-22  0:11   ` Andrew Morton
2014-02-22  9:28     ` Vladimir Davydov
2014-02-20  7:22 ` [PATCH -mm v3 3/7] memcg, slab: separate memcg vs root cache creation paths Vladimir Davydov
2014-02-20  7:22 ` [PATCH -mm v3 4/7] memcg, slab: unregister cache from memcg before starting to destroy it Vladimir Davydov
2014-02-20  7:22 ` [PATCH -mm v3 5/7] memcg, slab: do not destroy children caches if parent has aliases Vladimir Davydov
2014-02-20  7:22 ` Vladimir Davydov [this message]
2014-02-20  7:22 ` [PATCH -mm v3 7/7] slub: rework sysfs layout for memcg caches Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0677eab4fd5e0167d799961c95dc68a4df9abc48.1392879001.git.vdavydov@parallels.com \
    --to=vdavydov@parallels.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux.com \
    --cc=devel@openvz.org \
    --cc=glommer@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@suse.cz \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox