[PATCH] minor cleanup according to Peter Xu
From: Barry Song
Date: Tue Feb 25 2025 - 21:22:17 EST
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.
Signed-off-by: Barry Song <v-songbaohua@xxxxxxxx>
---
mm/userfaultfd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c
index 2df5d100e76d..2955e20f86bf 100644
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -1101,8 +1101,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;
}
@@ -1369,7 +1369,7 @@ static int move_pages_pte(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd,
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;
@@ -1380,10 +1380,10 @@ static int move_pages_pte(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd,
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;
}
}
--
2.39.3 (Apple Git-146)
> Peter Xu
>
Thanks
Barry