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 974DAC38145 for ; Wed, 7 Sep 2022 09:47:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2D8706B0074; Wed, 7 Sep 2022 05:47:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 262606B0075; Wed, 7 Sep 2022 05:47:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 102A58D0002; Wed, 7 Sep 2022 05:47:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id EF3926B0074 for ; Wed, 7 Sep 2022 05:47:38 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C16581A10DD for ; Wed, 7 Sep 2022 09:47:38 +0000 (UTC) X-FDA: 79884812196.03.80C0E1B Received: from outbound-smtp41.blacknight.com (outbound-smtp41.blacknight.com [46.22.139.224]) by imf23.hostedemail.com (Postfix) with ESMTP id 9CECC140086 for ; Wed, 7 Sep 2022 09:47:37 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp41.blacknight.com (Postfix) with ESMTPS id 142012336 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: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662544058; 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: in-reply-to:in-reply-to:references:references; bh=qamNKlJYxBHYu49+LrVcC9bwTniScY2MRzQG37SIgWA=; b=jhzyIUMalX/sbImzpAaYejI8SNgSIg7qeE+zXPd/Wlhg3Po+pdVCkGjUldQWT9xXwvbrk4 TX8LXQa8HJMm/+vTo8dVvQsn3NhO2J69bluwk1TA8AJyfivU7NGk4N7VNjZKqP+rDcJVkN rCMPX2aWe0+Hhdh7saRBsKB8+Gkg1Xs= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.224 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662544058; a=rsa-sha256; cv=none; b=THuINFoyakJKLNGH8shiRUzb+9z216xBCdYPZ+B0qNEc7/LPrxG81Zc9YlIF6gwywX38mh DjIstu+zQakGYGtAy4+ugjeYNJMANbIHk90JrTU8SN0MNuDj9cePtmRfk55oRqJCcy3dMW F4TyUGpyY1dcigaPhxP4O7P3NDBCL7o= X-Rspam-User: Authentication-Results: imf23.hostedemail.com; dkim=none; spf=pass (imf23.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.139.224 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net; dmarc=none X-Rspamd-Server: rspam08 X-Stat-Signature: y9ok1w19gohy5wkesoz8zuijngqpm3r9 X-Rspamd-Queue-Id: 9CECC140086 X-HE-Tag: 1662544057-497616 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 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