Skip to content

Commit 5b7abea

Browse files
kiryltorvalds
authored andcommitted
thp: fix MADV_DONTNEED vs clear soft dirty race
Yet another instance of the same race. Fix is identical to change_huge_pmd(). See "thp: fix MADV_DONTNEED vs. numa balancing race" for more details. Link: http://lkml.kernel.org/r/20170302151034.27829-5-kirill.shutemov@linux.intel.com Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Hillf Danton <hillf.zj@alibaba-inc.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 58ceeb6 commit 5b7abea

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fs/proc/task_mmu.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,14 @@ static inline void clear_soft_dirty(struct vm_area_struct *vma,
900900
static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma,
901901
unsigned long addr, pmd_t *pmdp)
902902
{
903-
pmd_t pmd = pmdp_huge_get_and_clear(vma->vm_mm, addr, pmdp);
903+
pmd_t pmd = *pmdp;
904+
905+
/* See comment in change_huge_pmd() */
906+
pmdp_invalidate(vma, addr, pmdp);
907+
if (pmd_dirty(*pmdp))
908+
pmd = pmd_mkdirty(pmd);
909+
if (pmd_young(*pmdp))
910+
pmd = pmd_mkyoung(pmd);
904911

905912
pmd = pmd_wrprotect(pmd);
906913
pmd = pmd_clear_soft_dirty(pmd);

0 commit comments

Comments
 (0)