From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Alistair Popple <apopple@nvidia.com>, Zi Yan <ziy@nvidia.com>
Cc: Andrew Morton <akpm@linux-foundation.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 09:59:59 +0200 [thread overview]
Message-ID: <1d9ce144-de5a-44ae-8021-98177b3f98a2@kernel.org> (raw)
In-Reply-To: <akWv6Yd2NHwAIMVS@nvdebian.thelocal>
On 7/2/26 02:33, Alistair Popple wrote:
> 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:
>>
>>>
>>> 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.
"migrate_vma_split_folio() consumes this reference" would be better indeed.
--
Cheers,
David
next prev parent reply other threads:[~2026-07-02 8:00 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
2026-07-02 7:59 ` David Hildenbrand (Arm) [this message]
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=1d9ce144-de5a-44ae-8021-98177b3f98a2@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=byungchul@sk.com \
--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 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.