From: Hugh Dickins <hughd@google.com>
To: Oscar Salvador <osalvador@suse.de>
Cc: Hugh Dickins <hughd@google.com>, Gavin Guo <gavinguo@igalia.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
muchun.song@linux.dev, akpm@linux-foundation.org,
kernel-dev@igalia.com, stable@vger.kernel.org,
Florent Revest <revest@google.com>,
Gavin Shan <gshan@redhat.com>
Subject: Re: [PATCH v2] mm/hugetlb: fix a deadlock with pagecache_folio and hugetlb_fault_mutex_table
Date: Wed, 21 May 2025 08:58:32 -0700 (PDT) [thread overview]
Message-ID: <54bd3d6c-d763-ae09-6ee2-7ef192a97ca9@google.com> (raw)
In-Reply-To: <aC33A65HFJOSO1_R@localhost.localdomain>
On Wed, 21 May 2025, Oscar Salvador wrote:
> On Wed, May 21, 2025 at 08:10:46AM -0700, Hugh Dickins wrote:
> > Unless you have a very strong argument why this folio is invisible to
> > the rest of the world, including speculative accessors like compaction
> > (and the name "pagecache_folio" suggests very much the reverse): the
> > pattern of unlocking a lock when you see it locked is like (or worse
> > than) having no locking at all - it is potentially unlocking someone
> > else's lock.
>
> hugetlb_fault() locks 'pagecache_folio' and unlocks it after returning
> from hugetlb_wp().
> This patch introduces the possibility that hugetlb_wp() can also unlock it for
> the reasons explained.
> So, when hugetlb_wp() returns back to hugetlb_fault(), we
>
> 1) either still hold the lock (because hugetlb_fault() took it)
> 2) or we do not anymore because hugetlb_wp() unlocked it for us.
>
> So it is not that we are unlocking anything blindly, because if the lock
> is still 'taken' (folio_test_locked() returned true) it is because we,
> hugetlb_fault() took it and we are still holding it.
If we unlocked it, anyone else could have taken it immediately after.
Hugh
next prev parent reply other threads:[~2025-05-21 15:58 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 11:57 [PATCH v2] mm/hugetlb: fix a deadlock with pagecache_folio and hugetlb_fault_mutex_table Gavin Guo
2025-05-21 13:33 ` Oscar Salvador
2025-05-21 15:10 ` Hugh Dickins
2025-05-21 15:53 ` Oscar Salvador
2025-05-21 15:58 ` Hugh Dickins [this message]
2025-05-21 19:44 ` Oscar Salvador
2025-05-22 6:06 ` Gavin Guo
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=54bd3d6c-d763-ae09-6ee2-7ef192a97ca9@google.com \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=gavinguo@igalia.com \
--cc=gshan@redhat.com \
--cc=kernel-dev@igalia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=revest@google.com \
--cc=stable@vger.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;
as well as URLs for NNTP newsgroup(s).