From patchwork Wed Mar 21 20:09:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christoph Lameter (Ampere)" X-Patchwork-Id: 10300327 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CB3B9602B3 for ; Wed, 21 Mar 2018 20:10:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B1EE829924 for ; Wed, 21 Mar 2018 20:10:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B08F62996C; Wed, 21 Mar 2018 20:10:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9D4BD29957 for ; Wed, 21 Mar 2018 20:10:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B0ED51459; Wed, 21 Mar 2018 20:10:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B067960933; Wed, 21 Mar 2018 20:10:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F021A181BA00; Wed, 21 Mar 2018 20:10:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w2LKA8B3002462 for ; Wed, 21 Mar 2018 16:10:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id C310B8CA40; Wed, 21 Mar 2018 20:10:08 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9F78F749C9 for ; Wed, 21 Mar 2018 20:09:38 +0000 (UTC) Received: from resqmta-ch2-01v.sys.comcast.net (resqmta-ch2-01v.sys.comcast.net [69.252.207.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 89FDD7FEAC for ; Wed, 21 Mar 2018 20:09:37 +0000 (UTC) Received: from resomta-ch2-20v.sys.comcast.net ([69.252.207.116]) by resqmta-ch2-01v.sys.comcast.net with ESMTP id yk3EeogsV0Fiiyk3Ee8QUd; Wed, 21 Mar 2018 20:09:36 +0000 Received: from gentwo.org ([98.222.162.64]) by resomta-ch2-20v.sys.comcast.net with SMTP id yk3Deprjn1idiyk3EeCMHX; Wed, 21 Mar 2018 20:09:36 +0000 Received: by gentwo.org (Postfix, from userid 1001) id CD5C21160307; Wed, 21 Mar 2018 15:09:35 -0500 (CDT) Received: from localhost (localhost [127.0.0.1]) by gentwo.org (Postfix) with ESMTP id CADE71160261; Wed, 21 Mar 2018 15:09:35 -0500 (CDT) Date: Wed, 21 Mar 2018 15:09:35 -0500 (CDT) From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Mikulas Patocka In-Reply-To: Message-ID: References: <20180320173512.GA19669@bombadil.infradead.org> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-CMAE-Envelope: MS4wfJkTWMa2jHVoaRqJW6G2CrAU5qfjMw50FyS7nzsdNMvBgXzJwnwG/Gx15w9mudoYtYuv1J6oj6JlrDAP6LpPEJJnYX1Ihc+iiV0Nhk+unCWkn2GuAjYD dBK1+2oKJxIR0pDofFkp/eHWffPulBgy2Bl+jA1AeVrLtLLIyOu3z9tT0nrsvQ3S6SsjLbp8Lk+cZtVkxDKEO7OWbnECtGjmrYqv59GHHZIHSmgf/ArGRCbf jGJHD9voV5ZUBSN2xkS2TRCa5DdCeLSslZBNHdNkzebp9xiEn6dgNFTNyRFhv3yYDUxIwEA7YHojWTXk7ihy0eRWjT017XJweDQ/ho+jj/BG76JBxj3qggSR gLUHskD2oRddDPjLzXIDnW4PQJpLE+mvNvxPKTwD5Zd5tGjejZO44kF7xzM2h3Y0NukIo2Ai X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 21 Mar 2018 20:09:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 21 Mar 2018 20:09:37 +0000 (UTC) for IP:'69.252.207.33' DOMAIN:'resqmta-ch2-01v.sys.comcast.net' HELO:'resqmta-ch2-01v.sys.comcast.net' FROM:'cl@linux.com' RCPT:'' X-RedHat-Spam-Score: -0.012 (RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS) 69.252.207.33 resqmta-ch2-01v.sys.comcast.net 69.252.207.33 resqmta-ch2-01v.sys.comcast.net X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: Mike Snitzer , Matthew Wilcox , Pekka Enberg , linux-mm@kvack.org, dm-devel@redhat.com, David Rientjes , Joonsoo Kim , Andrew Morton Subject: Re: [dm-devel] [PATCH] slab: introduce the flag SLAB_MINIMIZE_WASTE X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 21 Mar 2018 20:10:12 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP On Wed, 21 Mar 2018, Mikulas Patocka wrote: > For example, if someone creates a slab cache with the flag SLAB_CACHE_DMA, > and he allocates an object from this cache and this allocation races with > the user writing to /sys/kernel/slab/cache/order - then the allocator can > for a small period of time see "s->allocflags == 0" and allocate a non-DMA > page. That is a bug. True we need to fix that: Subject: Avoid potentially visible allocflags without all flags set During slab size recalculation s->allocflags may be temporarily set to 0 and thus the flags may not be set which may result in the wrong flags being passed. Slab size calculation happens in two cases: 1. When a slab is created (which is safe since we cannot have concurrent allocations) 2. When the slab order is changed via /sysfs. Signed-off-by: Christoph Lameter --- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel Index: linux/mm/slub.c =================================================================== --- linux.orig/mm/slub.c +++ linux/mm/slub.c @@ -3457,6 +3457,7 @@ static void set_cpu_partial(struct kmem_ static int calculate_sizes(struct kmem_cache *s, int forced_order) { slab_flags_t flags = s->flags; + gfp_t allocflags; size_t size = s->object_size; int order; @@ -3551,16 +3552,17 @@ static int calculate_sizes(struct kmem_c if (order < 0) return 0; - s->allocflags = 0; + allocflags = 0; if (order) - s->allocflags |= __GFP_COMP; + allocflags |= __GFP_COMP; if (s->flags & SLAB_CACHE_DMA) - s->allocflags |= GFP_DMA; + allocflags |= GFP_DMA; if (s->flags & SLAB_RECLAIM_ACCOUNT) - s->allocflags |= __GFP_RECLAIMABLE; + allocflags |= __GFP_RECLAIMABLE; + s->allocflags = allocflags; /* * Determine the number of objects per slab */