Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5526250rwb; Wed, 7 Sep 2022 04:23:11 -0700 (PDT) X-Google-Smtp-Source: AA6agR7vqoKLsX+TcNh2uobZBe0Fa2zr48ZNNtOFG8J03IFguNjMutU1UhTeINxtXBTtKNS++KN6 X-Received: by 2002:a62:be0d:0:b0:535:df64:b106 with SMTP id l13-20020a62be0d000000b00535df64b106mr3342036pff.60.1662549791510; Wed, 07 Sep 2022 04:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662549791; cv=none; d=google.com; s=arc-20160816; b=VFUGegALPzym5IAoKDuAEJc7sCLAJz9QmsGTpHBZeq70q2Nt3UhlfOt+F5uCENhZ7s t4nzV4CY3DfZ1dEaNmX4TINRXdorbrap8NYH1nIyWGVHWU79/S8Z2ShabdcnKeELukxB 9KaVm6xSqCzyBJmYYBxlGBAWlHXZnsbkkhEttfb3hQEtDCxOTDb7hFIBdGUQzKT1lrC2 nWpqPcbHcSIRCjJeGNT3rxnpU5noSFianA2zKUCvZsguALuX1R9XF4tUI9lt56RDX4w4 zaNL5ZCg01T8AUdz0Q4R38FPpjaBoIS0C5O5ZBElTKAJ02kzeSFSh8xhfib93FCCtVBU unfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=qamNKlJYxBHYu49+LrVcC9bwTniScY2MRzQG37SIgWA=; b=i8L78JiEO5Ew1vADdAdFjG9yzXFvLAh00kXCGXAeIM5LvYKkobKlWXAz7H88cyBOJQ DYljcITH9hlqOJG9tnVDToGyAWnrOmGOhHmJwkblQHT5jz8iLEONYClvwmwGCbPk983b M251Ec98pGEw5MZ3xBvJpqneH6KqVcaQQskpboVkZ/0+DUMIRmkCXE/5s/m4BhtJPib9 NSayKw7cwX66gAPie6rSBrpezBBKd0rJYEE4rM6rZRYqfBjye9JiDg8IZZLzDAQ37B0u sLhBO+s0/3DKAwZjUlm1UQMGxJeopoIYdRpcsSUPi0ChSD06LYl4Ah3DjlSK83V2nNWi KYHw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y184-20020a638ac1000000b00434dd6f6e21si2652895pgd.125.2022.09.07.04.22.52; Wed, 07 Sep 2022 04:23:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229799AbiIGJri (ORCPT + 99 others); Wed, 7 Sep 2022 05:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229797AbiIGJrg (ORCPT ); Wed, 7 Sep 2022 05:47:36 -0400 Received: from outbound-smtp48.blacknight.com (outbound-smtp48.blacknight.com [46.22.136.219]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62EB09AFBA for ; Wed, 7 Sep 2022 02:47:35 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp48.blacknight.com (Postfix) with ESMTPS id 16F97FAF13 for ; Wed, 7 Sep 2022 10:47:34 +0100 (IST) Received: (qmail 25917 invoked from network); 7 Sep 2022 09:47:33 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 7 Sep 2022 09:47:33 -0000 Date: Wed, 7 Sep 2022 10:47:24 +0100 From: Mel Gorman To: Michal Hocko Cc: Andrew Morton , NeilBrown , Thierry Reding , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mel Gorman , Vlastimil Babka Subject: Re: [PATCH] MM: discard __GFP_ATOMIC Message-ID: <20220907094724.5lanecgcjg75vxv3@techsingularity.net> References: <163712397076.13692.4727608274002939094@noble.neil.brown.name> <163764199967.7248.2528204111227925210@noble.neil.brown.name> <20220430113028.9daeebeedf679aa384da5945@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 06, 2022 at 09:35:41AM +0200, Michal Hocko wrote: > > From: "NeilBrown" > > Subject: mm: discard __GFP_ATOMIC > > > > __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. > > > > 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. > > > > __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. > > > > __GFP_ATOMIC allows the "watermark_boost" to be side-stepped. It is > > probable that testing ALLOC_HARDER is a better fit here. > > > > __GFP_ATOMIC is used by tegra-smmu.c to check if the allocation might > > sleep. This should test __GFP_DIRECT_RECLAIM instead. > > > > This patch: > > - removes __GFP_ATOMIC > > - causes __GFP_HIGH to set ALLOC_HARDER unless __GFP_NOMEMALLOC is set > > (as well as ALLOC_HIGH). > > - makes other adjustments as suggested by the above. > > > > 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. > > This is a good summary of the current usage and existing issues. It also > shows that the naming is tricky and allows people to make wrong calls > (tegra-smmu.c). I also thing that it is wrong to couple memory reserves > access to the reclaim constrains/expectations of the caller. > I think it's worth trying to get rid of __GFP_ATOMIC although this patch needs to be rebased. Without rebasing it, I suspect there is a corner case for reserving high order atomic blocks. A high-order atomic allocation might get confused with a __GFP_HIGH high-order allocation that can sleep. It would not be completely irrational to have such a caller if it was in a path that can tolerate a stall but stalling might have visible consequences. I'm also worried that the patch might allow __GFP_HIGH to ignore cpusets which is probably not intended by direct users like ksm. > > Link: https://lkml.kernel.org/r/163712397076.13692.4727608274002939094@noble.neil.brown.name > > Signed-off-by: NeilBrown > > Reviewed-by: Matthew Wilcox (Oracle) > > Cc: Michal Hocko > > Cc: Thierry Reding > > Cc: Mel Gorman > > Signed-off-by: Andrew Morton > > Yes, I am all for dropping the gfp flag. One thing that is not really > entirely clear to me, though, is whether we still need 3 levels of > memory reserves access. Can we just drop ALLOC_HARDER? With this patch > applied it serves RT tasks and conflates it with __GFP_HIGH users > essentially. So why do we need that additional level of reserves? I think this would fall under the "naming is hard". If __GFP_ATOMIC was removed, the ALLOC_ flags might need renaming to detect differences in high priority allocations (RT + GFP_ATOMIC), critical allocations (OOM) and ones that can access special reserves (GFP_ATOMIC high-order). -- Mel Gorman SUSE Labs