From patchwork Mon Dec 2 12:58:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13895600 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 A7609E7716D for ; Thu, 5 Dec 2024 15:35:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA0A36B0137; Thu, 5 Dec 2024 10:19:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4E15E6B0104; Thu, 5 Dec 2024 10:19:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E57096B00F6; Thu, 5 Dec 2024 10:19:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 083086B0082 for ; Mon, 2 Dec 2024 07:58:56 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id BF8F481C0A for ; Mon, 2 Dec 2024 12:58:55 +0000 (UTC) X-FDA: 82850023284.03.0553A12 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 206DE140022 for ; Mon, 2 Dec 2024 12:58:45 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Qxv5fvlg; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733144328; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=8HP8ABYEm75mn1BmFryMatwFYZ4LLrOWgOCnAtcF7Tc=; b=2IffUZpNiSVGZ5VF87aLw8wOSaY1qgOXorWoVumFn+SmN1NdP+dCufDOMtMdhC80t298Fh pJ1oPa+/4Lvu91RSEMxNp7nfYPjSFaEudt8o3U1rmz/bqa7nUJwrwX9//pUQlxf/KVtniQ E9y9RVC1jMuKIfvfBCOErht1jk3y0dI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733144328; a=rsa-sha256; cv=none; b=DKHcblfH25ETJtpDKOfiFtZLO4EGUCCGu9A+6cmVhiElNCNXk9nZtsUC0q+VYMKVtPQaqu 8qM9Wva0C3WSoFrEu2hzeo3SLEcvJavrM4RhtuAJNziMZWj/gnBwTHh6p1hvpJHYd/6pKX eTNUUN35G4yGtIaOwC6h03TeUBzJdO8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Qxv5fvlg; spf=pass (imf23.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733144333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8HP8ABYEm75mn1BmFryMatwFYZ4LLrOWgOCnAtcF7Tc=; b=Qxv5fvlgSnHZxRCnhcmBQ1W4Nt5cffErITVKKJAZTiUmziPFJoNK8q9huehXfKdQ9z0+aR VrP9LMIyfMWSYIMG3609GIejWTW7+osCXKuFnsYNTVdH33wLCW4xJHjpASSaQWo/peH56Q 3Y4TJ2Oi4/YpLbH3frBAPDv2jE70B90= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-542-2zDHXoRjPpyrImBN_4zy5g-1; Mon, 02 Dec 2024 07:58:47 -0500 X-MC-Unique: 2zDHXoRjPpyrImBN_4zy5g-1 X-Mimecast-MFC-AGG-ID: 2zDHXoRjPpyrImBN_4zy5g Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3121D1964CCE; Mon, 2 Dec 2024 12:58:45 +0000 (UTC) Received: from t14s.cit.tum.de (unknown [10.39.194.150]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EFAD6195605A; Mon, 2 Dec 2024 12:58:40 +0000 (UTC) From: David Hildenbrand To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, David Hildenbrand , Andrew Morton , Oscar Salvador , Zi Yan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Naveen N Rao , Madhavan Srinivasan Subject: [PATCH v1 5/6] mm/page_alloc: forward the gfp flags from alloc_contig_range() to post_alloc_hook() Date: Mon, 2 Dec 2024 13:58:11 +0100 Message-ID: <20241202125812.561028-6-david@redhat.com> In-Reply-To: <20241202125812.561028-1-david@redhat.com> References: <20241202125812.561028-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X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LalEBeIZotQtk8G zKZv0LPv CkZKW/W/kf1t3gNgtW0Y7AG/WvVhK8T9NeldhZRnUOAEjyApuButZONi4eTFHTu5DCq6IbRJaCKnD/pFDW7zXiRbpGOX9Rz/zag2MbHnnNJmMKyAWQDU9VgFoAD330xLykQ4OLHbUygs3tE4iVSNHPx3uMdJwi3nLQBLXalGmUlbmdIEAdHSJmgN68nsy0//ji4BJ3+ZcL+pB/o9MS9FZdOEN4oi7chcSPUzfz30Fe5RA0TWtE8m1t0mV8nTtLA71Wsib5jX5bjH1WZlPF14cLchAIoS3Niqhoq9uHOBW+3uiVbg97fJMuLRBdNL1cWzieyGhA3bghlMYuHe9tsRWZU0UP1qSYY687oU+iQ+UNrsa/YuPD4qjXYfigp6Ug30u3vfKgEb7CBGbyRxL5UgMx3HznA== 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: List-Subscribe: List-Unsubscribe: In the __GFP_CONT case, we already pass the gfp_flags to prep_new_page()->post_alloc_hook(). However, in the !__GFP_CONT case, we essentially pass only hardcoded __GFP_MOVABLE to post_alloc_hook(), preventing some action modifiers from being effective.. Let's pass our now properly adjusted gfp flags there as well. This way, we can now support __GFP_ZERO for alloc_contig_*(). As a side effect, we now also support __GFP_SKIP_ZERO and__GFP_ZEROTAGS; but we'll keep the more special stuff (KASAN, NOLOCKDEP) disabled for now. It's worth nothing that with __GFP_ZERO, we might unnecessarily zero pages when we have to release part of our range using free_contig_range() again. This can be optimized in the future, if ever required; the caller we'll be converting (powernv/memtrace) next won't trigger this. Signed-off-by: David Hildenbrand --- mm/page_alloc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 54594cc4f650..71d70bc0ad79 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -6364,7 +6364,7 @@ static int __alloc_contig_migrate_range(struct compact_control *cc, return (ret < 0) ? ret : 0; } -static void split_free_pages(struct list_head *list) +static void split_free_pages(struct list_head *list, gfp_t gfp_mask) { int order; @@ -6375,7 +6375,7 @@ static void split_free_pages(struct list_head *list) list_for_each_entry_safe(page, next, &list[order], lru) { int i; - post_alloc_hook(page, order, __GFP_MOVABLE); + post_alloc_hook(page, order, gfp_mask); set_page_refcounted(page); if (!order) continue; @@ -6393,7 +6393,8 @@ static void split_free_pages(struct list_head *list) static int __alloc_contig_verify_gfp_mask(gfp_t gfp_mask, gfp_t *gfp_cc_mask) { const gfp_t reclaim_mask = __GFP_IO | __GFP_FS | __GFP_RECLAIM; - const gfp_t action_mask = __GFP_COMP | __GFP_RETRY_MAYFAIL | __GFP_NOWARN; + const gfp_t action_mask = __GFP_COMP | __GFP_RETRY_MAYFAIL | __GFP_NOWARN | + __GFP_ZERO | __GFP_ZEROTAGS | __GFP_SKIP_ZERO; const gfp_t cc_action_mask = __GFP_RETRY_MAYFAIL | __GFP_NOWARN; /* @@ -6541,7 +6542,7 @@ int alloc_contig_range_noprof(unsigned long start, unsigned long end, } if (!(gfp_mask & __GFP_COMP)) { - split_free_pages(cc.freepages); + split_free_pages(cc.freepages, gfp_mask); /* Free head and tail (if any) */ if (start != outer_start)