From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E833C3DA7A for ; Thu, 5 Jan 2023 21:53:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E40388E0002; Thu, 5 Jan 2023 16:53:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DEFC28E0001; Thu, 5 Jan 2023 16:53:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C993F8E0002; Thu, 5 Jan 2023 16:53:56 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B3E8D8E0001 for ; Thu, 5 Jan 2023 16:53:56 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8468C1C652F for ; Thu, 5 Jan 2023 21:53:56 +0000 (UTC) X-FDA: 80322098472.09.7479C9A Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf29.hostedemail.com (Postfix) with ESMTP id B7BB6120005 for ; Thu, 5 Jan 2023 21:53:54 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=gXuiPn3e; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=nVz5m7Ag; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf29.hostedemail.com: domain of neilb@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=neilb@suse.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672955635; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dW8J8auodsvikhrjVTgqz8kfZPcO06WsqZRTH494sVo=; b=8r5gRU6O3DOo2wUJAQ/G9zq1z9cvj47h0C9af6ltcUgNlTGoeU+bOj2jbyQugz22IGwSSC ybf6cAi60Un2eJyI45aTAUK5MYi+uXo5aqLrzcRQw9USzyyFfaSy80kJtvTqv0ZlDjeUzx hN4/kjNxJgDQIEQUImrBKpge4+tz3oQ= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=gXuiPn3e; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=nVz5m7Ag; dmarc=pass (policy=none) header.from=suse.de; spf=pass (imf29.hostedemail.com: domain of neilb@suse.de designates 195.135.220.28 as permitted sender) smtp.mailfrom=neilb@suse.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672955635; a=rsa-sha256; cv=none; b=DF9wb1q1d/ZQDUYJP+XmeTvi3VqXkyF9bhN6Jn7rdNK3pG7rLladxKx+YH+madxRF/mmHw hpFeAEE0Ekq76S9TDseqFtAM9EuwZIx/p60vSLYa0L1ShLvAjM4EsSUFykGY+MwB1WKit7 zeWtp+rc0GHKAD1IxbZPUUpmim7Wbuw= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id A01EA6C20E; Thu, 5 Jan 2023 21:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1672955632; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dW8J8auodsvikhrjVTgqz8kfZPcO06WsqZRTH494sVo=; b=gXuiPn3ejr00pBNYsq20RYl2YoY5IMxoasZdLcGyQ57Ie12GiS1AWcG+xkFkLv4lB4vQNe Cc3mowotkpdhE1ehw5/Uxc6aiUO+O9A5mvT/divnuKQldLEidqpQ4zAPFPendoFXg3omWO 90CXyJL9G97VYLZfSSUNKoHoYDe9prk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1672955632; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dW8J8auodsvikhrjVTgqz8kfZPcO06WsqZRTH494sVo=; b=nVz5m7AgX+z93FKYhH1ylkYzqLGYZMR7nr5h8LgaY/PQniaZTNt9hvyvQfn5NcBwt2WwZ3 Hfu+nFy6QsbYWeAw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 69F8513338; Thu, 5 Jan 2023 21:53:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id bqsPCO1Gt2PcTwAAMHmgww (envelope-from ); Thu, 05 Jan 2023 21:53:49 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 From: "NeilBrown" To: "Mike Rapoport" Cc: "Mel Gorman" , "Linux-MM" , "Andrew Morton" , "Michal Hocko" , "Thierry Reding" , "Matthew Wilcox" , "Vlastimil Babka" , "LKML" Subject: Re: [PATCH 6/6] mm: discard __GFP_ATOMIC In-reply-to: References: <20221129151701.23261-1-mgorman@techsingularity.net>, <20221129151701.23261-7-mgorman@techsingularity.net>, Date: Fri, 06 Jan 2023 08:53:45 +1100 Message-id: <167295562534.13974.9600718707761592893@noble.neil.brown.name> X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B7BB6120005 X-Stat-Signature: ecurduphqpsjok489zw94ndyshxhn3f5 X-HE-Tag: 1672955634-568206 X-HE-Meta: U2FsdGVkX1/uBPZzSQ8gFFjpEiq1hwBrPCty/SAg9/fAYx+gHpHBg7eIevUcOdNe5+KprHKOi5y+KvRdqGa9ZaW7erK6UvjhKNUgHHDCH7kpLjOhDrPQta2D7o+PaIrE6MIgwRDlSUVLYFvzgBJ3/mfd/BSGX8MvoOeglahuPUbsD21ngFkpdU6zbORL7hnmd3WJIKlabIXSmkEZ7H6ZX3EKn9cap2d4noGHt4xa97pKHiXeGWrh3YUMFg+rsK2ibGtFfCssiHjQlpKk2GHgu0jnatgKNoTimVG3gwq7J7UJ2tyd45DOPh4qKHg2ihqNnFpNCMuyqVSPYwdUl+vXP1sPInsKqtjIdf03sEjRR8GKhRT/jiZUemasQcc+VxNsT7h9Dvv2bL+DzbQ/Fwwf5aDxtGLQ2/EeeuevexpeO4UCBPmvpGRXDMK+zuGMKSC1H8awaqwa1me0asHsjf3qeHyAmQ/NYfUsNydBMthwzLdd4tFky4ZvVm1ePyuuyrUHWhuFmyP98kZFuLIydmfhgPvX6AxiTJcHpmCUazjrg+OCfc9KUUZEHbQT7/a0XmgVCQu0TpTNZDXf/WDZSow0t122a02VaLIt6b7OmgcfnOLjN/AjbOee2xIt9kTzashgcosZPLBpU0j253PfZ003PKUH+Ywta5MZbSI91J/ZZfTRFajsN+URPXCAisloX+EYYQCHVwhFL7nAaYEy6TZ4cJxgs3fnl+s+VLcp2rSRxPmPuFS5kGq2K7WktqdYpDa565SJFdLSYVxpaHlpAfaGk8XSeZxCL1gAK1svLdbCdsfyi4n7mqCUfB058hNNjqE30cbE7jpVmTiPYhxXyXeQ9fRcqR+Wy16gEqxKpl2IW1IscuFK2TJfUXwQhbmHNudPKQIEqL+o9F1tTAMYYDY+zjHcpeN/+SZHSbB8GDybWrCAGgbd0sID5l4mjrEWiJlSmYbiz35Aqjclza9jMw+ V5NydsS8 3X9pECUNKDcjX/un4MvSnXagQSv+0OFcoAgKg 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 Fri, 06 Jan 2023, Mike Rapoport wrote: > Hi Mel, >=20 > On Tue, Nov 29, 2022 at 03:17:01PM +0000, Mel Gorman wrote: > > From: NeilBrown > >=20 > > __GFP_ATOMIC serves little purpose. Its main effect is to set > > ALLOC_HARDER which adds a few little boosts to increase the chance of an > > allocation succeeding, one of which is to lower the water-mark at which it > > will succeed. > >=20 > > It is *always* paired with __GFP_HIGH which sets ALLOC_HIGH which also > > adjusts this watermark. It is probable that other users of __GFP_HIGH > > should benefit from the other little bonuses that __GFP_ATOMIC gets. > >=20 > > __GFP_ATOMIC also gives a warning if used with __GFP_DIRECT_RECLAIM. > > There is little point to this. We already get a might_sleep() warning if > > __GFP_DIRECT_RECLAIM is set. > >=20 > > __GFP_ATOMIC allows the "watermark_boost" to be side-stepped. It is > > probable that testing ALLOC_HARDER is a better fit here. > >=20 > > __GFP_ATOMIC is used by tegra-smmu.c to check if the allocation might > > sleep. This should test __GFP_DIRECT_RECLAIM instead. > >=20 > > This patch: > > - removes __GFP_ATOMIC > > - allows __GFP_HIGH allocations to ignore watermark boosting as well > > as GFP_ATOMIC requests. > > - makes other adjustments as suggested by the above. > >=20 > > The net result is not change to GFP_ATOMIC allocations. Other > > allocations that use __GFP_HIGH will benefit from a few different extra > > privileges. This affects: > > xen, dm, md, ntfs3 > > the vermillion frame buffer > > hibernation > > ksm > > swap > > all of which likely produce more benefit than cost if these selected > > allocation are more likely to succeed quickly. > >=20 > > [mgorman: Minor adjustments to rework on top of a series] > > Link: https://lkml.kernel.org/r/163712397076.13692.4727608274002939094@no= ble.neil.brown.name > > Signed-off-by: NeilBrown > > Signed-off-by: Mel Gorman > > --- > > Documentation/mm/balance.rst | 2 +- >=20 > Documentation/core-api/memory-allocation.rst needs an update as well, and > there are other mentions of GFP_ATOMIC in Documentation/ Note that this patch removes __GFP_ATOMIC, but does not change the behaviour of GFP_ATOMIC. So I don't believe there is any other documentation that need changing. Thanks, NeilBrown >=20 > > drivers/iommu/tegra-smmu.c | 4 ++-- > > include/linux/gfp_types.h | 12 ++++-------- > > include/trace/events/mmflags.h | 1 - > > lib/test_printf.c | 8 ++++---- > > mm/internal.h | 2 +- > > mm/page_alloc.c | 13 +++---------- > > tools/perf/builtin-kmem.c | 1 - > > 8 files changed, 15 insertions(+), 28 deletions(-) > >=20 > > diff --git a/Documentation/mm/balance.rst b/Documentation/mm/balance.rst > > index 6a1fadf3e173..e38e9d83c1c7 100644 > > --- a/Documentation/mm/balance.rst > > +++ b/Documentation/mm/balance.rst > > @@ -6,7 +6,7 @@ Memory Balancing > > =20 > > Started Jan 2000 by Kanoj Sarcar > > =20 > > -Memory balancing is needed for !__GFP_ATOMIC and !__GFP_KSWAPD_RECLAIM as > > +Memory balancing is needed for !__GFP_HIGH and !__GFP_KSWAPD_RECLAIM as > > well as for non __GFP_IO allocations. > > =20 > > The first reason why a caller may avoid reclaim is that the caller can n= ot > > diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c > > index 5b1af40221ec..af8d0e685260 100644 > > --- a/drivers/iommu/tegra-smmu.c > > +++ b/drivers/iommu/tegra-smmu.c > > @@ -671,12 +671,12 @@ static struct page *as_get_pde_page(struct tegra_sm= mu_as *as, > > * allocate page in a sleeping context if GFP flags permit. Hence > > * spinlock needs to be unlocked and re-locked after allocation. > > */ > > - if (!(gfp & __GFP_ATOMIC)) > > + if (gfpflags_allow_blocking(gfp)) > > spin_unlock_irqrestore(&as->lock, *flags); > > =20 > > page =3D alloc_page(gfp | __GFP_DMA | __GFP_ZERO); > > =20 > > - if (!(gfp & __GFP_ATOMIC)) > > + if (gfpflags_allow_blocking(gfp)) > > spin_lock_irqsave(&as->lock, *flags); > > =20 > > /* > > diff --git a/include/linux/gfp_types.h b/include/linux/gfp_types.h > > index d88c46ca82e1..5088637fe5c2 100644 > > --- a/include/linux/gfp_types.h > > +++ b/include/linux/gfp_types.h > > @@ -31,7 +31,7 @@ typedef unsigned int __bitwise gfp_t; > > #define ___GFP_IO 0x40u > > #define ___GFP_FS 0x80u > > #define ___GFP_ZERO 0x100u > > -#define ___GFP_ATOMIC 0x200u > > +/* 0x200u unused */ > > #define ___GFP_DIRECT_RECLAIM 0x400u > > #define ___GFP_KSWAPD_RECLAIM 0x800u > > #define ___GFP_WRITE 0x1000u > > @@ -116,11 +116,8 @@ typedef unsigned int __bitwise gfp_t; > > * > > * %__GFP_HIGH indicates that the caller is high-priority and that grant= ing > > * the request is necessary before the system can make forward progress. > > - * For example, creating an IO context to clean pages. > > - * > > - * %__GFP_ATOMIC indicates that the caller cannot reclaim or sleep and is > > - * high priority. Users are typically interrupt handlers. This may be > > - * used in conjunction with %__GFP_HIGH > > + * For example creating an IO context to clean pages and requests > > + * from atomic context. > > * > > * %__GFP_MEMALLOC allows access to all memory. This should only be used= when > > * the caller guarantees the allocation will allow more memory to be fre= ed > > @@ -135,7 +132,6 @@ typedef unsigned int __bitwise gfp_t; > > * %__GFP_NOMEMALLOC is used to explicitly forbid access to emergency re= serves. > > * This takes precedence over the %__GFP_MEMALLOC flag if both are set. > > */ > > -#define __GFP_ATOMIC ((__force gfp_t)___GFP_ATOMIC) > > #define __GFP_HIGH ((__force gfp_t)___GFP_HIGH) > > #define __GFP_MEMALLOC ((__force gfp_t)___GFP_MEMALLOC) > > #define __GFP_NOMEMALLOC ((__force gfp_t)___GFP_NOMEMALLOC) > > @@ -329,7 +325,7 @@ typedef unsigned int __bitwise gfp_t; > > * version does not attempt reclaim/compaction at all and is by default = used > > * in page fault path, while the non-light is used by khugepaged. > > */ > > -#define GFP_ATOMIC (__GFP_HIGH|__GFP_ATOMIC|__GFP_KSWAPD_RECLAIM) > > +#define GFP_ATOMIC (__GFP_HIGH|__GFP_KSWAPD_RECLAIM) > > #define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS) > > #define GFP_KERNEL_ACCOUNT (GFP_KERNEL | __GFP_ACCOUNT) > > #define GFP_NOWAIT (__GFP_KSWAPD_RECLAIM) > > diff --git a/include/trace/events/mmflags.h b/include/trace/events/mmflag= s.h > > index e87cb2b80ed3..11524cda4a95 100644 > > --- a/include/trace/events/mmflags.h > > +++ b/include/trace/events/mmflags.h > > @@ -31,7 +31,6 @@ > > gfpflag_string(__GFP_HIGHMEM), \ > > gfpflag_string(GFP_DMA32), \ > > gfpflag_string(__GFP_HIGH), \ > > - gfpflag_string(__GFP_ATOMIC), \ > > gfpflag_string(__GFP_IO), \ > > gfpflag_string(__GFP_FS), \ > > gfpflag_string(__GFP_NOWARN), \ > > diff --git a/lib/test_printf.c b/lib/test_printf.c > > index 4bd15a593fbd..fe13de1bed5f 100644 > > --- a/lib/test_printf.c > > +++ b/lib/test_printf.c > > @@ -686,17 +686,17 @@ flags(void) > > gfp =3D GFP_ATOMIC|__GFP_DMA; > > test("GFP_ATOMIC|GFP_DMA", "%pGg", &gfp); > > =20 > > - gfp =3D __GFP_ATOMIC; > > - test("__GFP_ATOMIC", "%pGg", &gfp); > > + gfp =3D __GFP_HIGH; > > + test("__GFP_HIGH", "%pGg", &gfp); > > =20 > > /* Any flags not translated by the table should remain numeric */ > > gfp =3D ~__GFP_BITS_MASK; > > snprintf(cmp_buffer, BUF_SIZE, "%#lx", (unsigned long) gfp); > > test(cmp_buffer, "%pGg", &gfp); > > =20 > > - snprintf(cmp_buffer, BUF_SIZE, "__GFP_ATOMIC|%#lx", > > + snprintf(cmp_buffer, BUF_SIZE, "__GFP_HIGH|%#lx", > > (unsigned long) gfp); > > - gfp |=3D __GFP_ATOMIC; > > + gfp |=3D __GFP_HIGH; > > test(cmp_buffer, "%pGg", &gfp); > > =20 > > kfree(cmp_buffer); > > diff --git a/mm/internal.h b/mm/internal.h > > index 98b1e526559d..48926b290cd5 100644 > > --- a/mm/internal.h > > +++ b/mm/internal.h > > @@ -24,7 +24,7 @@ struct folio_batch; > > #define GFP_RECLAIM_MASK (__GFP_RECLAIM|__GFP_HIGH|__GFP_IO|__GFP_FS|\ > > __GFP_NOWARN|__GFP_RETRY_MAYFAIL|__GFP_NOFAIL|\ > > __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC|\ > > - __GFP_ATOMIC|__GFP_NOLOCKDEP) > > + __GFP_NOLOCKDEP) > > =20 > > /* The GFP flags allowed during early boot */ > > #define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_RECLAIM|__GFP_IO|__GFP_= FS)) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > > index 6bee987ec9a3..ad6c4705a79d 100644 > > --- a/mm/page_alloc.c > > +++ b/mm/page_alloc.c > > @@ -4081,13 +4081,14 @@ static inline bool zone_watermark_fast(struct zon= e *z, unsigned int order, > > if (__zone_watermark_ok(z, order, mark, highest_zoneidx, alloc_flags, > > free_pages)) > > return true; > > + > > /* > > - * Ignore watermark boosting for GFP_ATOMIC order-0 allocations > > + * Ignore watermark boosting for GFP_HIGH order-0 allocations > > * when checking the min watermark. The min watermark is the > > * point where boosting is ignored so that kswapd is woken up > > * when below the low watermark. > > */ > > - if (unlikely(!order && (gfp_mask & __GFP_ATOMIC) && z->watermark_boost > > + if (unlikely(!order && (alloc_flags & ALLOC_MIN_RESERVE) && z->watermar= k_boost > > && ((alloc_flags & ALLOC_WMARK_MASK) =3D=3D WMARK_MIN))) { > > mark =3D z->_watermark[WMARK_MIN]; > > return __zone_watermark_ok(z, order, mark, highest_zoneidx, > > @@ -5052,14 +5053,6 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned in= t order, > > unsigned int zonelist_iter_cookie; > > int reserve_flags; > > =20 > > - /* > > - * We also sanity check to catch abuse of atomic reserves being used by > > - * callers that are not in atomic context. > > - */ > > - if (WARN_ON_ONCE((gfp_mask & (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM)) =3D=3D > > - (__GFP_ATOMIC|__GFP_DIRECT_RECLAIM))) > > - gfp_mask &=3D ~__GFP_ATOMIC; > > - > > restart: > > compaction_retries =3D 0; > > no_progress_loops =3D 0; > > diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c > > index ebfab2ca1702..4a06d83f2ac5 100644 > > --- a/tools/perf/builtin-kmem.c > > +++ b/tools/perf/builtin-kmem.c > > @@ -640,7 +640,6 @@ static const struct { > > { "__GFP_HIGHMEM", "HM" }, > > { "GFP_DMA32", "D32" }, > > { "__GFP_HIGH", "H" }, > > - { "__GFP_ATOMIC", "_A" }, > > { "__GFP_IO", "I" }, > > { "__GFP_FS", "F" }, > > { "__GFP_NOWARN", "NWR" }, > > --=20 > > 2.35.3 > >=20 > >=20 >=20 > --=20 > Sincerely yours, > Mike. >=20