From patchwork Tue Dec 3 08:37:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Hildenbrand X-Patchwork-Id: 13895594 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 A4007E7716C for ; Thu, 5 Dec 2024 15:34:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0097C6B0093; Thu, 5 Dec 2024 10:19:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 520266B00C4; Thu, 5 Dec 2024 10:19:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26EBC6B00EC; Thu, 5 Dec 2024 10:19:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id A62F86B007B for ; Tue, 3 Dec 2024 03:38:34 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5BEF61207B0 for ; Tue, 3 Dec 2024 08:38:34 +0000 (UTC) X-FDA: 82852996002.13.8073AEA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id D05DA14000D for ; Tue, 3 Dec 2024 08:38:23 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QHNhI4bo; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733215106; a=rsa-sha256; cv=none; b=DldEHeU0sfO/gmCMBy262G47qaBD3+EttUZbEl9oUcaXxwV/ogFxNgknkGe+he0AtOuTZ1 6ARY+/dUH0DDEOmg3OrpvZIdqVmTfQBtDFgzeRevlrZL91i99pnHTMu6lLaTXH1d2b75l3 p6UuR+K6kQsV88Abkfo30Ng28PBB6Fs= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QHNhI4bo; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf09.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733215106; 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=0fQppTuvH7gihnzA0jS0S7Nrs9VtQXSbfqTsq5GHr48=; b=fbMovOr8Q6pBG0AipmgZDCzafIijknAPUH1Z4ovtOhHgt33M9tOcZ8DkdZl8V1oNN4hy59 hBU5NL9xSLie0ODggkSh93RN5BSlhlrr6YTn+vLTrDYEiYOTlftT18aOixh6Yw9NKgj9ig qdpMMvcJGUXVz3gd0vW0RgHlJRObZxo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733215112; 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=0fQppTuvH7gihnzA0jS0S7Nrs9VtQXSbfqTsq5GHr48=; b=QHNhI4boIQwyN6GZD0X8tZtTZG21NiHOsYhDPqDQSoC2kdvvLok1ey9+5MlysHHfW1VzMV hJ1reyaelb1Zk5dZ78u0XGvFQiC+Tc+RIINLNTamf4pr9NvoWBfjGNbVtki5D1jqguZnfs 89GL4KrDrfHQnFjCwVjVKoXofSlIDjc= Received: from mx-prod-mc-04.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-649-KHX7Pf0UPF6xnbXl4YXWTA-1; Tue, 03 Dec 2024 03:38:30 -0500 X-MC-Unique: KHX7Pf0UPF6xnbXl4YXWTA-1 X-Mimecast-MFC-AGG-ID: KHX7Pf0UPF6xnbXl4YXWTA Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4588B19560BF; Tue, 3 Dec 2024 08:38:29 +0000 (UTC) Received: from t14s.fritz.box (unknown [10.22.88.109]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EAC8F30000DF; Tue, 3 Dec 2024 08:38:24 +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 v2 5/6] mm/page_alloc: forward the gfp flags from alloc_contig_range() to post_alloc_hook() Date: Tue, 3 Dec 2024 09:37:55 +0100 Message-ID: <20241203083756.112975-6-david@redhat.com> In-Reply-To: <20241203083756.112975-1-david@redhat.com> References: <20241203083756.112975-1-david@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X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om/KMx6l0F4zxrpghCt1CTc2Z6 q+azESlu Ef4h4fGwtljhX/Pkram7OTPhSvBIpT9vTCH0OFMPonwkO4lT3o+cZSKfZgYTG6XDDQ1zFnR80FY065Spt9uZq3QpzVrHA/xg0vXPIsoMIaTWKQJfsBDbrG01wt1yoKE1j+1vNv2OWRR0Pc04r47VY/UOd/krzVChqx0LAX2RucJ3l7Zy6Hs/1KVolm+FG+nlusPOSoXfIuvMcZfITtIrN7mXCSEdOclQTL4FTsfZQ4QBzXcsDOMKAWe5ZKowtQkDNwUUYa76jzyu7GxGoWPUk9IoH+z+vCa3NRS55ARp5vVmKP0HNGosCnqyav/3+ing51MYSc1oPNUJDIyJO4HatpThPDxwYtZJp7YylJ8CirrukbWgXq6GxraRIgF6W4pCiuLAr3VYSs1plm/iEgOazA/vZ+w== 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_COMP case, we already pass the gfp_flags to prep_new_page()->post_alloc_hook(). However, in the !__GFP_COMP 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 noting 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)