From: Gregory Price <gourry@gourry.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com, liam@infradead.org, ljs@kernel.org,
david@kernel.org, vbabka@kernel.org, jannh@google.com,
sashiko-bot <sashiko-bot@kernel.org>,
stable@vger.kernel.org
Subject: Re: [RESEND PATCH] mm/madvise: use folio_trylock() in the cold/pageout PMD split
Date: Tue, 15 Sep 2026 23:27:47 -0400 [thread overview]
Message-ID: <aqoKLlzgsMc7VwJ3@gourry-fedora-PF4VCD3F> (raw)
In-Reply-To: <20260915184633.e2d8cf719e5eed186d087a8a@linux-foundation.org>
On Tue, Sep 15, 2026 at 06:46:33PM -0700, Andrew Morton wrote:
> >
> > On failure the walker returns 0 and nothing retries. The PMD path becomes
> > best effort when the folio lock is held elsewhere - same as the PTE path.
>
> Can this result in more EAGAINs being returned to userspace?
>
I don't see where this can result in more EAGAIN, at least from the
madvise side. The race is the same, we're just giving up and saying
"I tried, doesn't matter if i succeeded".
> > --- a/mm/madvise.c
> > +++ b/mm/madvise.c
> > @@ -419,9 +419,10 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
> > if (next - addr != HPAGE_PMD_SIZE) {
> > int err;
> >
> > + if (!folio_trylock(folio))
> > + goto huge_unlock;
> > folio_get(folio);
> > spin_unlock(ptl);
> > - folio_lock(folio);
> > err = split_folio(folio);
> > folio_unlock(folio);
> > folio_put(folio);
>
> Sashiko shares my reaction, "dear god, why does that function exist".
>
> https://sashiko.dev/#/patchset/20260912110540.3203010-1-gourry@gourry.net
>
> Like the entire function, that random mix of "goto foo" with "return
> whatever" needs to die.
>
> Anyway, please check it out while you're on a roll.
I've been trying to shore up the sashiko garbage first in a backportable
manner before doing a full restructure.
I would hate to rewrite this just to carry bugs forward, and clearly the
code isn't even remotely correct as-is.
The remaining issue on that link is the memory leak patch you already
looked at.
It's taken a bit to generate positive tests for these bugs and go
through validation, but I think we are finally at the end of the
nasty part and can actually get to cleaning this up.
~Gregory
next prev parent reply other threads:[~2026-09-16 3:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 11:05 Gregory Price
2026-09-16 1:46 ` Andrew Morton
2026-09-16 3:27 ` Gregory Price [this message]
2026-09-16 6:25 ` David Hildenbrand (Arm)
2026-09-16 13:05 ` 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=aqoKLlzgsMc7VwJ3@gourry-fedora-PF4VCD3F \
--to=gourry@gourry.net \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--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=ljs@kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®