Re: [PATCH] mm/gup: fix GUP-fast fallback for NULL-mapping order-0 folios

Zi Yan
2026-04-09T17:34:06Z

On 9 Apr 2026, at 13:31, David Hildenbrand (Arm) wrote:

> On 4/9/26 18:55, Zi Yan wrote:
>> On 9 Apr 2026, at 11:11, David Hildenbrand (Arm) wrote:
>>
>>> On 4/9/26 17:05, Zi Yan wrote:
>>>>
>>>>
>>>> The idea is to give every allocated page a NotRmappable page_type and
>>>> 1) let page_rmappable_folio() remove the page_type by setting mapcount
>>>> to 0, since page_type overlaps with mapcount;
>>>> 2) allow callers of alloc_page*() to change page_type from NotRmappable
>>>> to other types.
>>>
>>> Could we instead just set the special type in vm_insert_page(), after
>>> verifying that it does not have any other type?
>>
>> You mean in validate_page_before_insert() we set the page to NotRmappable
>> if it can be inserted, then in the rmap code we reject NotRmappable
>> page/folios? And NotRmappable will remain until the page/folio is freed.
>> That should work. So the purpose is to avoid setting the page_type if
>> a page/folio is never going through vm_insert_page()?
>
> Yes, only these non-folio pages will show up process page tables.
>
> We would add a safety check that the mapcount really is 0 (-1) or
> already the proper type (NotRmappable).
>
> Rmap code would then simply skip any such thing.

OK, I can give this a try in my new version.

Best Regards,
Yan, Zi