From nobody Sun Feb 8 12:36:27 2026 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7C381DF268 for ; Tue, 3 Dec 2024 08:38:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733215116; cv=none; b=WHB2BICUT0dydspzkgh5etjpi4aq+Ykn+WH8ELjok8mJ3z1atB3xPgK4AJ1UG/HIQwTzRkqPe4sUgOEbZgx85aYwrx6tl8Jc2bpTre3AJ90ZQKesY9VuCbAnC+Hh79HBd977x/D/BEPoHBC8y4YHcwnc+MU22TWIBPM3iG7leHM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733215116; c=relaxed/simple; bh=BE95e1zGPFXvVOiSFQar6b+X36e2g4Vn8nTd7MPy5DY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uMsHfDnGNiY55CQxALah685DTR/6EmRF+imdvA8wBRrcXhlcJvOwTAig3tui8wux1couJo2Od/qn2SWP/M3nLdKpN3a1IA3rSJzHgaULcquEVej2i+OFHgBeZ/KBlOFMZtF/aSTYmmRb+GuTkN1z6e+80x5IxiwLChceC9hjCQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=VPOkJzE6; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VPOkJzE6" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1733215114; 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=VPOkJzE6CbUarMNBDoGmvSlFM/3IMVQ2bU0eDJC1XVIK+QyeIG0B3Bl+HSsTocnd72uIan y4hO5otXlNs6T3o1zg3ofbZaMxvzAY4eQZ5jU4SItwduO0TI7MRQ8sjFycy8o1nhmKsVBl JSdJVG3RncAa7mQXpYd4rmX1rOmSWJw= 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Content-Type: text/plain; charset="utf-8" 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 compac= t_control *cc, return (ret < 0) ? ret : 0; } =20 -static void split_free_pages(struct list_head *list) +static void split_free_pages(struct list_head *list, gfp_t gfp_mask) { int order; =20 @@ -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; =20 - 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_ma= sk) { const gfp_t reclaim_mask =3D __GFP_IO | __GFP_FS | __GFP_RECLAIM; - const gfp_t action_mask =3D __GFP_COMP | __GFP_RETRY_MAYFAIL | __GFP_NOWA= RN; + const gfp_t action_mask =3D __GFP_COMP | __GFP_RETRY_MAYFAIL | __GFP_NOWA= RN | + __GFP_ZERO | __GFP_ZEROTAGS | __GFP_SKIP_ZERO; const gfp_t cc_action_mask =3D __GFP_RETRY_MAYFAIL | __GFP_NOWARN; =20 /* @@ -6541,7 +6542,7 @@ int alloc_contig_range_noprof(unsigned long start, un= signed long end, } =20 if (!(gfp_mask & __GFP_COMP)) { - split_free_pages(cc.freepages); + split_free_pages(cc.freepages, gfp_mask); =20 /* Free head and tail (if any) */ if (start !=3D outer_start) --=20 2.47.1