Skip to content

Commit ef4c962

Browse files
kirylgregkh
authored andcommitted
thp: fix MADV_DONTNEED vs clear soft dirty race
commit 5b7abeae3af8c08c577e599dd0578b9e3ee6687b upstream. 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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3144d81 commit ef4c962

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

fs/proc/task_mmu.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,14 @@ static inline void clear_soft_dirty(struct vm_area_struct *vma,
803803
static inline void clear_soft_dirty_pmd(struct vm_area_struct *vma,
804804
unsigned long addr, pmd_t *pmdp)
805805
{
806-
pmd_t pmd = pmdp_huge_get_and_clear(vma->vm_mm, addr, pmdp);
806+
pmd_t pmd = *pmdp;
807+
808+
/* See comment in change_huge_pmd() */
809+
pmdp_invalidate(vma, addr, pmdp);
810+
if (pmd_dirty(*pmdp))
811+
pmd = pmd_mkdirty(pmd);
812+
if (pmd_young(*pmdp))
813+
pmd = pmd_mkyoung(pmd);
807814

808815
pmd = pmd_wrprotect(pmd);
809816
pmd = pmd_clear_soft_dirty(pmd);

0 commit comments

Comments
 (0)