From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754051AbaCMPHN (ORCPT ); Thu, 13 Mar 2014 11:07:13 -0400 Received: from relay.parallels.com ([195.214.232.42]:56809 "EHLO relay.parallels.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753977AbaCMPHH (ORCPT ); Thu, 13 Mar 2014 11:07:07 -0400 From: Vladimir Davydov To: CC: , , , , , , Christoph Lameter , Pekka Enberg Subject: [PATCH RESEND -mm 12/12] slub: make sure all memcg caches have unique names on sysfs Date: Thu, 13 Mar 2014 19:06:50 +0400 Message-ID: <060fdfeb4dc2b2aa49ff84599ba8e70d49b45688.1394708827.git.vdavydov@parallels.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.30.16.96] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since memcg caches are now reparented on memcg offline, a memcg cache can outlive its cgroup. If the memcg id is then reused for a new cgroup with the same name, we can get cache name collision, which will result in failures while trying to add a sysfs entry for a new cgroup's cache. Let's fix this by appending the cache address to sysfs names of all memcg caches so that they are guaranteed to have unique names. Signed-off-by: Vladimir Davydov Cc: Johannes Weiner Cc: Michal Hocko Cc: Glauber Costa Cc: Christoph Lameter Cc: Pekka Enberg --- mm/slub.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/mm/slub.c b/mm/slub.c index 3ea91fb54f41..f5c74daeb46d 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -5236,7 +5236,18 @@ static int sysfs_slab_add(struct kmem_cache *s) } s->kobj.kset = cache_kset(s); - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name); + /* + * A memcg cache can outlive its cgroup. If the memcg id is then reused + * for a new cgroup with the same name, we can get cache name + * collision. To make sure all memcg caches have unique names on sysfs, + * we append the cache address to its name. + */ + if (is_root_cache(s)) + err = kobject_init_and_add(&s->kobj, &slab_ktype, + NULL, "%s", name); + else + err = kobject_init_and_add(&s->kobj, &slab_ktype, + NULL, "%s-%p", name, s); if (err) goto out_put_kobj; -- 1.7.10.4