Re: [PATCH v2] mm/migrate: rename PAGE_ migration flags to FOLIO_

From: Garg, Shivank

Date: Tue Mar 24 2026 - 15:08:15 EST




On 3/24/2026 7:08 PM, Zi Yan wrote:
> On 24 Mar 2026, at 7:47, Shivank Garg wrote:
>
>> These flags only track folio-specific state during migration and are
>> not used for movable_ops pages. Rename the enum values and the
>> old_page_state variable to match.
>>
>> No functional change.
>>
>> Suggested-by: David Hildenbrand <david@xxxxxxxxxx>
>> Signed-off-by: Shivank Garg <shivankg@xxxxxxx>
>> ---
>>
>> Applies cleanly on mm-new (02b045682c74).
>>
>> v1: https://lore.kernel.org/all/20260323141935.389232-3-shivankg@xxxxxxx
>>
>> v2:
>> - Rename FOLIO_MF_* to FOLIO_*, per feedback from Willy.
>>
>> mm/migrate.c | 46 +++++++++++++++++++++++-----------------------
>> 1 file changed, 23 insertions(+), 23 deletions(-)
>>
>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index 05cb408846f2..7dd6c2f2e1ef 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -1135,26 +1135,26 @@ static int move_to_new_folio(struct folio *dst, struct folio *src,
>> * This is safe because nobody is using it except us.
>> */
>> enum {
>> - PAGE_WAS_MAPPED = BIT(0),
>> - PAGE_WAS_MLOCKED = BIT(1),
>> - PAGE_OLD_STATES = PAGE_WAS_MAPPED | PAGE_WAS_MLOCKED,
>> + FOLIO_WAS_MAPPED = BIT(0),
>> + FOLIO_WAS_MLOCKED = BIT(1),
>> + FOLIO_OLD_STATES = FOLIO_WAS_MAPPED | FOLIO_WAS_MLOCKED,
>> };
>>
>> static void __migrate_folio_record(struct folio *dst,
>> - int old_page_state,
>> + int old_folio_state,
>> struct anon_vma *anon_vma)
>> {
>> - dst->private = (void *)anon_vma + old_page_state;
>> + dst->private = (void *)anon_vma + old_folio_state;
>> }
>>
>> static void __migrate_folio_extract(struct folio *dst,
>> - int *old_page_state,
>> + int *old_folio_state,
>> struct anon_vma **anon_vmap)
>> {
>> unsigned long private = (unsigned long)dst->private;
>>
>> - *anon_vmap = (struct anon_vma *)(private & ~PAGE_OLD_STATES);
>> - *old_page_state = private & PAGE_OLD_STATES;
>> + *anon_vmap = (struct anon_vma *)(private & ~FOLIO_OLD_STATES);
>> + *old_folio_state = private & FOLIO_OLD_STATES;
>> dst->private = NULL;
>> }
>
> Just an observation on folio->private, it is void*, but page->private
> is unsigned long. It confused me a bit. There are folio_get_private()
> and folio_change_private(), I wonder if we want to use them here
> instead of direct ->private accesses. Feel free to ignore this,
> since it is irrelevant to this patch.
>

Yeah, using folio_get_private() and folio_change_private() would be cleaner.
I'll keep it in mind as a follow-up cleanup but leaving this patch as a pure rename for now.

Thanks for suggestion.

> LGTM.
>
> Reviewed-by: Zi Yan <ziy@xxxxxxxxxx>

Thank you :)

Best regards,
Shivank