* [PATCH 1/3] mm/migrate: rename page to folio leftovers
2026-06-26 9:37 [PATCH 0/3] mm/migrate: preparatory cleanups for batch copy and offload Shivank Garg
@ 2026-06-26 9:37 ` Shivank Garg
2026-06-26 16:10 ` David Hildenbrand (Arm)
2026-06-26 9:37 ` [PATCH 2/3] mm/migrate: fix stale list name in migrate_folios_move() comment Shivank Garg
2026-06-26 9:37 ` [PATCH 3/3] mm/migrate: use migrate_info field instead of private Shivank Garg
2 siblings, 1 reply; 10+ messages in thread
From: Shivank Garg @ 2026-06-26 9:37 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Zi Yan, Matthew Brost,
Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
Cc: linux-mm, linux-kernel, Shivank Garg, Dev Jain
Rename migrate_folio_undo_src()'s page_was_mapped parameter to
folio_was_mapped, matching FOLIO_WAS_MAPPED naming.
Also fix migrate_folio() kerneldoc to say "folio" instead of "page".
Suggested-by: Dev Jain <dev.jain@arm.com>
Signed-off-by: Shivank Garg <shivankg@amd.com>
---
mm/migrate.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index d9b23909d716..dd7dbd8d84a0 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -884,7 +884,7 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
* @mapping: The address_space containing the folio.
* @dst: The folio to migrate the data to.
* @src: The folio containing the current data.
- * @mode: How to migrate the page.
+ * @mode: How to migrate the folio.
*
* Common logic to directly migrate a single LRU folio suitable for
* folios that do not have private data.
@@ -1157,13 +1157,10 @@ static void __migrate_folio_extract(struct folio *dst,
}
/* Restore the source folio to the original state upon failure */
-static void migrate_folio_undo_src(struct folio *src,
- int page_was_mapped,
- struct anon_vma *anon_vma,
- bool locked,
- struct list_head *ret)
+static void migrate_folio_undo_src(struct folio *src, int folio_was_mapped,
+ struct anon_vma *anon_vma, bool locked, struct list_head *ret)
{
- if (page_was_mapped)
+ if (folio_was_mapped)
remove_migration_ptes(src, src, 0);
/* Drop an anon_vma reference if we took one */
if (anon_vma)
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 1/3] mm/migrate: rename page to folio leftovers
2026-06-26 9:37 ` [PATCH 1/3] mm/migrate: rename page to folio leftovers Shivank Garg
@ 2026-06-26 16:10 ` David Hildenbrand (Arm)
2026-06-26 16:42 ` Garg, Shivank
0 siblings, 1 reply; 10+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-26 16:10 UTC (permalink / raw)
To: Shivank Garg, Andrew Morton, Zi Yan, Matthew Brost, Joshua Hahn,
Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
Cc: linux-mm, linux-kernel, Dev Jain
On 6/26/26 11:37, Shivank Garg wrote:
> Rename migrate_folio_undo_src()'s page_was_mapped parameter to
> folio_was_mapped, matching FOLIO_WAS_MAPPED naming.
>
> Also fix migrate_folio() kerneldoc to say "folio" instead of "page".
>
> Suggested-by: Dev Jain <dev.jain@arm.com>
> Signed-off-by: Shivank Garg <shivankg@amd.com>
> ---
> mm/migrate.c | 11 ++++-------
> 1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index d9b23909d716..dd7dbd8d84a0 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -884,7 +884,7 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
> * @mapping: The address_space containing the folio.
> * @dst: The folio to migrate the data to.
> * @src: The folio containing the current data.
> - * @mode: How to migrate the page.
> + * @mode: How to migrate the folio.
> *
> * Common logic to directly migrate a single LRU folio suitable for
> * folios that do not have private data.
> @@ -1157,13 +1157,10 @@ static void __migrate_folio_extract(struct folio *dst,
> }
>
> /* Restore the source folio to the original state upon failure */
> -static void migrate_folio_undo_src(struct folio *src,
> - int page_was_mapped,
> - struct anon_vma *anon_vma,
> - bool locked,
> - struct list_head *ret)
> +static void migrate_folio_undo_src(struct folio *src, int folio_was_mapped,
> + struct anon_vma *anon_vma, bool locked, struct list_head *ret)
> {
> - if (page_was_mapped)
> + if (folio_was_mapped)
Why not "was_mapped" given that folio is part of the function name?
(it's also not "folio_locked") :)
--
Cheers,
David
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 1/3] mm/migrate: rename page to folio leftovers
2026-06-26 16:10 ` David Hildenbrand (Arm)
@ 2026-06-26 16:42 ` Garg, Shivank
2026-06-26 17:01 ` David Hildenbrand (Arm)
0 siblings, 1 reply; 10+ messages in thread
From: Garg, Shivank @ 2026-06-26 16:42 UTC (permalink / raw)
To: David Hildenbrand (Arm), Andrew Morton, Zi Yan, Matthew Brost,
Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
Cc: linux-mm, linux-kernel, Dev Jain
On 6/26/2026 9:40 PM, David Hildenbrand (Arm) wrote:
> On 6/26/26 11:37, Shivank Garg wrote:
>> Rename migrate_folio_undo_src()'s page_was_mapped parameter to
>> folio_was_mapped, matching FOLIO_WAS_MAPPED naming.
>>
>> Also fix migrate_folio() kerneldoc to say "folio" instead of "page".
>>
>> Suggested-by: Dev Jain <dev.jain@arm.com>
>> Signed-off-by: Shivank Garg <shivankg@amd.com>
>> ---
>> mm/migrate.c | 11 ++++-------
>> 1 file changed, 4 insertions(+), 7 deletions(-)
>>
>> diff --git a/mm/migrate.c b/mm/migrate.c
>> index d9b23909d716..dd7dbd8d84a0 100644
>> --- a/mm/migrate.c
>> +++ b/mm/migrate.c
>> @@ -884,7 +884,7 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
>> * @mapping: The address_space containing the folio.
>> * @dst: The folio to migrate the data to.
>> * @src: The folio containing the current data.
>> - * @mode: How to migrate the page.
>> + * @mode: How to migrate the folio.
>> *
>> * Common logic to directly migrate a single LRU folio suitable for
>> * folios that do not have private data.
>> @@ -1157,13 +1157,10 @@ static void __migrate_folio_extract(struct folio *dst,
>> }
>>
>> /* Restore the source folio to the original state upon failure */
>> -static void migrate_folio_undo_src(struct folio *src,
>> - int page_was_mapped,
>> - struct anon_vma *anon_vma,
>> - bool locked,
>> - struct list_head *ret)
>> +static void migrate_folio_undo_src(struct folio *src, int folio_was_mapped,
>> + struct anon_vma *anon_vma, bool locked, struct list_head *ret)
>> {
>> - if (page_was_mapped)
>> + if (folio_was_mapped)
>
> Why not "was_mapped" given that folio is part of the function name?
>
> (it's also not "folio_locked") :)
>
yes, makes sense. I'll use was_mapped.
While here, what's your opinion on unmap_and_move_huge_page()?
It also has local variable named page_was_mapped even though the function
is fully folio-based. The function name and comments still have "page".
Thanks,
Shivank
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 1/3] mm/migrate: rename page to folio leftovers
2026-06-26 16:42 ` Garg, Shivank
@ 2026-06-26 17:01 ` David Hildenbrand (Arm)
0 siblings, 0 replies; 10+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-26 17:01 UTC (permalink / raw)
To: Garg, Shivank, Andrew Morton, Zi Yan, Matthew Brost, Joshua Hahn,
Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
Cc: linux-mm, linux-kernel, Dev Jain
On 6/26/26 18:42, Garg, Shivank wrote:
>
>
> On 6/26/2026 9:40 PM, David Hildenbrand (Arm) wrote:
>> On 6/26/26 11:37, Shivank Garg wrote:
>>> Rename migrate_folio_undo_src()'s page_was_mapped parameter to
>>> folio_was_mapped, matching FOLIO_WAS_MAPPED naming.
>>>
>>> Also fix migrate_folio() kerneldoc to say "folio" instead of "page".
>>>
>>> Suggested-by: Dev Jain <dev.jain@arm.com>
>>> Signed-off-by: Shivank Garg <shivankg@amd.com>
>>> ---
>>> mm/migrate.c | 11 ++++-------
>>> 1 file changed, 4 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/mm/migrate.c b/mm/migrate.c
>>> index d9b23909d716..dd7dbd8d84a0 100644
>>> --- a/mm/migrate.c
>>> +++ b/mm/migrate.c
>>> @@ -884,7 +884,7 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
>>> * @mapping: The address_space containing the folio.
>>> * @dst: The folio to migrate the data to.
>>> * @src: The folio containing the current data.
>>> - * @mode: How to migrate the page.
>>> + * @mode: How to migrate the folio.
>>> *
>>> * Common logic to directly migrate a single LRU folio suitable for
>>> * folios that do not have private data.
>>> @@ -1157,13 +1157,10 @@ static void __migrate_folio_extract(struct folio *dst,
>>> }
>>>
>>> /* Restore the source folio to the original state upon failure */
>>> -static void migrate_folio_undo_src(struct folio *src,
>>> - int page_was_mapped,
>>> - struct anon_vma *anon_vma,
>>> - bool locked,
>>> - struct list_head *ret)
>>> +static void migrate_folio_undo_src(struct folio *src, int folio_was_mapped,
>>> + struct anon_vma *anon_vma, bool locked, struct list_head *ret)
>>> {
>>> - if (page_was_mapped)
>>> + if (folio_was_mapped)
>>
>> Why not "was_mapped" given that folio is part of the function name?
>>
>> (it's also not "folio_locked") :)
>>
>
> yes, makes sense. I'll use was_mapped.
>
> While here, what's your opinion on unmap_and_move_huge_page()?
> It also has local variable named page_was_mapped even though the function
> is fully folio-based. The function name and comments still have "page".
Ah, yeah ... please fix that.
And while at it, rename it to "unmap_and_move_hugetlb_folio". Thx :)
--
Cheers,
David
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/3] mm/migrate: fix stale list name in migrate_folios_move() comment
2026-06-26 9:37 [PATCH 0/3] mm/migrate: preparatory cleanups for batch copy and offload Shivank Garg
2026-06-26 9:37 ` [PATCH 1/3] mm/migrate: rename page to folio leftovers Shivank Garg
@ 2026-06-26 9:37 ` Shivank Garg
2026-06-26 16:12 ` David Hildenbrand (Arm)
2026-06-26 19:02 ` Zi Yan
2026-06-26 9:37 ` [PATCH 3/3] mm/migrate: use migrate_info field instead of private Shivank Garg
2 siblings, 2 replies; 10+ messages in thread
From: Shivank Garg @ 2026-06-26 9:37 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Zi Yan, Matthew Brost,
Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
Cc: linux-mm, linux-kernel, Shivank Garg
The return-value description in migrate_folios_move() still refers to
unmap_folios, but that list no longer exists. Update this name to
src_folios.
Signed-off-by: Shivank Garg <shivankg@amd.com>
---
mm/migrate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index dd7dbd8d84a0..84b4c24f9dac 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1738,7 +1738,7 @@ static void migrate_folios_move(struct list_head *src_folios,
/*
* The rules are:
* 0: folio will be freed
- * -EAGAIN: stay on the unmap_folios list
+ * -EAGAIN: stay on the src_folios list
* Other errno: put on ret_folios list
*/
switch (rc) {
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 2/3] mm/migrate: fix stale list name in migrate_folios_move() comment
2026-06-26 9:37 ` [PATCH 2/3] mm/migrate: fix stale list name in migrate_folios_move() comment Shivank Garg
@ 2026-06-26 16:12 ` David Hildenbrand (Arm)
2026-06-26 19:02 ` Zi Yan
1 sibling, 0 replies; 10+ messages in thread
From: David Hildenbrand (Arm) @ 2026-06-26 16:12 UTC (permalink / raw)
To: Shivank Garg, Andrew Morton, Zi Yan, Matthew Brost, Joshua Hahn,
Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
Cc: linux-mm, linux-kernel
On 6/26/26 11:37, Shivank Garg wrote:
> The return-value description in migrate_folios_move() still refers to
> unmap_folios, but that list no longer exists. Update this name to
> src_folios.
>
> Signed-off-by: Shivank Garg <shivankg@amd.com>
> ---
> mm/migrate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index dd7dbd8d84a0..84b4c24f9dac 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -1738,7 +1738,7 @@ static void migrate_folios_move(struct list_head *src_folios,
> /*
> * The rules are:
> * 0: folio will be freed
> - * -EAGAIN: stay on the unmap_folios list
> + * -EAGAIN: stay on the src_folios list
> * Other errno: put on ret_folios list
> */
> switch (rc) {
>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH 2/3] mm/migrate: fix stale list name in migrate_folios_move() comment
2026-06-26 9:37 ` [PATCH 2/3] mm/migrate: fix stale list name in migrate_folios_move() comment Shivank Garg
2026-06-26 16:12 ` David Hildenbrand (Arm)
@ 2026-06-26 19:02 ` Zi Yan
1 sibling, 0 replies; 10+ messages in thread
From: Zi Yan @ 2026-06-26 19:02 UTC (permalink / raw)
To: Shivank Garg, Andrew Morton, David Hildenbrand, Matthew Brost,
Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
Cc: linux-mm, linux-kernel
On Fri Jun 26, 2026 at 5:37 AM EDT, Shivank Garg wrote:
> The return-value description in migrate_folios_move() still refers to
> unmap_folios, but that list no longer exists. Update this name to
> src_folios.
>
> Signed-off-by: Shivank Garg <shivankg@amd.com>
> ---
> mm/migrate.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
LGTM.
Reviewed-by: Zi Yan <ziy@nvidia.com>
--
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/3] mm/migrate: use migrate_info field instead of private
2026-06-26 9:37 [PATCH 0/3] mm/migrate: preparatory cleanups for batch copy and offload Shivank Garg
2026-06-26 9:37 ` [PATCH 1/3] mm/migrate: rename page to folio leftovers Shivank Garg
2026-06-26 9:37 ` [PATCH 2/3] mm/migrate: fix stale list name in migrate_folios_move() comment Shivank Garg
@ 2026-06-26 9:37 ` Shivank Garg
2026-06-26 18:58 ` Zi Yan
2 siblings, 1 reply; 10+ messages in thread
From: Shivank Garg @ 2026-06-26 9:37 UTC (permalink / raw)
To: Andrew Morton, David Hildenbrand, Zi Yan, Matthew Brost,
Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
Cc: linux-mm, linux-kernel, Shivank Garg, Jonathan Cameron
Add an unsigned long migrate_info member to the struct folio union and
use it to store migration state (anon_vma pointer and FOLIO_WAS_*
markers) instead of using folio->private. While at it, switch to bitwise
OR.
No functional change.
Suggested-by: David Hildenbrand <david@kernel.org>
Reviewed-by: Jonathan Cameron <jic23@kernel.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Huang Ying <ying.huang@linux.alibaba.com>
Signed-off-by: Shivank Garg <shivankg@amd.com>
---
include/linux/mm_types.h | 1 +
mm/migrate.c | 14 +++++++-------
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index b18c2b2e7d2c..ae9bca4eda5c 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -427,6 +427,7 @@ struct folio {
union {
void *private;
swp_entry_t swap;
+ unsigned long migrate_info;
};
atomic_t _mapcount;
atomic_t _refcount;
diff --git a/mm/migrate.c b/mm/migrate.c
index 84b4c24f9dac..7a83032a14b5 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1130,7 +1130,7 @@ static int move_to_new_folio(struct folio *dst, struct folio *src,
}
/*
- * To record some information during migration, we use unused private
+ * To record some information during migration, we use the migrate_info
* field of struct folio of the newly allocated destination folio.
* This is safe because nobody is using it except us.
*/
@@ -1143,17 +1143,17 @@ enum {
static void __migrate_folio_record(struct folio *dst,
int old_folio_state, struct anon_vma *anon_vma)
{
- dst->private = (void *)anon_vma + old_folio_state;
+ dst->migrate_info = (unsigned long)anon_vma | old_folio_state;
}
static void __migrate_folio_extract(struct folio *dst,
int *old_folio_state, struct anon_vma **anon_vmap)
{
- unsigned long private = (unsigned long)dst->private;
+ unsigned long info = dst->migrate_info;
- *anon_vmap = (struct anon_vma *)(private & ~FOLIO_OLD_STATES);
- *old_folio_state = private & FOLIO_OLD_STATES;
- dst->private = NULL;
+ *anon_vmap = (struct anon_vma *)(info & ~FOLIO_OLD_STATES);
+ *old_folio_state = info & FOLIO_OLD_STATES;
+ dst->migrate_info = 0;
}
/* Restore the source folio to the original state upon failure */
@@ -1214,7 +1214,7 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
return -ENOMEM;
*dstp = dst;
- dst->private = NULL;
+ dst->migrate_info = 0;
if (!folio_trylock(src)) {
if (mode == MIGRATE_ASYNC)
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH 3/3] mm/migrate: use migrate_info field instead of private
2026-06-26 9:37 ` [PATCH 3/3] mm/migrate: use migrate_info field instead of private Shivank Garg
@ 2026-06-26 18:58 ` Zi Yan
0 siblings, 0 replies; 10+ messages in thread
From: Zi Yan @ 2026-06-26 18:58 UTC (permalink / raw)
To: Shivank Garg, Andrew Morton, David Hildenbrand, Matthew Brost,
Joshua Hahn, Rakie Kim, Byungchul Park, Gregory Price, Ying Huang,
Alistair Popple, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko
Cc: linux-mm, linux-kernel, Jonathan Cameron
On Fri Jun 26, 2026 at 5:37 AM EDT, Shivank Garg wrote:
> Add an unsigned long migrate_info member to the struct folio union and
> use it to store migration state (anon_vma pointer and FOLIO_WAS_*
> markers) instead of using folio->private. While at it, switch to bitwise
> OR.
>
> No functional change.
>
> Suggested-by: David Hildenbrand <david@kernel.org>
> Reviewed-by: Jonathan Cameron <jic23@kernel.org>
> Acked-by: David Hildenbrand (Arm) <david@kernel.org>
> Reviewed-by: Huang Ying <ying.huang@linux.alibaba.com>
> Signed-off-by: Shivank Garg <shivankg@amd.com>
> ---
> include/linux/mm_types.h | 1 +
> mm/migrate.c | 14 +++++++-------
> 2 files changed, 8 insertions(+), 7 deletions(-)
>
LGTM.
Acked-by: Zi Yan <ziy@nvidia.com>
--
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 10+ messages in thread