Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
forked fromtorvalds/linux

Commit58ceeb6

Browse files
kiryltorvalds
authored andcommitted
thp: fix MADV_DONTNEED vs. MADV_FREE race
Both MADV_DONTNEED and MADV_FREE handled with down_read(mmap_sem).It's critical to not clear pmd intermittently while handling MADV_FREEto avoid race with MADV_DONTNEED:CPU0:CPU1:madvise_free_huge_pmd() pmdp_huge_get_and_clear_full()madvise_dontneed() zap_pmd_range() pmd_trans_huge(*pmd) == 0 (without ptl) // skip the pmd set_pmd_at(); // pmd is re-establishedIt results in MADV_DONTNEED skipping the pmd, leaving it not cleared.It violates MADV_DONTNEED interface and can result is userspacemisbehaviour.Basically it's the same race as with numa balancing inchange_huge_pmd(), but a bit simpler to mitigate: we don't need topreserve dirty/young flags here due to MADV_FREE functionality.[kirill.shutemov@linux.intel.com: Urgh... Power is special again] Link:http://lkml.kernel.org/r/20170303102636.bhd2zhtpds4mt62a@black.fi.intel.comLink:http://lkml.kernel.org/r/20170302151034.27829-4-kirill.shutemov@linux.intel.comSigned-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>Acked-by: Minchan Kim <minchan@kernel.org>Cc: Minchan Kim <minchan@kernel.org>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 parentc0c379e commit58ceeb6

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

‎mm/huge_memory.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,8 +1568,7 @@ bool madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
15681568
deactivate_page(page);
15691569

15701570
if (pmd_young(orig_pmd)||pmd_dirty(orig_pmd)) {
1571-
orig_pmd=pmdp_huge_get_and_clear_full(tlb->mm,addr,pmd,
1572-
tlb->fullmm);
1571+
pmdp_invalidate(vma,addr,pmd);
15731572
orig_pmd=pmd_mkold(orig_pmd);
15741573
orig_pmd=pmd_mkclean(orig_pmd);
15751574

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp