Skip to content

Commit

Permalink
mm/migrate_device: try to handle swapcache pages
Browse files Browse the repository at this point in the history
Migrating file pages and swapcache pages into device memory is not
supported.  Try to get rid of the swap cache, and if successful, go ahead
as with other anonymous pages.

Link: https://lkml.kernel.org/r/20230607172944.11713-1-mpenttil@redhat.com
Signed-off-by: Mika Penttilä <mpenttil@redhat.com>
Reviewed-by: "Huang, Ying" <ying.huang@intel.com>
Reviewed-by: Alistair Popple <apopple@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Mika Penttilä authored and Andrew Morton committed Aug 18, 2023
1 parent d9cfaf4 commit df263d9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions mm/migrate_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,22 @@ 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.
*/
if (!folio_test_anon(folio) ||
!folio_free_swap(folio)) {
src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
continue;
}
}
} else if (is_zone_device_page(newpage)) {
/*
Expand Down

0 comments on commit df263d9

Please sign in to comment.