linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mm/migrate_device: Try to handle swapcache pages
@ 2023-05-31  4:40 mpenttil
  2023-05-31  7:24 ` Huang, Ying
  0 siblings, 1 reply; 2+ messages in thread
From: mpenttil @ 2023-05-31  4:40 UTC (permalink / raw)
  To: linux-kernel, linux-mm
  Cc: Mika Penttilä,
	Alistair Popple, John Hubbard, Ralph Campbell, Huang Ying

From: Mika Penttilä <mpenttil@redhat.com>

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 <apopple@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Huang Ying <ying.huang@intel.com>
Signed-off-by: Mika Penttilä <mpenttil@redhat.com>
---

v2:
  - use folio_test_anon() (Huang, Ying)

 
 mm/migrate_device.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index d30c9de60b0d..829bbc526758 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -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)) {
 			/*
-- 
2.17.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] mm/migrate_device: Try to handle swapcache pages
  2023-05-31  4:40 [PATCH v2] mm/migrate_device: Try to handle swapcache pages mpenttil
@ 2023-05-31  7:24 ` Huang, Ying
  0 siblings, 0 replies; 2+ messages in thread
From: Huang, Ying @ 2023-05-31  7:24 UTC (permalink / raw)
  To: mpenttil
  Cc: linux-kernel, linux-mm, Alistair Popple, John Hubbard, Ralph Campbell

mpenttil@redhat.com writes:

> From: Mika Penttilä <mpenttil@redhat.com>
>
> 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 <apopple@nvidia.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Ralph Campbell <rcampbell@nvidia.com>
> Cc: Huang Ying <ying.huang@intel.com>
> Signed-off-by: Mika Penttilä <mpenttil@redhat.com>
> ---
>
> v2:
>   - use folio_test_anon() (Huang, Ying)
>
>  
>  mm/migrate_device.c | 24 ++++++++++++++++++------
>  1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
> index d30c9de60b0d..829bbc526758 100644
> --- a/mm/migrate_device.c
> +++ b/mm/migrate_device.c
> @@ -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.

I think we can delete the following 2 lines of comments.  They add
nothing except what code says already.

Otherwise looks good to me.

Reviewed-by: "Huang, Ying" <ying.huang@intel.com>

> +				 * 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)) {
>  			/*


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-31  7:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31  4:40 [PATCH v2] mm/migrate_device: Try to handle swapcache pages mpenttil
2023-05-31  7:24 ` Huang, Ying

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).