Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp979309rwb; Tue, 29 Nov 2022 07:34:15 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Kbajde1bODDMcGiWZ2RZHpKG4PnuPF+HxN3K/QNcgVLFlZfadn8Cr8ldawx1s+xWyhteB X-Received: by 2002:a17:903:1206:b0:186:a2ef:7a74 with SMTP id l6-20020a170903120600b00186a2ef7a74mr41423997plh.148.1669736055672; Tue, 29 Nov 2022 07:34:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669736055; cv=none; d=google.com; s=arc-20160816; b=yuEhWfvGJ8A/gkT7Lyr31ENyj0uwxqqX9LrICmoviYYnV6j4c6SM+VLMj2VF7kBvJO 8ubT0ePOlZCwVQHWK8dCP+s25K4fIR8zH55xjhwJWyAamiSJ+nQxkFk0D9hHYql9G+ig 3gBTDDDb/77N+5n3XgtqMczdcrhC7lb8u4KmjQ8jkPOfyhwgdQTgTLM9xI6J+nW+gU72 Gu43pXt4G3uJDlsLKw0CuKa3vfa2S99+shEuhkTWQr214c25s3wlXO4y+jAP2KFFne1I WG6ZgOOSw4LQQfIkeYe2XZk/KDsJsy3kQhrXrSt9fMqLRdF0cajlcy2MixacWEh8V2kv xCKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tS8n/Ck67Q8F8PZhxNkkUKyllJ628oDKaZcfi2EFgb8=; b=f8EQUFmfNBHSgz+v3lS6qawt/w/KMGzFYytLlriSMDRfGnlpVsgFxVeWrvc3UbpDh7 fZQ8PIkIPhiOfGNh4JkDQZETCmBpY8Ez7z16N7GWXRjMI1h7teBtupepDsMHPz94lWe2 JMIfyevFy56/T602xTkm+wTwAjFqxEGpAm3UaGJalfgfZNCYBJpmEu4mnQF2LgK0VYxl hHbFgf27Rn2wDmsaDCN0Utv+JoOjeObnX2Mz4Qkn7buV9Rz1ntIsahoO8Uaf2cFCUQOh zoCz0AmwrMNiJzUuaqemsGRbs2+DHc4Z8wmG7VTiU2BJq+R6pxdwL8BGitwwjzWQUPN7 T/YQ== 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 e20-20020a170902e0d400b001895608367csi13983105pla.535.2022.11.29.07.34.01; Tue, 29 Nov 2022 07:34:15 -0800 (PST) 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 S235352AbiK2PSJ (ORCPT + 84 others); Tue, 29 Nov 2022 10:18:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235301AbiK2PRx (ORCPT ); Tue, 29 Nov 2022 10:17:53 -0500 Received: from outbound-smtp03.blacknight.com (outbound-smtp03.blacknight.com [81.17.249.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD5171F629 for ; Tue, 29 Nov 2022 07:17:46 -0800 (PST) Received: from mail.blacknight.com (pemlinmail02.blacknight.ie [81.17.254.11]) by outbound-smtp03.blacknight.com (Postfix) with ESMTPS id BECE4C0C21 for ; Tue, 29 Nov 2022 15:17:44 +0000 (GMT) Received: (qmail 4822 invoked from network); 29 Nov 2022 15:17:44 -0000 Received: from unknown (HELO morpheus.112glenside.lan) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPA; 29 Nov 2022 15:17:44 -0000 From: Mel Gorman To: Linux-MM Cc: Andrew Morton , Michal Hocko , NeilBrown , Thierry Reding , Matthew Wilcox , Vlastimil Babka , LKML , Mel Gorman Subject: [PATCH 3/6] mm/page_alloc: Explicitly record high-order atomic allocations in alloc_flags Date: Tue, 29 Nov 2022 15:16:58 +0000 Message-Id: <20221129151701.23261-4-mgorman@techsingularity.net> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221129151701.23261-1-mgorman@techsingularity.net> References: <20221129151701.23261-1-mgorman@techsingularity.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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 A high-order ALLOC_HARDER allocation is assumed to be atomic. While that is accurate, it changes later in the series. In preparation, explicitly record high-order atomic allocations in gfp_to_alloc_flags(). Signed-off-by: Mel Gorman --- mm/internal.h | 1 + mm/page_alloc.c | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index d503e57a57a1..9a9d9b5ee87f 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -754,6 +754,7 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone, #else #define ALLOC_NOFRAGMENT 0x0 #endif +#define ALLOC_HIGHATOMIC 0x200 /* Allows access to MIGRATE_HIGHATOMIC */ #define ALLOC_KSWAPD 0x800 /* allow waking of kswapd, __GFP_KSWAPD_RECLAIM set */ enum ttu_flags; diff --git a/mm/page_alloc.c b/mm/page_alloc.c index da746e9eb2cf..e2b65767dda0 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3710,7 +3710,7 @@ struct page *rmqueue_buddy(struct zone *preferred_zone, struct zone *zone, * reserved for high-order atomic allocation, so order-0 * request should skip it. */ - if (order > 0 && alloc_flags & ALLOC_HARDER) + if (alloc_flags & ALLOC_HIGHATOMIC) page = __rmqueue_smallest(zone, order, MIGRATE_HIGHATOMIC); if (!page) { page = __rmqueue(zone, order, migratetype, alloc_flags); @@ -4028,8 +4028,10 @@ bool __zone_watermark_ok(struct zone *z, unsigned int order, unsigned long mark, return true; } #endif - if (alloc_harder && !free_area_empty(area, MIGRATE_HIGHATOMIC)) + if ((alloc_flags & ALLOC_HIGHATOMIC) && + !free_area_empty(area, MIGRATE_HIGHATOMIC)) { return true; + } } return false; } @@ -4291,7 +4293,7 @@ get_page_from_freelist(gfp_t gfp_mask, unsigned int order, int alloc_flags, * If this is a high-order atomic allocation then check * if the pageblock should be reserved for the future */ - if (unlikely(order && (alloc_flags & ALLOC_HARDER))) + if (unlikely(alloc_flags & ALLOC_HIGHATOMIC)) reserve_highatomic_pageblock(page, zone, order); return page; @@ -4818,7 +4820,7 @@ static void wake_all_kswapds(unsigned int order, gfp_t gfp_mask, } static inline unsigned int -gfp_to_alloc_flags(gfp_t gfp_mask) +gfp_to_alloc_flags(gfp_t gfp_mask, unsigned int order) { unsigned int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET; @@ -4844,8 +4846,13 @@ gfp_to_alloc_flags(gfp_t gfp_mask) * Not worth trying to allocate harder for __GFP_NOMEMALLOC even * if it can't schedule. */ - if (!(gfp_mask & __GFP_NOMEMALLOC)) + if (!(gfp_mask & __GFP_NOMEMALLOC)) { alloc_flags |= ALLOC_HARDER; + + if (order > 0) + alloc_flags |= ALLOC_HIGHATOMIC; + } + /* * Ignore cpuset mems for GFP_ATOMIC rather than fail, see the * comment for __cpuset_node_allowed(). @@ -5053,7 +5060,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order, * kswapd needs to be woken up, and to avoid the cost of setting up * alloc_flags precisely. So we do that now. */ - alloc_flags = gfp_to_alloc_flags(gfp_mask); + alloc_flags = gfp_to_alloc_flags(gfp_mask, order); /* * We need to recalculate the starting point for the zonelist iterator -- 2.35.3