linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jann Horn <jannh@google.com>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: Andy Lutomirski <luto@kernel.org>, Linux-MM <linux-mm@kvack.org>,
	Mel Gorman <mgorman@suse.de>,  Rik van Riel <riel@redhat.com>,
	kernel list <linux-kernel@vger.kernel.org>,
	 Kees Cook <keescook@chromium.org>,
	Ingo Molnar <mingo@kernel.org>,
	 Sasha Levin <sasha.levin@oracle.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	 Will Deacon <will@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	 Linus Torvalds <torvalds@linuxfoundation.org>
Subject: Re: [BUG?] X86 arch_tlbbatch_flush() seems to be lacking mm_tlb_flush_nested() integration
Date: Mon, 17 Oct 2022 12:56:37 +0200	[thread overview]
Message-ID: <CAG48ez3bPLVA2tqoYUT_mKp3u_yUg5QXx7AmxASrTE=jxnNWJg@mail.gmail.com> (raw)
In-Reply-To: <0484E294-D6D6-45CE-87F7-5AFDA5309BA1@gmail.com>

On Sat, Oct 15, 2022 at 5:51 AM Nadav Amit <nadav.amit@gmail.com> wrote:
> On Oct 14, 2022, at 9:19 PM, Jann Horn <jannh@google.com> wrote:
> > I haven't actually managed to reproduce this behavior, so maybe I'm
> > just misunderstanding how this works; but I think the
> > arch_tlbbatch_flush() path for batched TLB flushing in vmscan ought to
> > have some kind of integration with mm_tlb_flush_nested().
> >
> > I think that currently, the following race could happen:
> >
> > [initial situation: page P is mapped into a page table of task B, but
> > the page is not referenced, the PTE's A/D bits are clear]
> > A: vmscan begins
> > A: vmscan looks at P and P's PTEs, and concludes that P is not currently in use
> > B: reads from P through the PTE, setting the Accessed bit and creating
> > a TLB entry
> > A: vmscan enters try_to_unmap_one()
> > A: try_to_unmap_one() calls should_defer_flush(), which returns true
> > A: try_to_unmap_one() removes the PTE and queues a TLB flush
> > (arch_tlbbatch_add_mm())
> > A: try_to_unmap_one() returns, try_to_unmap() returns to shrink_folio_list()
> > B: calls munmap() on the VMA that mapped P
> > B: no PTEs are removed, so no TLB flush happens
>
> Unless I am missing something, flush_tlb_batched_pending() is would be
> called and do the flushing at this point, no?

Ooooh! Thanks, I missed that.


      parent reply	other threads:[~2022-10-17 10:57 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-14 18:19 Jann Horn
2022-10-14 19:08 ` Linus Torvalds
2022-10-14 22:23 ` Kirill A. Shutemov
2022-10-14 22:29   ` Jann Horn
2022-10-14 22:55     ` Kirill A. Shutemov
2022-10-15  3:51 ` Nadav Amit
2022-10-15 23:47   ` Linus Torvalds
2022-10-16  5:31     ` Nadav Amit
2022-10-17 14:57     ` Mel Gorman
2022-10-17 10:56   ` Jann Horn [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAG48ez3bPLVA2tqoYUT_mKp3u_yUg5QXx7AmxASrTE=jxnNWJg@mail.gmail.com' \
    --to=jannh@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=nadav.amit@gmail.com \
    --cc=peterz@infradead.org \
    --cc=riel@redhat.com \
    --cc=sasha.levin@oracle.com \
    --cc=torvalds@linuxfoundation.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox