]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
minor cleanup according to Peter Xu
authorBarry Song <v-songbaohua@oppo.com>
Wed, 26 Feb 2025 02:22:17 +0000 (15:22 +1300)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 28 Feb 2025 00:58:47 +0000 (16:58 -0800)
According to Peter Xu:
1. Unnecessary line move.
2. Can drop this folio check as it just did check
   "!IS_ERR_OR_NULL(folio)"
3. Not sure if it can do any harm, but maybe still nicer
   to put swap before locking folio.

Link: https://lkml.kernel.org/r/20250226024411.47092-1-21cnbao@gmail.com
Signed-off-by: Barry Song <v-songbaohua@oppo.com>
Cc: Peter Xu <peterx@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/userfaultfd.c

index 8eae4ea3cafd2e037adbeab89ba117dfbde4830d..c45b672e10d17eef361268a046062ab20a5052bb 100644 (file)
@@ -1105,8 +1105,8 @@ static int move_swap_pte(struct mm_struct *mm, struct vm_area_struct *dst_vma,
 
        orig_src_pte = ptep_get_and_clear(mm, src_addr, src_pte);
        set_pte_at(mm, dst_addr, dst_pte, orig_src_pte);
-
        double_pt_unlock(dst_ptl, src_ptl);
+
        return 0;
 }
 
@@ -1373,7 +1373,7 @@ retry:
                        folio = filemap_get_folio(swap_address_space(entry),
                                        swap_cache_index(entry));
                if (!IS_ERR_OR_NULL(folio)) {
-                       if (folio && folio_test_large(folio)) {
+                       if (folio_test_large(folio)) {
                                err = -EBUSY;
                                folio_put(folio);
                                goto out;
@@ -1384,10 +1384,10 @@ retry:
                                pte_unmap(&orig_src_pte);
                                pte_unmap(&orig_dst_pte);
                                src_pte = dst_pte = NULL;
-                               /* now we can block and wait */
-                               folio_lock(src_folio);
                                put_swap_device(si);
                                si = NULL;
+                               /* now we can block and wait */
+                               folio_lock(src_folio);
                                goto retry;
                        }
                }