From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Hongfu Li <hongfu.li@linux.dev>,
akpm@linux-foundation.org, liam@infradead.org,
lihongfu@kylinos.cn, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, mhocko@suse.com, rppt@kernel.org,
surenb@google.com, vbabka@kernel.org
Subject: Re: [PATCH v4] mm: Use a folio in the softleaf_is_device_private path
Date: Tue, 18 Aug 2026 09:56:43 +0100 [thread overview]
Message-ID: <aoQXk1PmUDD2hxZF@lucifer> (raw)
In-Reply-To: <f27cc496-d9c8-4642-9d33-15c629623d1f@kernel.org>
On Tue, Aug 18, 2026 at 09:30:40AM +0200, David Hildenbrand (Arm) wrote:
> On 8/18/26 04:13, Hongfu Li wrote:
> >>> So after migrate_to_ram() the folio might have been split or otherwise somehow
> >>> the page doesn't belong to the same locked, refcount-incremented folio it did
> >>> before?
> >>
> >> I suspect a split.
> >>
> >>>
> >>> That's kinda a footgun... but this documents it at least.
> >>>
> >>> I think a comment explaining how this can happen would be helpful though as this
> >>> doesn't seem intuitive.
> >>
> >> I think, conceptually, calling into something that consumes a page (vmf->page)
> >> always needs care when operating on folios.
> >>
> >> Passing the vmf to some callback might be the odd thing here, because the
> >> vmf->page contract is not really clear.
> >
> > I'm very sorry for introducing this regression.
> > Thank you for identifying and testing this issue.
> >
> > I will double-check this code path and apply your fix to run further
> > tests locally.
> >
> > Would it make sense to add a comment here like the below, to make this
> > subtle behavior clearer for future readers?
> >
> > diff --git a/mm/memory.c b/mm/memory.c
> > index 4134ac607ee0..2b6d6c863ecb 100644
> > --- a/mm/memory.c
> > +++ b/mm/memory.c
> > @@ -4937,6 +4937,12 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
> > pte_unmap_unlock(vmf->pte, vmf->ptl);
> > pgmap = page_pgmap(vmf->page);
> > ret = pgmap->ops->migrate_to_ram(vmf);
> > + /*
> > + * migrate_to_ram() can split a large folio, updating
> > + * vmf->page to a different folio. Re-fetch folio for
> > + * correct unlock/put.
> > + */
>
> "migrate_to_ram() might have split the folio."
>
> Should be sufficient I guess.
Agreed, no need for a schloppy long comment here!
/* migrate_to_ram() might have split the folio. */
folio = page_folio(vmf->page);
Should be fine.
The commit message should be updated to reflect it too and mention that we are
going from 4 -> 2 compound_head()'s now.
>
> --
> Cheers,
>
> David
--
Cheers, Lorenzo
next prev parent reply other threads:[~2026-08-18 8:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-03 3:15 [PATCH v4] mm: Use a folio in the softleaf_is_device_private path Hongfu Li
2026-08-03 6:25 ` Anshuman Khandual
2026-08-17 15:52 ` David Hildenbrand (Arm)
2026-08-17 15:57 ` David Hildenbrand (Arm)
2026-08-17 16:39 ` Lorenzo Stoakes (ARM)
2026-08-17 17:45 ` David Hildenbrand (Arm)
2026-08-18 2:13 ` Hongfu Li
2026-08-18 7:30 ` David Hildenbrand (Arm)
2026-08-18 8:56 ` Lorenzo Stoakes (ARM) [this message]
2026-08-18 9:50 ` Hongfu Li
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=aoQXk1PmUDD2hxZF@lucifer \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=hongfu.li@linux.dev \
--cc=liam@infradead.org \
--cc=lihongfu@kylinos.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--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;
as well as URLs for NNTP newsgroup(s).