Path: csiph.com!goblin2!goblin.stu.neva.ru!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod From: "Levin, Alexander (Sasha Levin)" Newsgroups: linux.kernel Subject: [PATCH review for 4.9 24/50] slub: do not merge cache if slub_debug contains a never-merge flag Date: Mon, 25 Sep 2017 03:40:03 +0200 Message-ID: References: X-Original-To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506302043; x=1537838043; h=from:cc:to:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=IkppM5KGPB3dKY7NbueVXBF6F7VaznLDRhfmbbJrph0=; b=ha8RdeqQ2ze+iq45QmHOKrq5SUMtwtBz9PYvhkwVVxNvR2Zul99VfB0S MS51BrrQz9k4satXOFs7itB3xKMwc1gw/0uzqFy7/G7yz7Foj7fJtHs1H wPer3Uy4ObQqA+o6U3VnGtlu8T15tzaynGg+J0PFT+RB6G8VD8DGVAqg6 U=; Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506301978; x=1537837978; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=IkppM5KGPB3dKY7NbueVXBF6F7VaznLDRhfmbbJrph0=; b=X7X7rq1x/NeCHzfE1KYS/+s5ilENlPKlNSyzF9YT723xU9a/WGUxs+xR xVaTbDJ5eNuyU8swjUk8dWGU8brR7vowWc+RogkuNTixA928+kQD9ncl/ UsQLUbL9U0SRfLojmEeWcUwkL0UMz8byQB2N8BbPIYzgd6peO+fu8tIip E=; Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=verizon.com; i=@verizon.com; q=dns/txt; s=corp; t=1506301976; x=1537837976; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=IkppM5KGPB3dKY7NbueVXBF6F7VaznLDRhfmbbJrph0=; b=hIgOblsCkGm/h9ML+nyDuVi2P07FvVCqoQjczFQ/Y1nGmL6BriUGoOcI 3fhNKGHZQ5mrfpNAVVa2wo0e9UEAhN+EqvToOopd+ZEiaWnfpr5KdwC8A rrCEQ1aNreNgHTvp3CFp7Y+3qJt82PUkzmpAL7q/hBlZQKZEGdCvyUhwY o=; X-Host: viking.odc.vzwcorp.com Thread-Topic: [PATCH review for 4.9 24/50] slub: do not merge cache if slub_debug contains a never-merge flag Thread-Index: AQHTNZtoQznzw+qcnU+3+WJhSfizlA== Accept-Language: en-US Content-Language: en-US X-Ms-Exchange-Messagesentrepresentingtype: 1 X-Ms-Exchange-Transport-Fromentityheader: Hosted X-Originating-IP: [10.144.60.250] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 56 Organization: linux.* mail to news gateway X-Original-Cc: Grygorii Maistrenko , Joonsoo Kim , Andrew Morton , "Linus Torvalds" , "Levin, Alexander (Sasha Levin)" X-Original-Date: Mon, 25 Sep 2017 01:12:50 +0000 X-Original-Message-ID: <20170925011225.10029-24-alexander.levin@verizon.com> X-Original-References: <20170925011225.10029-1-alexander.levin@verizon.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1738706 From: Grygorii Maistrenko [ Upstream commit c6e28895a4372992961888ffaadc9efc643b5bfe ] In case CONFIG_SLUB_DEBUG_ON=3Dn, find_mergeable() gets debug features from commandline but never checks if there are features from the SLAB_NEVER_MERGE set. As a result selected by slub_debug caches are always mergeable if they have been created without a custom constructor set or without one of the SLAB_* debug features on. This moves the SLAB_NEVER_MERGE check below the flags update from commandline to make sure it won't merge the slab cache if one of the debug features is on. Link: http://lkml.kernel.org/r/20170101124451.GA4740@lp-laptop-d Signed-off-by: Grygorii Maistrenko Reviewed-by: Pekka Enberg Acked-by: David Rientjes Acked-by: Christoph Lameter Cc: Joonsoo Kim Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/slab_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/slab_common.c b/mm/slab_common.c index 5d2f24fbafc5..622f6b6ae844 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c @@ -255,7 +255,7 @@ struct kmem_cache *find_mergeable(size_t size, size_t a= lign, { struct kmem_cache *s; =20 - if (slab_nomerge || (flags & SLAB_NEVER_MERGE)) + if (slab_nomerge) return NULL; =20 if (ctor) @@ -266,6 +266,9 @@ struct kmem_cache *find_mergeable(size_t size, size_t a= lign, size =3D ALIGN(size, align); flags =3D kmem_cache_flags(size, flags, name, NULL); =20 + if (flags & SLAB_NEVER_MERGE) + return NULL; + list_for_each_entry_reverse(s, &slab_caches, list) { if (slab_unmergeable(s)) continue; --=20 2.11.0