From patchwork Wed Feb 24 17:10:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rik van Riel X-Patchwork-Id: 12102179 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02C29C433E0 for ; Wed, 24 Feb 2021 17:10:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6428E64ECF for ; Wed, 24 Feb 2021 17:10:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6428E64ECF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C77CE6B006C; Wed, 24 Feb 2021 12:10:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C27D56B0070; Wed, 24 Feb 2021 12:10:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3D456B0071; Wed, 24 Feb 2021 12:10:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0212.hostedemail.com [216.40.44.212]) by kanga.kvack.org (Postfix) with ESMTP id 9E5956B006C for ; Wed, 24 Feb 2021 12:10:31 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 61C71826478B for ; Wed, 24 Feb 2021 17:10:31 +0000 (UTC) X-FDA: 77853800262.27.DB9B3FD Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf24.hostedemail.com (Postfix) with ESMTP id B0684A000528 for ; Wed, 24 Feb 2021 17:10:19 +0000 (UTC) Received: from [2603:3005:d05:2b00:6e0b:84ff:fee2:98bb] (helo=imladris.surriel.com) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1lExg2-0000fq-F3; Wed, 24 Feb 2021 12:10:18 -0500 Date: Wed, 24 Feb 2021 12:10:16 -0500 From: Rik van Riel To: Hugh Dickins Cc: Vlastimil Babka , Andrew Morton , xuyu@linux.alibaba.com, mgorman@suse.de, aarcange@redhat.com, willy@infradead.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, linux-mm@kvack.org, mhocko@suse.com Subject: [PATCH 4/3] mm,shmem,thp: limit shmem THP allocations to requested zones Message-ID: <20210224121016.1314ed6d@imladris.surriel.com> In-Reply-To: References: <20201124194925.623931-1-riel@surriel.com> X-Mailer: Claws Mail 3.17.6 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B0684A000528 X-Stat-Signature: d1a63zgan7w6b7id36m5opx83xqh1psb Received-SPF: none (shelob.surriel.com>: No applicable sender policy available) receiver=imf24; identity=mailfrom; envelope-from=""; helo=shelob.surriel.com; client-ip=96.67.55.147 X-HE-DKIM-Result: none/none X-HE-Tag: 1614186619-888562 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, 24 Feb 2021 08:55:40 -0800 (PST) Hugh Dickins wrote: > On Wed, 24 Feb 2021, Rik van Riel wrote: > > On Wed, 2021-02-24 at 00:41 -0800, Hugh Dickins wrote: > > > Oh, I'd forgotten all about that gma500 aspect: > > > well, I can send a fixup later on. > > > > I already have code to fix that, which somebody earlier > > in this discussion convinced me to throw away. Want me > > to send it as a patch 4/3 ? > > If Andrew wants it all, yes, please do add that - thanks Rik. Trivial patch to fix the gma500 thing below: ---8<--- mm,shmem,thp: limit shmem THP allocations to requested zones Hugh pointed out that the gma500 driver uses shmem pages, but needs to limit them to the DMA32 zone. Ensure the allocations resulting from the gfp_mask returned by limit_gfp_mask use the zone flags that were originally passed to shmem_getpage_gfp. Signed-off-by: Rik van Riel Suggested-by: Hugh Dickins Acked-by: Vlastimil Babka --- mm/shmem.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/shmem.c b/mm/shmem.c index ee3cea10c2a4..876fec89686f 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1539,7 +1539,11 @@ static gfp_t limit_gfp_mask(gfp_t huge_gfp, gfp_t limit_gfp) { gfp_t allowflags = __GFP_IO | __GFP_FS | __GFP_RECLAIM; gfp_t denyflags = __GFP_NOWARN | __GFP_NORETRY; - gfp_t result = huge_gfp & ~allowflags; + gfp_t zoneflags = limit_gfp & GFP_ZONEMASK; + gfp_t result = huge_gfp & ~(allowflags | GFP_ZONEMASK); + + /* Allow allocations only from the originally specified zones. */ + result |= zoneflags; /* * Minimize the result gfp by taking the union with the deny flags,