Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: change the interface of prep_compound_tail()

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.

Link: https://lkml.kernel.org/r/20260227194302.274384-3-kas@kernel.org
Signed-off-by: Kiryl Shutsemau <kas@kernel.org>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Acked-by: David Hildenbrand (arm) <david@kernel.org>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Baoquan He <bhe@redhat.com>
Cc: Christoph Lameter <cl@gentwo.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Frank van der Linden <fvdl@google.com>
Cc: Harry Yoo <harry.yoo@oracle.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Usama Arif <usamaarif642@gmail.com>
Cc: WANG Xuerui <kernel@xen0n.name>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Kiryl Shutsemau and committed by
Andrew Morton
f0369fb1 a2c77ec3

+15 -13
+3 -2
include/linux/page-flags.h
··· 870 870 return folio_test_head(folio); 871 871 } 872 872 873 - static __always_inline void set_compound_head(struct page *page, struct page *head) 873 + static __always_inline void set_compound_head(struct page *tail, 874 + const struct page *head, unsigned int order) 874 875 { 875 - WRITE_ONCE(page->compound_head, (unsigned long)head + 1); 876 + WRITE_ONCE(tail->compound_head, (unsigned long)head + 1); 876 877 } 877 878 878 879 static __always_inline void clear_compound_head(struct page *page)
+5 -3
mm/hugetlb.c
··· 3168 3168 3169 3169 /* Initialize [start_page:end_page_number] tail struct pages of a hugepage */ 3170 3170 static void __init hugetlb_folio_init_tail_vmemmap(struct folio *folio, 3171 + struct hstate *h, 3171 3172 unsigned long start_page_number, 3172 3173 unsigned long end_page_number) 3173 3174 { ··· 3177 3176 struct page *page = folio_page(folio, start_page_number); 3178 3177 unsigned long head_pfn = folio_pfn(folio); 3179 3178 unsigned long pfn, end_pfn = head_pfn + end_page_number; 3179 + unsigned int order = huge_page_order(h); 3180 3180 3181 3181 /* 3182 3182 * As we marked all tail pages with memblock_reserved_mark_noinit(), ··· 3185 3183 */ 3186 3184 for (pfn = head_pfn + start_page_number; pfn < end_pfn; page++, pfn++) { 3187 3185 __init_single_page(page, pfn, zone, nid); 3188 - prep_compound_tail((struct page *)folio, pfn - head_pfn); 3186 + prep_compound_tail(page, &folio->page, order); 3189 3187 set_page_count(page, 0); 3190 3188 } 3191 3189 } ··· 3205 3203 __folio_set_head(folio); 3206 3204 ret = folio_ref_freeze(folio, 1); 3207 3205 VM_BUG_ON(!ret); 3208 - hugetlb_folio_init_tail_vmemmap(folio, 1, nr_pages); 3206 + hugetlb_folio_init_tail_vmemmap(folio, h, 1, nr_pages); 3209 3207 prep_compound_head(&folio->page, huge_page_order(h)); 3210 3208 } 3211 3209 ··· 3262 3260 * time as this is early in boot and there should 3263 3261 * be no contention. 3264 3262 */ 3265 - hugetlb_folio_init_tail_vmemmap(folio, 3263 + hugetlb_folio_init_tail_vmemmap(folio, h, 3266 3264 HUGETLB_VMEMMAP_RESERVE_PAGES, 3267 3265 pages_per_huge_page(h)); 3268 3266 }
+5 -6
mm/internal.h
··· 897 897 INIT_LIST_HEAD(&folio->_deferred_list); 898 898 } 899 899 900 - static inline void prep_compound_tail(struct page *head, int tail_idx) 900 + static inline void prep_compound_tail(struct page *tail, 901 + const struct page *head, unsigned int order) 901 902 { 902 - struct page *p = head + tail_idx; 903 - 904 - p->mapping = TAIL_MAPPING; 905 - set_compound_head(p, head); 906 - set_page_private(p, 0); 903 + tail->mapping = TAIL_MAPPING; 904 + set_compound_head(tail, head, order); 905 + set_page_private(tail, 0); 907 906 } 908 907 909 908 void post_alloc_hook(struct page *page, unsigned int order, gfp_t gfp_flags);
+1 -1
mm/mm_init.c
··· 1110 1110 struct page *page = pfn_to_page(pfn); 1111 1111 1112 1112 __init_zone_device_page(page, pfn, zone_idx, nid, pgmap); 1113 - prep_compound_tail(head, pfn - head_pfn); 1113 + prep_compound_tail(page, head, order); 1114 1114 set_page_count(page, 0); 1115 1115 } 1116 1116 prep_compound_head(head, order);
+1 -1
mm/page_alloc.c
··· 744 744 745 745 __SetPageHead(page); 746 746 for (i = 1; i < nr_pages; i++) 747 - prep_compound_tail(page, i); 747 + prep_compound_tail(page + i, page, order); 748 748 749 749 prep_compound_head(page, order); 750 750 }