mm/migrate_device: Try to handle swapcache pages
Subsystems (2)
PATCH v2 1/1 mm/migrate_device: Try to handle swapcache pages
From: Mika Penttilä <[email protected]>
Migrating file pages and swapcache pages into device memory is not supported. The decision is done based on page_mapping(). For now, swapcache pages are not migrated.
Things can however be improved, for swapcache pages. Try to get rid of the swap cache, and if successful, go ahead as with other anonymous pages.
---
v2:
- use folio_test_anon() (Huang, Ying)
mm/migrate_device.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
mm/migrate_device.c +18 -6
@@ -747,13 +747,25 @@ static void __migrate_device_pages(unsigned long *src_pfns,if (is_device_private_page (newpage) ||is_device_coherent_page (newpage)) { -/* -* For now only support anonymous memory migrating to -* device private or coherent memory. -*/ +if (mapping) { - src_pfns[i] &= ~MIGRATE_PFN_MIGRATE ; -continue ; +struct folio *folio; + + folio =page_folio (page); + +/* +* For now only support anonymous memory migrating to +* device private or coherent memory. +* +* Try to get rid of swap cache if possible. +* page is here file or swapcache page, could be shmem also +* folio_test_anon() filters out file and shmem +* +*/ +if (!folio_test_anon (folio) || !folio_free_swap (folio)) { + src_pfns[i] &= ~MIGRATE_PFN_MIGRATE ; +continue ; + } } }else if (is_zone_device_page (newpage)) {/*
Signature · 1 line
2.17.1
Quoted 37 lines · [email protected] writes:
From: Mika Penttilä <[email protected]>
Migrating file pages and swapcache pages into device memory is not supported. The decision is done based on
page_mapping(). For now, swapcache pages are not migrated.Things can however be improved, for swapcache pages. Try to get rid of the swap cache, and if successful, go ahead as with other anonymous pages.
Cc Alistair Popple <[email protected]>Cc John Hubbard <[email protected]>Cc Ralph Campbell <[email protected]>Cc Huang Ying <[email protected]>Signed-off-by Mika Penttilä <[email protected]>---
v2:
- usefolio_test_anon()(Huang, Ying)mm/migrate_device.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)mm/migrate_device.c +1
-5@@ -747,13 +747,25 @@ static void __migrate_device_pages(unsigned long *src_pfns,if (is_device_private_page (newpage) ||is_device_coherent_page (newpage)) { -/* -* For now only support anonymous memory migrating to -* device private or coherent memory. -*/ +if (mapping) { - src_pfns[i] &= ~MIGRATE_PFN_MIGRATE ;
mm/migrate_device.c static void __migrate_device_pages(unsigned long *src_pfns, · line 760
Quoted 10 lines
mm/migrate_device.c +9
-1-continue ; +struct folio *folio; + + folio =page_folio (page); + +/* +* For now only support anonymous memory migrating to +* device private or coherent memory. +* +* Try to get rid of swap cache if possible.
I think we can delete the following 2 lines of comments. They add nothing except what code says already.
Otherwise looks good to me.
Quoted 11 lines
mm/migrate_device.c +8
-0+* page is here file or swapcache page, could be shmem also +* folio_test_anon() filters out file and shmem +* +*/ +if (!folio_test_anon (folio) || !folio_free_swap (folio)) { + src_pfns[i] &= ~MIGRATE_PFN_MIGRATE ; +continue ; + } } }else if (is_zone_device_page (newpage)) {/*
Quoted 44 lines · Ying
Quoted 42 lines · [email protected] writes:
From: Mika Penttilä <[email protected]>
Migrating file pages and swapcache pages into device memory is not supported. The decision is done based on
page_mapping(). For now, swapcache pages are not migrated.Things can however be improved, for swapcache pages. Try to get rid of the swap cache, and if successful, go ahead as with other anonymous pages.
Cc Alistair Popple <[email protected]>Cc John Hubbard <[email protected]>Cc Ralph Campbell <[email protected]>Cc Huang Ying <[email protected]>Signed-off-by Mika Penttilä <[email protected]>---
v2:
- usefolio_test_anon()(Huang, Ying)mm/migrate_device.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)mm/migrate_device.c +5
-6@@ -747,13 +747,25 @@ static void __migrate_device_pages(unsigned long *src_pfns,if (is_device_private_page (newpage) ||is_device_coherent_page (newpage)) { -/* -* For now only support anonymous memory migrating to -* device private or coherent memory. -*/ +if (mapping) { - src_pfns[i] &= ~MIGRATE_PFN_MIGRATE ; -continue ; +struct folio *folio; + + folio =page_folio (page); +
Quoted 8 lines
mm/migrate_device.c static void __migrate_device_pages(unsigned long *src_pfns, · line 760
Quoted 5 lines
mm/migrate_device.c +5
-0+/* +* For now only support anonymous memory migrating to +* device private or coherent memory. +* +* Try to get rid of swap cache if possible. I think we can delete the following 2 lines of comments. They add nothing except what code says already.
They are also a bit confusing, because a private file-backed mapping is treated as anonymous so folio_test_anon() won't filter those out.
I will test this tomorrow but the change looks good so please add:
Quoted 15 lines
Otherwise looks good to me.
Reviewed-by "Huang, Ying" <[email protected]>Quoted 11 lines
mm/migrate_device.c +8
-0+* page is here file or swapcache page, could be shmem also +* folio_test_anon() filters out file and shmem +* +*/ +if (!folio_test_anon (folio) || !folio_free_swap (folio)) { + src_pfns[i] &= ~MIGRATE_PFN_MIGRATE ; +continue ; + } } }else if (is_zone_device_page (newpage)) {/*