diff mbox series

[3/5] mm: migrate_device: unify migrate folio for MIGRATE_SYNC_NO_COPY

Message ID 20240524052843.182275-4-wangkefeng.wang@huawei.com (mailing list archive)
State New
Headers show
Series mm: cleanup MIGRATE_SYNC_NO_COPY mode | expand

Commit Message

Kefeng Wang May 24, 2024, 5:28 a.m. UTC
The __migrate_device_pages() won't copy page so MIGRATE_SYNC_NO_COPY
passed into migrate_folio()/migrate_folio_extra(), actually a easy
way is just to call folio_migrate_mapping()/folio_migrate_flags(),
converting it to unify and simplify the migrate device pages, which
also remove the only call for MIGRATE_SYNC_NO_COPY.

Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/migrate_device.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Jane Chu June 7, 2024, 8:23 p.m. UTC | #1
On 5/23/2024 10:28 PM, Kefeng Wang wrote:

> The __migrate_device_pages() won't copy page so MIGRATE_SYNC_NO_COPY
> passed into migrate_folio()/migrate_folio_extra(), actually a easy
> way is just to call folio_migrate_mapping()/folio_migrate_flags(),
> converting it to unify and simplify the migrate device pages, which
> also remove the only call for MIGRATE_SYNC_NO_COPY.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>   mm/migrate_device.c | 13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
> index f5e034de718a..051d0a3ccbee 100644
> --- a/mm/migrate_device.c
> +++ b/mm/migrate_device.c
> @@ -693,7 +693,7 @@ static void __migrate_device_pages(unsigned long *src_pfns,
>   		struct page *page = migrate_pfn_to_page(src_pfns[i]);
>   		struct address_space *mapping;
>   		struct folio *newfolio, *folio;
> -		int r;
> +		int r, extra_cnt = 0;
>   
>   		if (!newpage) {
>   			src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
> @@ -754,14 +754,15 @@ static void __migrate_device_pages(unsigned long *src_pfns,
>   			continue;
>   		}
>   
> +		BUG_ON(folio_test_writeback(folio));
> +
>   		if (migrate && migrate->fault_page == page)
> -			r = migrate_folio_extra(mapping, newfolio, folio,
> -						MIGRATE_SYNC_NO_COPY, 1);
> -		else
> -			r = migrate_folio(mapping, newfolio, folio,
> -					  MIGRATE_SYNC_NO_COPY);
> +			extra_cnt = 1;
> +		r = folio_migrate_mapping(mapping, newfolio, folio, extra_cnt);
>   		if (r != MIGRATEPAGE_SUCCESS)
>   			src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
> +		else
> +			folio_migrate_flags(newfolio, folio);
>   	}
>   
>   	if (notified)

No functionality change, looks good.

Reviewed-by:  Jane Chu <jane.chu@oracle.com>

-jane
diff mbox series

Patch

diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index f5e034de718a..051d0a3ccbee 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -693,7 +693,7 @@  static void __migrate_device_pages(unsigned long *src_pfns,
 		struct page *page = migrate_pfn_to_page(src_pfns[i]);
 		struct address_space *mapping;
 		struct folio *newfolio, *folio;
-		int r;
+		int r, extra_cnt = 0;
 
 		if (!newpage) {
 			src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
@@ -754,14 +754,15 @@  static void __migrate_device_pages(unsigned long *src_pfns,
 			continue;
 		}
 
+		BUG_ON(folio_test_writeback(folio));
+
 		if (migrate && migrate->fault_page == page)
-			r = migrate_folio_extra(mapping, newfolio, folio,
-						MIGRATE_SYNC_NO_COPY, 1);
-		else
-			r = migrate_folio(mapping, newfolio, folio,
-					  MIGRATE_SYNC_NO_COPY);
+			extra_cnt = 1;
+		r = folio_migrate_mapping(mapping, newfolio, folio, extra_cnt);
 		if (r != MIGRATEPAGE_SUCCESS)
 			src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
+		else
+			folio_migrate_flags(newfolio, folio);
 	}
 
 	if (notified)