The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Alistair Popple <apopple@nvidia.com>
To: Zi Yan <ziy@nvidia.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 "David Hildenbrand (Arm)" <david@kernel.org>,
	Usama Arif <usama.arif@linux.dev>,
	byungchul@sk.com,  gourry@gourry.net, joshua.hahnjy@gmail.com,
	linux-kernel@vger.kernel.org,  linux-mm@kvack.org,
	matthew.brost@intel.com, rakie.kim@sk.com,
	 ying.huang@linux.alibaba.com, shakeel.butt@linux.dev,
	hannes@cmpxchg.org, kernel-team@meta.com,
	 sashiko-bot <sashiko-bot@kernel.org>
Subject: Re: [PATCH] mm/migrate_device: pin large folios before splitting
Date: Thu, 2 Jul 2026 10:33:28 +1000	[thread overview]
Message-ID: <akWv6Yd2NHwAIMVS@nvdebian.thelocal> (raw)
In-Reply-To: <C3D3519D-0D57-45C8-B6C4-64731E9021F8@nvidia.com>

On 2026-07-02 at 06:16 +1000, Zi Yan <ziy@nvidia.com> wrote...
> On 1 Jul 2026, at 16:06, David Hildenbrand (Arm) wrote:
> 
> > On 7/1/26 21:27, Andrew Morton wrote:
> >> On Wed, 01 Jul 2026 13:02:10 -0400 Zi Yan <ziy@nvidia.com> wrote:
> >>
> >>> LGTM. Like David said, the comments might not be needed. Thanks.
> >>
> >> I like the comments!  They may be uninteresting to those who are
> >> already familiar with these things, but they aren't the target audience.
> >>
> >> How are others to become familiar, if not by this?
> >
> > I mean, it's one of the basic rules: if you lookup a page in the page table, the
> > moment you drop the lock that might be invalid.
> >
> > If we were to document that everywhere... this is not really the secret sauce we
> > want to document everywhere.
> 
> In this particular case, split_folio() is used in migrate_vma_split_folio()
> and split_folio() wraps __split_huge_page_to_list_to_order(), which documents
> the requirement of elevated folio reference. One who wants to get familiar
> with kernel code can be expected to chase down to
> __split_huge_page_to_list_to_order() and find the requirement.
> 
> With LLMs, it is probably as easy as asking “why is folio_get() needed here?”.

The interesting part of the comment isn't why the folio_get() is needed, it's
where the corresponding reference is dropped/returned. I've spent far too many
hours in this code trying to figure out why a page didn't migrate because of
a spurious refcount and it's not easy figuring out where the matching get/puts
occur.

So the comment could probably be condensed but I think it's valuable.

 - Alistair

> Best Regards,
> Yan, Zi

  reply	other threads:[~2026-07-02  0:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 14:06 [PATCH] mm/migrate_device: pin large folios before splitting Usama Arif
2026-07-01 16:49 ` David Hildenbrand (Arm)
2026-07-01 17:02 ` Zi Yan
2026-07-01 19:27   ` Andrew Morton
2026-07-01 20:06     ` David Hildenbrand (Arm)
2026-07-01 20:16       ` Zi Yan
2026-07-02  0:33         ` Alistair Popple [this message]
2026-07-02  7:59           ` David Hildenbrand (Arm)
2026-07-01 23:29 ` SJ Park
2026-07-02 10:47   ` Usama Arif
2026-07-02  4:45 ` Lance Yang
2026-07-02 10:56 ` Usama Arif

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=akWv6Yd2NHwAIMVS@nvdebian.thelocal \
    --to=apopple@nvidia.com \
    --cc=akpm@linux-foundation.org \
    --cc=byungchul@sk.com \
    --cc=david@kernel.org \
    --cc=gourry@gourry.net \
    --cc=hannes@cmpxchg.org \
    --cc=joshua.hahnjy@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.brost@intel.com \
    --cc=rakie.kim@sk.com \
    --cc=sashiko-bot@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=usama.arif@linux.dev \
    --cc=ying.huang@linux.alibaba.com \
    --cc=ziy@nvidia.com \
    /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