On 5/21/25 23:58, Hugh Dickins wrote:
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
- either still hold the lock (because hugetlb_fault() took it)
- 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 _______________________________________________ Kernel-dev mailing list -- kernel-dev@igalia.com To unsubscribe send an email to kernel-dev-leave@igalia.com
Sigh, I should have thought of that as well. Next time, I'll be more careful.