mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_rw_nolock()
authorQi Zheng <zhengqi.arch@bytedance.com>
Thu, 26 Sep 2024 06:46:20 +0000 (14:46 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 6 Nov 2024 00:56:27 +0000 (16:56 -0800)
commit6dfd0d2cb3691040979ddbd6c758956694a3185d
tree86a3d82508709534d9a87023bd02b83e8fcb8f11
parentd9c1ddf37b4c287597a4578e70d19ed68d536be8
mm: khugepaged: collapse_pte_mapped_thp() use pte_offset_map_rw_nolock()

In collapse_pte_mapped_thp(), we may modify the pte and pmd entry after
acquiring the ptl, so convert it to using pte_offset_map_rw_nolock().  At
this time, the pte_same() check is not performed after the PTL held.  So
we should get pgt_pmd and do pmd_same() check after the ptl held.

Link: https://lkml.kernel.org/r/055e42db68da00ac8ecab94bd2633c7cd965eb1c.1727332572.git.zhengqi.arch@bytedance.com
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
Reviewed-by: Muchun Song <muchun.song@linux.dev>
Cc: David Hildenbrand <david@redhat.com>
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