Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp570016pxb; Wed, 24 Feb 2021 09:12:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJyH3FhnJyxxeZlA7phTYZX0QRMkJGkz7m6EWpqNFalmS/RrcyKqiZqKEPKVFFE6xTD8kGto X-Received: by 2002:aa7:d416:: with SMTP id z22mr2653701edq.239.1614186755193; Wed, 24 Feb 2021 09:12:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614186755; cv=none; d=google.com; s=arc-20160816; b=tFLTBekcj/bUBCLClo7CotWQDZjCsX8oEvjgMQ1sE+6uCAf0y6bjAnuExVqxcN2yRF gSRNZIzRoGTaYzkPYrprDfqOrMhs3ugKGMRKquMxgfFzao595MlrXpPiR8sPhmiTOWWG vCnntpjjBo93OsTawrEIseMnKWhE4TzIFAd7wkJvxos86CGA3GMjE3WwuJnA0Z3+qH+Y 7+zXTRHzuZldTMk+qSdRSJY61GIVojDJd6PZlF7HxAbLO0+M1YIChk/Tb28lHHG/46oe iW4VRDZLgNuJyzsgkwYP8Et5J1kmZmYhmnLCyskQZ0hReJtohbFc8O0MN6Ek/jjX5c1v OpHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=GIfdxGgdYU4U/p47IPktt9mfm6AHWi/6xy6Sm4IHG5M=; b=y+EjJl/kU1U43o4VUvpcOQLV1WXQbDwHOhk6o6Ryjh6x+Ohb5wMeMpWSYoVxOc7HUz RBwoas1yK4WQR9gbuxTIW/lPZQlyrPPqMY0h8maPosvpTI2FHYan4IJjw83d//QtYDAf a/3Ms9eVCwcaTOoz/EpsxWTWFEoFB8+lImglR9zv5AamPLanYnGayBFtLjZDYEp/6KOS ef62frUGV7FuPyEYrnI4YNLP1vjeXu/TueCnXitV2WSx5vbCyHV+1kJnBKAuQ/d+aHWF SNdXL3n0tzPqnsIYWv2K7zLQcolhj0moe4J5+duP03XVz+hfw6zqxDG+3dhwydAfjW0l qPEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qn10si1563206ejb.682.2021.02.24.09.12.05; Wed, 24 Feb 2021 09:12:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232408AbhBXRLG (ORCPT + 99 others); Wed, 24 Feb 2021 12:11:06 -0500 Received: from shelob.surriel.com ([96.67.55.147]:50078 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231439AbhBXRLF (ORCPT ); Wed, 24 Feb 2021 12:11:05 -0500 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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: riel@shelob.surriel.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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,