[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aC33A65HFJOSO1_R@localhost.localdomain>
Date: Wed, 21 May 2025 17:53:39 +0200
From: Oscar Salvador <osalvador@...e.de>
To: Hugh Dickins <hughd@...gle.com>
Cc: Gavin Guo <gavinguo@...lia.com>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, muchun.song@...ux.dev,
akpm@...ux-foundation.org, mike.kravetz@...cle.com,
kernel-dev@...lia.com, stable@...r.kernel.org,
Florent Revest <revest@...gle.com>, Gavin Shan <gshan@...hat.com>
Subject: Re: [PATCH v2] mm/hugetlb: fix a deadlock with pagecache_folio and
hugetlb_fault_mutex_table
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.
--
Oscar Salvador
SUSE Labs
Powered by blists - more mailing lists