linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Oscar Salvador <osalvador@suse.de>
To: David Hildenbrand <david@redhat.com>
Cc: Peter Xu <peterx@redhat.com>, Gavin Guo <gavinguo@igalia.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	muchun.song@linux.dev, akpm@linux-foundation.org,
	mike.kravetz@oracle.com, kernel-dev@igalia.com,
	stable@vger.kernel.org, Hugh Dickins <hughd@google.com>,
	Florent Revest <revest@google.com>, Gavin Shan <gshan@redhat.com>
Subject: Re: [PATCH v3] mm/hugetlb: fix a deadlock with pagecache_folio and hugetlb_fault_mutex_table
Date: Wed, 28 May 2025 17:45:42 +0200	[thread overview]
Message-ID: <aDcvplLNH0nGsLD1@localhost.localdomain> (raw)
In-Reply-To: <629bb87e-c493-4069-866c-20e02c14ddcc@redhat.com>

On Wed, May 28, 2025 at 05:09:26PM +0200, David Hildenbrand wrote:
> On 28.05.25 17:03, Peter Xu wrote:
> > So I'm not 100% sure we need the folio lock even for copy; IIUC a refcount
> > would be enough?
> 
> The introducing patches seem to talk about blocking concurrent migration /
> rmap walks.

I thought the main reason was because PageLock protects us against writes,
so when copying (in case of copying the underlying file), we want the
file to be stable throughout the copy?

> Maybe also concurrent fallocate(PUNCH_HOLE) is a problem regarding
> reservations? Not sure ...

fallocate()->hugetlb_vmdelete_list() tries to grab the vma in write-mode,
and hugetlb_wp() grabs the lock in read-mode, so we should be covered?

Also, hugetlbfs_punch_hole()->remove_inode_hugepages() will try to grab the mutex.

The only fishy thing I see is hugetlbfs_zero_partial_page().

But that is for old_page, and as I said, I thought main reason was to
protect us against writes during the copy.

> For 2) I am also not sure if we need need the pagecache folio locked; I
> doubt it ... but this code is not the easiest to follow.
 
I have been staring at that code and thinking about potential scenarios
for a few days now, and I cannot convice myself that we need
pagecache_folio's lock when pagecache_folio != old_folio because as a
matter of fact I cannot think of anything it protects us against.

I plan to rework this in a more sane way, or at least less offusctaed, and then
Galvin can fire his syzkaller to check whether we are good.

-- 
Oscar Salvador
SUSE Labs


  reply	other threads:[~2025-05-28 15:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-28  2:33 [PATCH v3] mm/hugetlb: fix a deadlock with pagecache_folio and hugetlb_fault_mutex_table Gavin Guo
2025-05-28  9:27 ` Oscar Salvador
2025-05-28 15:03   ` Peter Xu
2025-05-28 15:09     ` David Hildenbrand
2025-05-28 15:45       ` Oscar Salvador [this message]
2025-05-28 16:14         ` James Houghton
2025-05-28 16:24           ` Peter Xu
2025-05-28 16:16         ` Peter Xu
2025-05-28 20:00         ` David Hildenbrand
2025-05-28 20:26           ` David Hildenbrand
2025-05-28 21:34             ` Oscar Salvador

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=aDcvplLNH0nGsLD1@localhost.localdomain \
    --to=osalvador@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=gavinguo@igalia.com \
    --cc=gshan@redhat.com \
    --cc=hughd@google.com \
    --cc=kernel-dev@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=muchun.song@linux.dev \
    --cc=peterx@redhat.com \
    --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).