On Fri, Oct 12, 2018 at 08:24:28PM -0400, Andrea Arcangeli wrote: > This is a corollary of ced108037c2aa542b3ed8b7afd1576064ad1362a, > 58ceeb6bec86d9140f9d91d71a710e963523d063, > 5b7abeae3af8c08c577e599dd0578b9e3ee6687b. > > When the above three fixes where posted Dave asked > https://lkml.kernel.org/r/929b3844-aec2-0111-fef7-8002f9d4e2b9@xxxxxxxxx > but apparently this was missed. > > The pmdp_clear_flush* in migrate_misplaced_transhuge_page was > introduced in commit a54a407fbf7735fd8f7841375574f5d9b0375f93. > > The important part of such commit is only the part where the page lock > is not released until the first do_huge_pmd_numa_page() finished > disarming the pagenuma/protnone. > > The addition of pmdp_clear_flush() wasn't beneficial to such commit > and there's no commentary about such an addition either. > > I guess the pmdp_clear_flush() in such commit was added just in case for > safety, but it ended up introducing the MADV_DONTNEED race condition > found by Aaron. > > At that point in time nobody thought of such kind of MADV_DONTNEED > race conditions yet (they were fixed later) so the code may have > looked more robust by adding the pmdp_clear_flush(). > > This specific race condition won't destabilize the kernel, but it can > confuse userland because after MADV_DONTNEED the memory won't be > zeroed out. > > This also optimizes the code and removes a superflous TLB flush. > > Reported-by: Aaron Tomlin <atomlin@xxxxxxxxxx> > Signed-off-by: Andrea Arcangeli <aarcange@xxxxxxxxxx> Acked-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> -- Kirill A. Shutemov