mm: khugepaged: __collapse_huge_page_swapin() use pte_offset_map_ro_nolock()
authorQi Zheng <zhengqi.arch@bytedance.com>
Thu, 26 Sep 2024 06:46:17 +0000 (14:46 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 6 Nov 2024 00:56:27 +0000 (16:56 -0800)
In __collapse_huge_page_swapin(), we just use the ptl for pte_same() check
in do_swap_page().  In other places, we directly use
pte_offset_map_lock(), so convert it to using pte_offset_map_ro_nolock().

Link: https://lkml.kernel.org/r/dc97a6c3cb9ea80cab30c5626eeea79959d93258.1727332572.git.zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Cc: Hugh Dickins <hughd@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mike Rapoport (Microsoft) <rppt@kernel.org>
Cc: Peter Xu <peterx@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/khugepaged.c

index ed1a225dd198e9824ec6520964d6ddf094e1e1d1..8e0d05bd3d56026ca740e1268b2b56e3c302515e 100644 (file)
@@ -1014,7 +1014,11 @@ static int __collapse_huge_page_swapin(struct mm_struct *mm,
                };
 
                if (!pte++) {
-                       pte = pte_offset_map_nolock(mm, pmd, address, &ptl);
+                       /*
+                        * Here the ptl is only used to check pte_same() in
+                        * do_swap_page(), so readonly version is enough.
+                        */
+                       pte = pte_offset_map_ro_nolock(mm, pmd, address, &ptl);
                        if (!pte) {
                                mmap_read_unlock(mm);
                                result = SCAN_PMD_NULL;