aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJinjiang Tu <[email protected]>2025-07-25 03:31:12 +0000
committerAndrew Morton <[email protected]>2025-08-02 19:06:10 +0000
commit9109bd52559b44a66e4dbde69d0dd36f3e4dcae8 (patch)
tree8c8be28d30722d2c750d731c0e40000d992331b0
parentmm/mseal: rework mseal apply logic (diff)
downloadkernel-9109bd52559b44a66e4dbde69d0dd36f3e4dcae8.tar.gz
kernel-9109bd52559b44a66e4dbde69d0dd36f3e4dcae8.zip
mm/memory-failure: hold PTL in hwpoison_hugetlb_range
Hold PTL in hwpoison_hugetlb_range() to avoid operating on stale page, as hwpoison_pte_range() have done. This change is not known to address any issues which users have experienced. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Jinjiang Tu <[email protected]> Acked-by: David Hildenbrand <[email protected]> Cc: Andrei Vagin <[email protected]> Cc: Andrii Nakryiko <[email protected]> Cc: Baolin Wang <[email protected]> Cc: Brahmajit Das <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christophe Leroy <[email protected]> Cc: David Rientjes <[email protected]> Cc: Dev Jain <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Joern Engel <[email protected]> Cc: Kefeng Wang <[email protected]> Cc: Lorenzo Stoakes <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Thiago Jung Bauermann <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
-rw-r--r--mm/memory-failure.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 9e2cff199934..f0f0b23dcf2d 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -837,11 +837,17 @@ static int hwpoison_hugetlb_range(pte_t *ptep, unsigned long hmask,
struct mm_walk *walk)
{
struct hwpoison_walk *hwp = walk->private;
- pte_t pte = huge_ptep_get(walk->mm, addr, ptep);
struct hstate *h = hstate_vma(walk->vma);
+ spinlock_t *ptl;
+ pte_t pte;
+ int ret;
- return check_hwpoisoned_entry(pte, addr, huge_page_shift(h),
- hwp->pfn, &hwp->tk);
+ ptl = huge_pte_lock(h, walk->mm, ptep);
+ pte = huge_ptep_get(walk->mm, addr, ptep);
+ ret = check_hwpoisoned_entry(pte, addr, huge_page_shift(h),
+ hwp->pfn, &hwp->tk);
+ spin_unlock(ptl);
+ return ret;
}
#else
#define hwpoison_hugetlb_range NULL