mm/munlock: rmap call mlock_vma_page() munlock_vma_page()
[linux-2.6-microblaze.git] / mm / userfaultfd.c
index 0780c2a..15d3e97 100644 (file)
@@ -95,10 +95,15 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd,
        if (!pte_none(*dst_pte))
                goto out_unlock;
 
-       if (page_in_cache)
-               page_add_file_rmap(page, false);
-       else
+       if (page_in_cache) {
+               /* Usually, cache pages are already added to LRU */
+               if (newly_allocated)
+                       lru_cache_add(page);
+               page_add_file_rmap(page, dst_vma, false);
+       } else {
                page_add_new_anon_rmap(page, dst_vma, dst_addr, false);
+               lru_cache_add_inactive_or_unevictable(page, dst_vma);
+       }
 
        /*
         * Must happen after rmap, as mm_counter() checks mapping (via
@@ -106,9 +111,6 @@ int mfill_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd,
         */
        inc_mm_counter(dst_mm, mm_counter(page));
 
-       if (newly_allocated)
-               lru_cache_add_inactive_or_unevictable(page, dst_vma);
-
        set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte);
 
        /* No need to invalidate - it was non-present before */