Re: [PATCH] mm/migrate_device: pin large folios before splitting

From: Zi Yan

Date: Wed Jul 01 2026 - 16:19:23 EST


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@xxxxxxxxxx> 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?”.

Best Regards,
Yan, Zi