mprotect: use pfn_swap_entry_folio
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 11 Jan 2024 15:24:22 +0000 (15:24 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 22 Feb 2024 00:00:03 +0000 (16:00 -0800)
We only want to know whether the folio is anonymous, so use
pfn_swap_entry_folio() and save a call to compound_head().

Link: https://lkml.kernel.org/r/20240111152429.3374566-4-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: David Hildenbrand <david@redhat.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mprotect.c

index 81991102f7859e94cacd9670d42891038e92b214..f8a4544b4601db4e4ff8e575934ea9502850cd8a 100644 (file)
@@ -198,13 +198,13 @@ static long change_pte_range(struct mmu_gather *tlb,
                        pte_t newpte;
 
                        if (is_writable_migration_entry(entry)) {
-                               struct page *page = pfn_swap_entry_to_page(entry);
+                               struct folio *folio = pfn_swap_entry_folio(entry);
 
                                /*
                                 * A protection check is difficult so
                                 * just be safe and disable write
                                 */
-                               if (PageAnon(page))
+                               if (folio_test_anon(folio))
                                        entry = make_readable_exclusive_migration_entry(
                                                             swp_offset(entry));
                                else