From: Matthew Wilcox <willy@infradead.org>
To: David Stevens <stevensd@chromium.org>
Cc: Peter Xu <peterx@redhat.com>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
"Kirill A . Shutemov" <kirill@shutemov.name>,
Yang Shi <shy828301@gmail.com>,
David Hildenbrand <david@redhat.com>,
Hugh Dickins <hughd@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/khugepaged: skip shmem with userfaultfd
Date: Tue, 7 Feb 2023 02:29:40 +0000 [thread overview]
Message-ID: <Y+G3lDu3UPFZcFE0@casper.infradead.org> (raw)
In-Reply-To: <CAD=HUj4yhMLnBNpumxC4urSY2Js5XuekzGP+UOXJmUV=k5nx=A@mail.gmail.com>
On Tue, Feb 07, 2023 at 10:37:06AM +0900, David Stevens wrote:
> On Tue, Feb 7, 2023 at 6:50 AM Matthew Wilcox <willy@infradead.org> wrote:
> > On Mon, Feb 06, 2023 at 03:52:19PM -0500, Peter Xu wrote:
> > > The problem is khugepaged will release pgtable lock during collapsing, so
> > > AFAICT there can be a race where some other thread tries to insert pages
> > > into page cache in parallel with khugepaged right after khugepaged released
> > > the page cache lock.
> > >
> > > For example, it seems to me new page cache can be inserted when khugepaged
> > > is copying small page content to the new hpage.
>
> This particular race can't happen with either patch, since the missing
> page cache entries are filled when we create the multi-index entry for
> hpage.
Can too.
for (index = start; index < end; index++) {
...
if (xa_is_value(page) || !PageUptodate(page)) {
xas_unlock_irq(&xas);
/* swap in or instantiate fallocated page */
if (shmem_get_folio(mapping->host, index,
&folio, SGP_NOALLOC)) {
result = SCAN_FAIL;
goto xa_unlocked;
}
...
So we start the iteration, and then a page fault happens in one of
the indices we've already examined, but we don't have the page on
the list. It's a nice wide race too because we're bringing the
page in from swap.
next prev parent reply other threads:[~2023-02-07 2:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-06 11:28 David Stevens
2023-02-06 14:25 ` Matthew Wilcox
2023-02-06 19:01 ` Matthew Wilcox
2023-02-06 20:52 ` Peter Xu
2023-02-06 21:50 ` Matthew Wilcox
2023-02-07 1:37 ` David Stevens
2023-02-07 2:29 ` Matthew Wilcox [this message]
2023-02-07 4:14 ` David Stevens
2023-02-06 21:02 ` Peter Xu
2023-02-07 3:56 ` David Stevens
2023-02-07 16:34 ` Peter Xu
2023-02-08 2:42 ` David Stevens
2023-02-08 17:24 ` Peter Xu
2023-02-09 5:10 ` David Stevens
2023-02-09 18:50 ` Peter Xu
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=Y+G3lDu3UPFZcFE0@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=shy828301@gmail.com \
--cc=stevensd@chromium.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