From: David Hildenbrand <david@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Brian Geffon <bgeffon@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Zi Yan <ziy@nvidia.com>, Kefeng Wang <wangkefeng.wang@huawei.com>,
Suren Baghdasaryan <surenb@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Hugh Dickins <hughd@google.com>,
Marek Maslanka <mmaslanka@google.com>
Subject: Re: [PATCH] mm: fix finish_fault() handling for large folios
Date: Wed, 26 Feb 2025 17:52:13 +0100 [thread overview]
Message-ID: <12dfdfde-06db-4112-9979-2ed320f80439@redhat.com> (raw)
In-Reply-To: <Z79BHbCL3U5aGS0Q@casper.infradead.org>
On 26.02.25 17:28, Matthew Wilcox wrote:
> On Wed, Feb 26, 2025 at 04:42:46PM +0100, David Hildenbrand wrote:
>> On 26.02.25 15:03, Matthew Wilcox wrote:
>>> On Wed, Feb 26, 2025 at 06:48:15AM -0500, Brian Geffon wrote:
>>>> When handling faults for anon shmem finish_fault() will attempt to install
>>>> ptes for the entire folio. Unfortunately if it encounters a single
>>>> non-pte_none entry in that range it will bail, even if the pte that
>>>> triggered the fault is still pte_none. When this situation happens the
>>>> fault will be retried endlessly never making forward progress.
>>>>
>>>> This patch fixes this behavior and if it detects that a pte in the range
>>>> is not pte_none it will fall back to setting just the pte for the
>>>> address that triggered the fault.
>>>
>>> Surely there's a similar problem in do_anonymous_page()?
>>
>> I recall we handle it in there correctly the last time I stared at it.
>>
>> We check pte_none to decide which folio size we can allocate (including
>> basing the decision on other factors like VMA etc), and after retaking the
>> PTL, we recheck vmf_pte_changed / pte_range_none() to make sure there were
>> no races.
>
> Ah, so then we'll retry and allocate a folio of the right size the next
> time?
IIRC we'll retry the fault in case we had a race. Likely, if we had a
race, somebody else installed a (large) folio and we essentially have to
second fault. If, for some reason, the race only touched parts of the
PTEs we tried to modify, we'll get another fault and allocate something
(smaller) that would fit into the new empty range.
So yes, we're more flexible because we're allocating the folios and
don't have to take whatever folio size is in the pagecache in consideration.
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-02-26 16:52 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-26 11:48 Brian Geffon
2025-02-26 14:03 ` Matthew Wilcox
2025-02-26 14:31 ` Brian Geffon
2025-02-26 15:42 ` David Hildenbrand
2025-02-26 16:28 ` Matthew Wilcox
2025-02-26 16:52 ` David Hildenbrand [this message]
2025-02-26 15:17 ` Baolin Wang
2025-02-26 15:46 ` Brian Geffon
2025-02-26 16:23 ` [PATCH v2] " Brian Geffon
2025-02-27 7:34 ` Baolin Wang
2025-02-27 16:47 ` Brian Geffon
2025-02-27 13:32 ` [PATCH v3] " Brian Geffon
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=12dfdfde-06db-4112-9979-2ed320f80439@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=bgeffon@google.com \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mmaslanka@google.com \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
--cc=ziy@nvidia.com \
/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