]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
mm/hugetlb: convert hugetlb_change_protection() to folios
authorSidhartha Kumar <sidhartha.kumar@oracle.com>
Wed, 28 May 2025 19:20:13 +0000 (15:20 -0400)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 10 Jul 2025 05:41:54 +0000 (22:41 -0700)
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>
mm/hugetlb.c

index 9dc95eac558cde833ad406f11fcfed61da183821..7a7df0b2a56160c7a4ae8719b37b21519b1f8f87 100644 (file)
@@ -7166,11 +7166,11 @@ long hugetlb_change_protection(struct vm_area_struct *vma,
                        /* Nothing to do. */
                } else if (unlikely(is_hugetlb_entry_migration(pte))) {
                        swp_entry_t entry = pte_to_swp_entry(pte);
-                       struct page *page = pfn_swap_entry_to_page(entry);
+                       struct folio *folio = pfn_swap_entry_folio(entry);
                        pte_t newpte = pte;
 
                        if (is_writable_migration_entry(entry)) {
-                               if (PageAnon(page))
+                               if (folio_test_anon(folio))
                                        entry = make_readable_exclusive_migration_entry(
                                                                swp_offset(entry));
                                else