From nobody Sat Feb 7 20:58:17 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5F4DD3A0EAF for ; Thu, 15 Jan 2026 14:46:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768488377; cv=none; b=afuEvySOyuJYPNUFHI6gCOaWv7Cw70+WtPud5PVHCMrWN1udkwT9hqkCHHl+6xBgc6LutwSNSzGlrEK19SVw2UCP+w5NYF4ZzWetHls25VO1B7wTSXaUiXLNjYV0Meld/046JeQ2mJ9w7UT9sOYqp14fWxVTCzELlNV7ONwd4gk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768488377; c=relaxed/simple; bh=ft4QB+pe2zfMyyeRxFmvFGapI2DJYfjteZFz/aCazm4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SDqOVaPAIi5fGKNXV+RqU517G2WeFwwQqcafeAFMZmEycW8FTUcGqnqVGb7yrsaEuVyExSZupnKYCfTixdx85bqk6K4nSEPvqHNTgDDqWu32nUx6ubh81KvlJn6DXgMk4Yc5+uf9AutwoLCdMQyn1USaprH+XqJHOipxOxOG+l0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Snk1xT7N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Snk1xT7N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 113FCC116D0; Thu, 15 Jan 2026 14:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1768488375; bh=ft4QB+pe2zfMyyeRxFmvFGapI2DJYfjteZFz/aCazm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Snk1xT7N/hAcSlG+429C+NoZs18+WxhsUMs5OQqWEz7O+khW6evtiM3B/f0WgUbvX MliO4HtvbKbd1g6NqFtSyxmn6B4w6g5o7f+zwEdWyQdbAGsHLBzTg0OYgECs0t0Mhl I5x0JVmwjqX2VZHqo2SrxmNf8LYWczfzhH6HBmqFxj1NB3taX35UH4pXWZl/yeJEDp ldsWa2GFaZuRvisHiZkfj4s+6p1ewJsqd2J7QGdUzBgbql0hVkS2HLQFYMb781C9S0 yWwr69eijmzxhBuoCHldIUjMmlQa+hbgL1h/Y30Mvc1am1fzEiz3RtXwha2KHUV+7Z aN3sXFg2NQMog== Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfauth.phl.internal (Postfix) with ESMTP id 3DFC6F40068; Thu, 15 Jan 2026 09:46:14 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Thu, 15 Jan 2026 09:46:14 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgdduvdeifeefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhirhihlhcu ufhhuhhtshgvmhgruhcuoehkrghssehkvghrnhgvlhdrohhrgheqnecuggftrfgrthhtvg hrnhephfdufeejhefhkedtuedvfeevjeffvdfhvedtudfgudffjeefieekleehvdetvdev necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepkhhirh hilhhlodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduieduudeivdeiheeh qddvkeeggeegjedvkedqkhgrsheppehkvghrnhgvlhdrohhrghesshhhuhhtvghmohhvrd hnrghmvgdpnhgspghrtghpthhtohepvddtpdhmohguvgepshhmthhpohhuthdprhgtphht thhopegrkhhpmheslhhinhhugidqfhhouhhnuggrthhiohhnrdhorhhgpdhrtghpthhtoh epmhhutghhuhhnrdhsohhngheslhhinhhugidruggvvhdprhgtphhtthhopegurghvihgu sehkvghrnhgvlhdrohhrghdprhgtphhtthhopeifihhllhihsehinhhfrhgruggvrggurd horhhgpdhrtghpthhtohepuhhsrghmrggrrhhifheigedvsehgmhgrihhlrdgtohhmpdhr tghpthhtohepfhhvughlsehgohhoghhlvgdrtghomhdprhgtphhtthhopehoshgrlhhvrg guohhrsehsuhhsvgdruggvpdhrtghpthhtoheprhhpphhtsehkvghrnhgvlhdrohhrghdp rhgtphhtthhopehvsggrsghkrgesshhushgvrdgtii X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 15 Jan 2026 09:46:13 -0500 (EST) From: Kiryl Shutsemau To: Andrew Morton , Muchun Song , David Hildenbrand , Matthew Wilcox , Usama Arif , Frank van der Linden Cc: Oscar Salvador , Mike Rapoport , Vlastimil Babka , Lorenzo Stoakes , Zi Yan , Baoquan He , Michal Hocko , Johannes Weiner , Jonathan Corbet , kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Kiryl Shutsemau Subject: [PATCHv3 03/15] mm: Change the interface of prep_compound_tail() Date: Thu, 15 Jan 2026 14:45:49 +0000 Message-ID: <20260115144604.822702-4-kas@kernel.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20260115144604.822702-1-kas@kernel.org> References: <20260115144604.822702-1-kas@kernel.org> 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 Content-Type: text/plain; charset="utf-8" Instead of passing down the head page and tail page index, pass the tail and head pages directly, as well as the order of the compound page. This is a preparation for changing how the head position is encoded in the tail page. Signed-off-by: Kiryl Shutsemau Reviewed-by: Muchun Song --- include/linux/page-flags.h | 4 +++- mm/hugetlb.c | 8 +++++--- mm/internal.h | 12 ++++++------ mm/mm_init.c | 2 +- mm/page_alloc.c | 2 +- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 0091ad1986bf..d4952573a4af 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h @@ -865,7 +865,9 @@ static inline bool folio_test_large(const struct folio = *folio) return folio_test_head(folio); } =20 -static __always_inline void set_compound_head(struct page *page, struct pa= ge *head) +static __always_inline void set_compound_head(struct page *page, + const struct page *head, + unsigned int order) { WRITE_ONCE(page->compound_head, (unsigned long)head + 1); } diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 0455119716ec..a55d638975bd 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3212,6 +3212,7 @@ int __alloc_bootmem_huge_page(struct hstate *h, int n= id) =20 /* Initialize [start_page:end_page_number] tail struct pages of a hugepage= */ static void __init hugetlb_folio_init_tail_vmemmap(struct folio *folio, + struct hstate *h, unsigned long start_page_number, unsigned long end_page_number) { @@ -3220,6 +3221,7 @@ static void __init hugetlb_folio_init_tail_vmemmap(st= ruct folio *folio, struct page *page =3D folio_page(folio, start_page_number); unsigned long head_pfn =3D folio_pfn(folio); unsigned long pfn, end_pfn =3D head_pfn + end_page_number; + unsigned int order =3D huge_page_order(h); =20 /* * As we marked all tail pages with memblock_reserved_mark_noinit(), @@ -3227,7 +3229,7 @@ static void __init hugetlb_folio_init_tail_vmemmap(st= ruct folio *folio, */ for (pfn =3D head_pfn + start_page_number; pfn < end_pfn; page++, pfn++) { __init_single_page(page, pfn, zone, nid); - prep_compound_tail((struct page *)folio, pfn - head_pfn); + prep_compound_tail(page, &folio->page, order); set_page_count(page, 0); } } @@ -3247,7 +3249,7 @@ static void __init hugetlb_folio_init_vmemmap(struct = folio *folio, __folio_set_head(folio); ret =3D folio_ref_freeze(folio, 1); VM_BUG_ON(!ret); - hugetlb_folio_init_tail_vmemmap(folio, 1, nr_pages); + hugetlb_folio_init_tail_vmemmap(folio, h, 1, nr_pages); prep_compound_head((struct page *)folio, huge_page_order(h)); } =20 @@ -3304,7 +3306,7 @@ static void __init prep_and_add_bootmem_folios(struct= hstate *h, * time as this is early in boot and there should * be no contention. */ - hugetlb_folio_init_tail_vmemmap(folio, + hugetlb_folio_init_tail_vmemmap(folio, h, HUGETLB_VMEMMAP_RESERVE_PAGES, pages_per_huge_page(h)); } diff --git a/mm/internal.h b/mm/internal.h index 1561fc2ff5b8..f385370256b9 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -810,13 +810,13 @@ static inline void prep_compound_head(struct page *pa= ge, unsigned int order) INIT_LIST_HEAD(&folio->_deferred_list); } =20 -static inline void prep_compound_tail(struct page *head, int tail_idx) +static inline void prep_compound_tail(struct page *tail, + const struct page *head, + unsigned int order) { - struct page *p =3D head + tail_idx; - - p->mapping =3D TAIL_MAPPING; - set_compound_head(p, head); - set_page_private(p, 0); + tail->mapping =3D TAIL_MAPPING; + set_compound_head(tail, head, order); + set_page_private(tail, 0); } =20 void post_alloc_hook(struct page *page, unsigned int order, gfp_t gfp_flag= s); diff --git a/mm/mm_init.c b/mm/mm_init.c index 7712d887b696..87d1e0277318 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1102,7 +1102,7 @@ static void __ref memmap_init_compound(struct page *h= ead, struct page *page =3D pfn_to_page(pfn); =20 __init_zone_device_page(page, pfn, zone_idx, nid, pgmap); - prep_compound_tail(head, pfn - head_pfn); + prep_compound_tail(page, head, order); set_page_count(page, 0); } prep_compound_head(head, order); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index ed82ee55e66a..fe77c00c99df 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -717,7 +717,7 @@ void prep_compound_page(struct page *page, unsigned int= order) =20 __SetPageHead(page); for (i =3D 1; i < nr_pages; i++) - prep_compound_tail(page, i); + prep_compound_tail(page + i, page, order); =20 prep_compound_head(page, order); } --=20 2.51.2