Skip to content

Commit

Permalink
khugepaged: recheck pmd after mmap_sem re-acquired
Browse files Browse the repository at this point in the history
Vlastimil noted[1] that pmd can be no longer valid after we drop
mmap_sem.  We need recheck it once mmap_sem taken again.

[1] http://lkml.kernel.org/r/12918dcd-a695-c6f4-e06f-69141c5f357f@suse.cz

Link: http://lkml.kernel.org/r/1466021202-61880-6-git-send-email-kirill.shutemov@linux.intel.com
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Kirill A. Shutemov authored and Linus Torvalds committed Jul 26, 2016
1 parent 8024ee2 commit 1f52e67
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions mm/huge_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,9 @@ static bool __collapse_huge_page_swapin(struct mm_struct *mm,
/* vma is no longer available, don't continue to swapin */
if (hugepage_vma_revalidate(mm, address))
return false;
/* check if the pmd is still valid */
if (mm_find_pmd(mm, address) != pmd)
return false;
}
if (ret & VM_FAULT_ERROR) {
trace_mm_collapse_huge_page_swapin(mm, swapped_in, 0);
Expand Down Expand Up @@ -2518,6 +2521,9 @@ static void collapse_huge_page(struct mm_struct *mm,
result = hugepage_vma_revalidate(mm, address);
if (result)
goto out;
/* check if the pmd is still valid */
if (mm_find_pmd(mm, address) != pmd)
goto out;

anon_vma_lock_write(vma->anon_vma);

Expand Down

0 comments on commit 1f52e67

Please sign in to comment.