From: Oscar Salvador <osalvador@suse.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>,
Muchun Song <muchun.song@linux.dev>,
James Houghton <jthoughton@google.com>,
Peter Xu <peterx@redhat.com>, Gavin Guo <gavinguo@igalia.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/5] Misc rework on hugetlb_fault
Date: Fri, 13 Jun 2025 10:55:08 +0200 [thread overview]
Message-ID: <aEvnbO0n8lkYF9yI@localhost.localdomain> (raw)
In-Reply-To: <20250612134701.377855-1-osalvador@suse.de>
On Thu, Jun 12, 2025 at 03:46:56PM +0200, Oscar Salvador wrote:
> This is a new version of the RFC I sent a couple of weeks ago [1].
> It's the conclusion of the discussions that ocurred in that thread.
>
> Patch#1 is the fix for the deadlock.
> Patch#2 is to document why we take the lock, so none of us have to spend
> time again in figuring that out.
> Patch#3-5 are a bit of cleanup (removing obsolete comments etc.)
Andrew told me that this is very vague for a coverletter, and while this patchset
is sort of a refactor/clenaup/fixup mix, I acknowledge that it is far
from optimal to get people some context.
So let me try again, and I apologyze.
"
This patchset aims to give some love to the hugetlb faulting path, doing so
by removing obsolete comments that are no longer true, documenting in a clear
way the reason we take certain locks, and changing the mechanism we use to
determine whether we are COWing a private mapping already.
The most important patch of the series is #1, as it fixes a deadlock that
was described in [1], where two processes were holding the same lock
for the folio in the pagecache, and then deadlocked in the mutex.
Looking up and locking the folio in the pagecache was done to check whether
that folio was the same folio we had mapped in our pagetables, meaning that if it
was different we knew that we already mapped that folio privately, so any
further CoW would be made on a private mapping, which lead us to the question:
__Was the reservation for that address consumed?__
That is all we care about, because if it was indeed consumed and we are the
owner and we cannot allocate more folios, we need to unmap the folio from the
processes pagetables and make it exclusive for us.
We figured we do not need to look up the folio at all, and it is just enough to
check whether the folio we have mapped is anonymous, which means we mapped it
privately, so the reservation was indeed consumed.
Patch#2 follows a bit more to the trend on why we need to lock the
folio from the pagetables, whether it is anonymous or not.
For anonymous folios we need the lock in order to check whether we can re-use
exclusively for us, while for file folios we need to hold the lock to make the
folio stable throughout the copy.
We also hold it even if we are read-faulting, just to make sure it does not go
away. For this last case, we are already covered by the hugetlb_mutex, but
in order to bring hugetlb closer to the general faulting path, let us rely on
the lock instead, as do_read_fault() does.
Patch#3 is a merely correctness issue if you will, while Patch#4 and
Patch#5 remove obsolete comments and assumptions that are no longer
true.
[1] https://lore.kernel.org/lkml/20250513093448.592150-1-gavinguo@igalia.com/
"
Shame on me, this should have been the cover letter.
--
Oscar Salvador
SUSE Labs
prev parent reply other threads:[~2025-06-13 8:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 13:46 Oscar Salvador
2025-06-12 13:46 ` [PATCH 1/5] mm,hugetlb: Change mechanism to detect a COW on private mapping Oscar Salvador
2025-06-13 13:52 ` David Hildenbrand
2025-06-12 13:46 ` [PATCH 2/5] mm,hugetlb: Document the reason to lock the folio in the faulting path Oscar Salvador
2025-06-13 13:56 ` David Hildenbrand
2025-06-13 14:23 ` Oscar Salvador
2025-06-13 19:57 ` David Hildenbrand
2025-06-13 21:47 ` Oscar Salvador
2025-06-14 9:07 ` Oscar Salvador
2025-06-16 9:22 ` David Hildenbrand
2025-06-16 14:10 ` Oscar Salvador
2025-06-16 14:41 ` David Hildenbrand
2025-06-17 10:03 ` Oscar Salvador
2025-06-17 11:27 ` David Hildenbrand
2025-06-17 12:04 ` Oscar Salvador
2025-06-17 12:08 ` David Hildenbrand
2025-06-17 12:10 ` Oscar Salvador
2025-06-17 12:50 ` Oscar Salvador
2025-06-17 13:42 ` David Hildenbrand
2025-06-17 14:00 ` Oscar Salvador
2025-06-19 11:52 ` Oscar Salvador
2025-06-12 13:46 ` [PATCH 3/5] mm,hugetlb: Conver anon_rmap into boolean Oscar Salvador
2025-06-13 13:48 ` David Hildenbrand
2025-06-12 13:47 ` [PATCH 4/5] mm,hugetlb: Drop obsolete comment about non-present pte and second faults Oscar Salvador
2025-06-12 13:47 ` [PATCH 5/5] mm,hugetlb: Drop unlikelys from hugetlb_fault Oscar Salvador
2025-06-13 8:55 ` Oscar Salvador [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=aEvnbO0n8lkYF9yI@localhost.localdomain \
--to=osalvador@suse.de \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=gavinguo@igalia.com \
--cc=jthoughton@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=peterx@redhat.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