From patchwork Mon Apr 30 10:01:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 8308 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7274223E13 for ; Mon, 30 Apr 2012 10:02:46 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 096A4A185BE for ; Mon, 30 Apr 2012 10:02:45 +0000 (UTC) Received: by iage36 with SMTP id e36so5452583iag.11 for ; Mon, 30 Apr 2012 03:02:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:date:from :to:cc:subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to:user-agent:x-gm-message-state; bh=Bb9M0rPffrXAgsd/iV1sJaS03nEwN0FzHPcrAu9TkEE=; b=KlWYEJT8Y5eFU7mp9tYIN88ldncXDBeITZavD7vONVpuOdHvgQ/Qez28IX5hi4EmxU HhJev5MYpr/Ph2zHgN9QgE84tMGSXQi+FYXSzFwoS1UcUw5Fce8RsCdqDZCrK1jLJNsl Zr84YMLfWVon3KzP1PWr+aLyraGJV6QqvPVHeHgQYWvL/Yc3522QyuVh3odERqg2mVvz QFbaMIpDktXe4lNYgvI+e3mrLDRC95JFRqrPcWU/NuDuRRAUCP9nqYFO94IMcdOJxPjn Z92mLyzYAaPnFvPZrgn1n/BgFqJIeNmFrAFaLbaytpUqV10M91C4Bv2LF9rAAftTJZ7O 3KTg== Received: by 10.50.47.131 with SMTP id d3mr9675779ign.33.1335780165405; Mon, 30 Apr 2012 03:02:45 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.137.198 with SMTP id x6csp104573ibt; Mon, 30 Apr 2012 03:02:44 -0700 (PDT) Received: by 10.68.230.132 with SMTP id sy4mr21577264pbc.75.1335780164762; Mon, 30 Apr 2012 03:02:44 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id g8si14760481pbk.108.2012.04.30.03.02.44 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Apr 2012 03:02:44 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by pbcxa12 with SMTP id xa12so4134280pbc.37 for ; Mon, 30 Apr 2012 03:02:44 -0700 (PDT) Received: by 10.68.223.33 with SMTP id qr1mr2217928pbc.47.1335780164349; Mon, 30 Apr 2012 03:02:44 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id i5sm15600693pbf.19.2012.04.30.03.02.42 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 30 Apr 2012 03:02:43 -0700 (PDT) Date: Mon, 30 Apr 2012 03:01:21 -0700 From: Anton Vorontsov To: Glauber Costa Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, devel@openvz.org, kamezawa.hiroyu@jp.fujitsu.com, Michal Hocko , Johannes Weiner , Frederic Weisbecker , Greg Thelen , Suleiman Souhlal , John Stultz , linaro-kernel@lists.linaro.org, patches@linaro.org Subject: [PATCH 1/3] slab: Proper off-slabs handling when duplicating caches Message-ID: <20120430100121.GA28569@lizard> References: <20120430095918.GA13824@lizard> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20120430095918.GA13824@lizard> User-Agent: Mutt/1.5.21 (2010-09-15) X-Gm-Message-State: ALoCoQnsv50hemZqx4PmipJNahcAdtvS2NoI9BXz6Wgr90CZPc0qnbkbCx78ZowT8njIlTvMMAkK OFF_SLAB is not CREATE_MASK bit, so we should clear it before calling __kmem_cache_create(), otherwise kernel gets very upset, see below. As a side effect, now we let slab to reevaluate off-slab decision, but the decision will be the same, because whether we do off-slabs only depend on the size and create_mask bits. ------------[ cut here ]------------ kernel BUG at mm/slab.c:2376! invalid opcode: 0000 [#1] SMP CPU 0 Pid: 14, comm: kworker/0:1 Not tainted 3.4.0-rc4+ #32 Bochs Bochs RIP: 0010:[] [] __kmem_cache_create+0x609/0x650 RSP: 0018:ffff8800072c9c90 EFLAGS: 00010286 RAX: 0000000000000800 RBX: ffffffff81f26bf8 RCX: 000000000000000b RDX: 000000000000000c RSI: 000000000000000b RDI: ffff8800065c66f8 RBP: ffff8800072c9d40 R08: ffffffff80002800 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000001 R12: ffff8800072c8000 R13: ffff8800072c9fd8 R14: ffffffffffffffff R15: ffff8800072c9d0c FS: 00007f45eb0f2700(0000) GS:ffff880007c00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b CR2: ffffffffff600400 CR3: 000000000650e000 CR4: 00000000000006b0 DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400 Process kworker/0:1 (pid: 14, threadinfo ffff8800072c8000, task ffff88000725d100) Stack: ffff8800072c9cb0 0000000000000000 ffffc9000000c000 ffffffff81621e80 ffff8800072c9cc0 ffffffff81621e80 ffff8800072c9d40 ffffffff81355cbf ffffffff810c1944 0000000000000000 ffffffff81621ec0 ffffffff80002800 Call Trace: [] ? mutex_lock_nested+0x26f/0x340 [] ? kmem_cache_dup+0x44/0x110 [] ? memcg_create_kmem_cache+0xd0/0xd0 [] kmem_cache_dup+0x6b/0x110 [] memcg_create_kmem_cache+0xa3/0xd0 [] memcg_create_cache_work_func+0x7a/0xe0 [] process_one_work+0x174/0x450 [] ? process_one_work+0x116/0x450 [] worker_thread+0x123/0x2d0 [] ? manage_workers.isra.27+0x120/0x120 [] kthread+0x8e/0xa0 Signed-off-by: Anton Vorontsov --- mm/slab.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mm/slab.c b/mm/slab.c index eed72ac..dff87ef 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -2619,6 +2619,13 @@ kmem_cache_dup(struct mem_cgroup *memcg, struct kmem_cache *cachep) return NULL; flags = cachep->flags & ~SLAB_PANIC; + /* + * OFF_SLAB is not CREATE_MASK bit, so we should clear it before + * calling __kmem_cache_create(). As a side effect, we let slab + * to reevaluate off-slab decision; but that is OK, as the bit + * is automatically set depending on the size and other flags. + */ + flags &= ~CFLGS_OFF_SLAB; mutex_lock(&cache_chain_mutex); new = __kmem_cache_create(memcg, name, obj_size(cachep), cachep->memcg_params.orig_align, flags, cachep->ctor);