From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Gregory Price <gourry@gourry.net>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, akpm@linux-foundation.org,
liam@infradead.org, david@kernel.org, vbabka@kernel.org,
jannh@google.com, sashiko-bot <sashiko-bot@kernel.org>
Subject: Re: [PATCH] mm/madvise: use folio_trylock() in the cold/pageout PMD split
Date: Fri, 21 Aug 2026 20:18:39 +0100 [thread overview]
Message-ID: <aoicRY6aG6I2ZAvg@gremlin> (raw)
In-Reply-To: <aoiap-yBdPaM_YQG@gourry-fedora-PF4VCD3F>
On Fri, Aug 21, 2026 at 02:42:01PM -0400, Gregory Price wrote:
> On Fri, Aug 21, 2026 at 07:23:34PM +0100, Lorenzo Stoakes (ARM) wrote:
> > On Fri, Aug 21, 2026 at 11:09:12AM -0400, Gregory Price wrote:
> >
> > I am _so_ glad to see an actual reproducer used in a sashiko bug fix. THANKS. :)
> >
>
> fwiw i try to produce reproducers on all my sashiko submitted fixes,
> i've just been dumb about including them in the changelog. Trying to
> fix that from now on.
>
> > > + if (!folio_trylock(folio))
> > > + goto huge_unlock;
> >
> > Doesn't this violate lock ordering?
> >
> > From rmap.c:
> >
> > folio_lock
> > ...
> > mm->page_table_lock or pte_lock
> >
> > So now you hold the ptl lock _before_ you obtain the folio lock?
> >
> > I'm not sure if it being a trylock gets us out of that particular situation? And
> > I'd be reticent for us to violate it... unless I'm missing something :)
> >
>
> This was the thing i was least sure about, but the deadlock condition
> should only happen if we tried to spin on the folio lock right?
>
> It does look weird, so it would be wrong of me to say i'm 100%
> confident this is the best change.
Hmm yeah. I worry about subtleties here.
I suppose you are avoiding what you'd obviously worry about with a PTL
lock/folio lock inversion causing a deadlock.
madvise_free_pte_range() seems to 'violate' this also with a trlock, seems
it's not an uncommon pattern.
I suppose the question is - what else is likely to lock this?
It does seem likely to be the race you flag in general.
So probably this is fine then.
And the window is relatively small also...
This kind of stuff gives me the heebie-jeebies :) I know that's not exactly
technical but there we go.
I guess there's just no other way of resolving this either.
That with the reproducer suggests this is fine then!
Since it scares me I think A-b rather than R-b ;)
Acked-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
>
> ~Gregory
--
Cheers, Lorenzo
next prev parent reply other threads:[~2026-08-21 19:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 15:09 [PATCH] mm/madvise: use folio_trylock() in the cold/pageout PMD split Gregory Price
2026-08-21 18:23 ` Lorenzo Stoakes (ARM)
2026-08-21 18:42 ` Gregory Price
2026-08-21 19:18 ` Lorenzo Stoakes (ARM) [this message]
2026-08-21 19:48 ` Matthew Wilcox
2026-08-21 20:38 ` Gregory Price
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=aoicRY6aG6I2ZAvg@gremlin \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=gourry@gourry.net \
--cc=jannh@google.com \
--cc=kernel-team@meta.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sashiko-bot@kernel.org \
--cc=vbabka@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.