mm: thp: check pmd_trans_unstable() after split_huge_pmd()
Subsystems (4)
[email protected]
maintainerPATCH 63/126 mm: thp: check pmd_trans_unstable() after split_huge_pmd()
From: Naoya Horiguchi <[email protected]>
Subject: mm: thp: check pmd_trans_unstable() after split_huge_pmd()
split_huge_pmd() doesn't guarantee that the pmd is normal pmd pointing to pte entries, which can be checked with pmd_trans_unstable(). Some callers make this assertion and some do it differently and some not, so let's do it in a unified manner.
Signed-off-by Naoya Horiguchi <[email protected]>
Cc "Kirill A. Shutemov" <[email protected]>
Cc Hugh Dickins <[email protected]>
Cc Mel Gorman <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
mm/gup.c | 2 ++ mm/mempolicy.c | 2 ++ mm/mprotect.c | 2 +- mm/mremap.c | 3 +-- 4 files changed, 6 insertions(+), 3 deletions(-)
mm/gup.c renamed from mm/gup.c~mm-thp-check-pmd_trans_unstable-after-split_huge_pmd +2 -0
@@ -279,6 +279,8 @@ struct page *follow_page_mask(struct vm_spin_unlock (ptl); ret =0 ;split_huge_pmd (vma, pmd, address); +if (pmd_trans_unstable (pmd)) + ret = -EBUSY ; }else {get_page (page);spin_unlock (ptl);
mm/mempolicy.c renamed from mm/mempolicy.c~mm-thp-check-pmd_trans_unstable-after-split_huge_pmd +2 -0
@@ -512,6 +512,8 @@ static int queue_pages_pte_range(pmd_t * } } +if (pmd_trans_unstable (pmd)) +return 0 ; retry: pte =pte_offset_map_lock (walk->mm, pmd, addr, &ptl);for (; addr != end; pte++, addr +=PAGE_SIZE ) {
mm/mprotect.c renamed from mm/mprotect.c~mm-thp-check-pmd_trans_unstable-after-split_huge_pmd +1 -1
@@ -163,7 +163,7 @@ static inline unsigned long change_pmd_rif (pmd_trans_huge (*pmd) ||pmd_devmap (*pmd)) {if (next - addr !=HPAGE_PMD_SIZE ) {split_huge_pmd (vma, pmd, addr); -if (pmd_none (*pmd)) +if (pmd_trans_unstable (pmd))continue ; }else { int nr_ptes = change_huge_pmd(vma, pmd, addr,
mm/mremap.c renamed from mm/mremap.c~mm-thp-check-pmd_trans_unstable-after-split_huge_pmd +1 -2
@@ -210,9 +210,8 @@ unsigned long move_page_tables(struct vm } }split_huge_pmd (vma, old_pmd, old_addr); -if (pmd_none (*old_pmd)) +if (pmd_trans_unstable (old_pmd))continue ; -VM_BUG_ON (pmd_trans_huge (*old_pmd)); }if (pte_alloc (new_vma->vm_mm, new_pmd, new_addr))break ;
_