diff mbox series

[rfc,2/9] mm: migrate_device: use more folio in __migrate_device_pages()

Message ID 20240129070934.3717659-3-wangkefeng.wang@huawei.com (mailing list archive)
State New
Headers show
Series mm: migrate: support poison recover from migrate folio | expand

Commit Message

Kefeng Wang Jan. 29, 2024, 7:09 a.m. UTC
Use newfolio/folio for migrate_folio_extra()/migrate_folio() to
save three compound_head() calls.

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

Comments

Matthew Wilcox Feb. 1, 2024, 7:27 p.m. UTC | #1
On Mon, Jan 29, 2024 at 03:09:27PM +0800, Kefeng Wang wrote:
> Use newfolio/folio for migrate_folio_extra()/migrate_folio() to
> save three compound_head() calls.

I've looked at this function before and I get stuck on the question of
whether a device page truly is a folio or not.  I think for the moment,
we've decided that it is, so ..

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>

Although ...

> @@ -729,13 +730,12 @@ static void __migrate_device_pages(unsigned long *src_pfns,
>  		}
>  
>  		mapping = page_mapping(page);
> +		folio = page_folio(page);
> +		newfolio = page_folio(newpage);

you should save one more call to compound_head() by changing the
page_mapping() to folio_mapping().
Kefeng Wang Feb. 2, 2024, 2:44 a.m. UTC | #2
On 2024/2/2 3:27, Matthew Wilcox wrote:
> On Mon, Jan 29, 2024 at 03:09:27PM +0800, Kefeng Wang wrote:
>> Use newfolio/folio for migrate_folio_extra()/migrate_folio() to
>> save three compound_head() calls.
> 
> I've looked at this function before and I get stuck on the question of
> whether a device page truly is a folio or not.  I think for the moment,
> we've decided that it is, so ..
> 
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> 
> Although ...
> 
>> @@ -729,13 +730,12 @@ static void __migrate_device_pages(unsigned long *src_pfns,
>>   		}
>>   
>>   		mapping = page_mapping(page);
>> +		folio = page_folio(page);
>> +		newfolio = page_folio(newpage);
> 
> you should save one more call to compound_head() by changing the
> page_mapping() to folio_mapping().

Missing this one, will update, thanks.
>
diff mbox series

Patch

diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index b6c27c76e1a0..d49a48d87d72 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -694,6 +694,7 @@  static void __migrate_device_pages(unsigned long *src_pfns,
 		struct page *newpage = migrate_pfn_to_page(dst_pfns[i]);
 		struct page *page = migrate_pfn_to_page(src_pfns[i]);
 		struct address_space *mapping;
+		struct folio *newfolio, *folio;
 		int r;
 
 		if (!newpage) {
@@ -729,13 +730,12 @@  static void __migrate_device_pages(unsigned long *src_pfns,
 		}
 
 		mapping = page_mapping(page);
+		folio = page_folio(page);
+		newfolio = page_folio(newpage);
 
-		if (is_device_private_page(newpage) ||
-		    is_device_coherent_page(newpage)) {
+		if (folio_is_device_private(newfolio) ||
+		    folio_is_device_coherent(newfolio)) {
 			if (mapping) {
-				struct folio *folio;
-
-				folio = page_folio(page);
 
 				/*
 				 * For now only support anonymous memory migrating to
@@ -749,7 +749,7 @@  static void __migrate_device_pages(unsigned long *src_pfns,
 					continue;
 				}
 			}
-		} else if (is_zone_device_page(newpage)) {
+		} else if (folio_is_zone_device(newfolio)) {
 			/*
 			 * Other types of ZONE_DEVICE page are not supported.
 			 */
@@ -758,12 +758,11 @@  static void __migrate_device_pages(unsigned long *src_pfns,
 		}
 
 		if (migrate && migrate->fault_page == page)
-			r = migrate_folio_extra(mapping, page_folio(newpage),
-						page_folio(page),
+			r = migrate_folio_extra(mapping, newfolio, folio,
 						MIGRATE_SYNC_NO_COPY, 1);
 		else
-			r = migrate_folio(mapping, page_folio(newpage),
-					page_folio(page), MIGRATE_SYNC_NO_COPY);
+			r = migrate_folio(mapping, newfolio, folio,
+					  MIGRATE_SYNC_NO_COPY);
 		if (r != MIGRATEPAGE_SUCCESS)
 			src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
 	}