]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
userfault; expand folio use in mfill_atomic_install_pte()
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Tue, 23 Apr 2024 22:55:36 +0000 (23:55 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 6 May 2024 00:53:48 +0000 (17:53 -0700)
Call page_folio() a little earlier so we can use folio_mapping()
instead of page_mapping(), saving a call to compound_head().

Link: https://lkml.kernel.org/r/20240423225552.4113447-6-willy@infradead.org
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Eric Biggers <ebiggers@google.com>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/userfaultfd.c

index 575ccf90325aa7740b11246455cbdc98ac67a61c..8b1005ef9dfa9c954387b001ecbeb52383a4aaae 100644 (file)
@@ -180,9 +180,9 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd,
        pte_t _dst_pte, *dst_pte;
        bool writable = dst_vma->vm_flags & VM_WRITE;
        bool vm_shared = dst_vma->vm_flags & VM_SHARED;
-       bool page_in_cache = page_mapping(page);
        spinlock_t *ptl;
-       struct folio *folio;
+       struct folio *folio = page_folio(page);
+       bool page_in_cache = folio_mapping(folio);
 
        _dst_pte = mk_pte(page, dst_vma->vm_page_prot);
        _dst_pte = pte_mkdirty(_dst_pte);
@@ -212,7 +212,6 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd,
        if (!pte_none_mostly(ptep_get(dst_pte)))
                goto out_unlock;
 
-       folio = page_folio(page);
        if (page_in_cache) {
                /* Usually, cache pages are already added to LRU */
                if (newly_allocated)