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

mm/hugetlb: convert hugetlb_change_protection() to folios

The for loop inside hugetlb_change_protection() increments by the huge
page size:

psize = huge_page_size(h);
for (; address < end; address += psize)

so we are operating on the head page of the huge pages between address and
end. We can safely convert the struct page usage to struct folio.

Link: https://lkml.kernel.org/r/20250528192013.91130-1-sidhartha.kumar@oracle.com
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Oscar Salvador <osalvador@suse.de>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Sidhartha Kumar and committed by
Andrew Morton
cdf48aa8 4a1ff347

+2 -2
+2 -2
mm/hugetlb.c
··· 7166 7166 /* Nothing to do. */ 7167 7167 } else if (unlikely(is_hugetlb_entry_migration(pte))) { 7168 7168 swp_entry_t entry = pte_to_swp_entry(pte); 7169 - struct page *page = pfn_swap_entry_to_page(entry); 7169 + struct folio *folio = pfn_swap_entry_folio(entry); 7170 7170 pte_t newpte = pte; 7171 7171 7172 7172 if (is_writable_migration_entry(entry)) { 7173 - if (PageAnon(page)) 7173 + if (folio_test_anon(folio)) 7174 7174 entry = make_readable_exclusive_migration_entry( 7175 7175 swp_offset(entry)); 7176 7176 else