diff mbox series

[v1,02/11] mm: migrate_device: use more folio in __migrate_device_pages()

Message ID 20240321032747.87694-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 March 21, 2024, 3:27 a.m. UTC
Use newfolio/folio for migrate_folio_extra()/migrate_folio() to
save four compound_head() calls.

Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
 mm/migrate_device.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Comments

Vishal Moola April 1, 2024, 6:22 p.m. UTC | #1
On Thu, Mar 21, 2024 at 11:27:38AM +0800, Kefeng Wang wrote:
>  
>  		if (!newpage) {
> @@ -728,14 +729,13 @@ static void __migrate_device_pages(unsigned long *src_pfns,
>  			continue;
>  		}
>  
> -		mapping = page_mapping(page);
> +		newfolio = page_folio(newpage);

You could save another compound_head() call by passing the folio through
to migrate_vma_insert_page() and make it migrate_vma_insert_folio(),
since its already converted to use folios.

> +		folio = page_folio(page);
> +		mapping = folio_mapping(folio);
>
Kefeng Wang April 2, 2024, 6:21 a.m. UTC | #2
On 2024/4/2 2:22, Vishal Moola wrote:
> On Thu, Mar 21, 2024 at 11:27:38AM +0800, Kefeng Wang wrote:
>>   
>>   		if (!newpage) {
>> @@ -728,14 +729,13 @@ static void __migrate_device_pages(unsigned long *src_pfns,
>>   			continue;
>>   		}
>>   
>> -		mapping = page_mapping(page);
>> +		newfolio = page_folio(newpage);
> 
> You could save another compound_head() call by passing the folio through
> to migrate_vma_insert_page() and make it migrate_vma_insert_folio(),
> since its already converted to use folios.

Sure, but let's do it later, we could convert more functions in 
migrate_device.c to use folios, thanks for your review, do you
mind to help to review other patches, hope that the poison recover
from migrate folio was merged firstly.

> 
>> +		folio = page_folio(page);
>> +		mapping = folio_mapping(folio);
>>   
>
Vishal Moola April 2, 2024, 3:54 p.m. UTC | #3
On Mon, Apr 1, 2024 at 11:21 PM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>
>
>
> On 2024/4/2 2:22, Vishal Moola wrote:
> > On Thu, Mar 21, 2024 at 11:27:38AM +0800, Kefeng Wang wrote:
> >>
> >>              if (!newpage) {
> >> @@ -728,14 +729,13 @@ static void __migrate_device_pages(unsigned long *src_pfns,
> >>                      continue;
> >>              }
> >>
> >> -            mapping = page_mapping(page);
> >> +            newfolio = page_folio(newpage);
> >
> > You could save another compound_head() call by passing the folio through
> > to migrate_vma_insert_page() and make it migrate_vma_insert_folio(),
> > since its already converted to use folios.
>
> Sure, but let's do it later, we could convert more functions in
> migrate_device.c to use folios, thanks for your review, do you

Makes sense to me. This patch looks fine to me:
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>

> mind to help to review other patches, hope that the poison recover
> from migrate folio was merged firstly.

I'll take a look at it, I'm not too familiar with how that code works just
yet.

> >
> >> +            folio = page_folio(page);
> >> +            mapping = folio_mapping(folio);
> >>
> >
Kefeng Wang April 3, 2024, 1:23 a.m. UTC | #4
On 2024/4/2 23:54, Vishal Moola wrote:
> On Mon, Apr 1, 2024 at 11:21 PM Kefeng Wang <wangkefeng.wang@huawei.com> wrote:
>>
>>
>>
>> On 2024/4/2 2:22, Vishal Moola wrote:
>>> On Thu, Mar 21, 2024 at 11:27:38AM +0800, Kefeng Wang wrote:
>>>>
>>>>               if (!newpage) {
>>>> @@ -728,14 +729,13 @@ static void __migrate_device_pages(unsigned long *src_pfns,
>>>>                       continue;
>>>>               }
>>>>
>>>> -            mapping = page_mapping(page);
>>>> +            newfolio = page_folio(newpage);
>>>
>>> You could save another compound_head() call by passing the folio through
>>> to migrate_vma_insert_page() and make it migrate_vma_insert_folio(),
>>> since its already converted to use folios.
>>
>> Sure, but let's do it later, we could convert more functions in
>> migrate_device.c to use folios, thanks for your review, do you
> 
> Makes sense to me. This patch looks fine to me:
> Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
> 

Thanks,

>> mind to help to review other patches, hope that the poison recover
>> from migrate folio was merged firstly.
> 
> I'll take a look at it, I'm not too familiar with how that code works just
> yet.

That's great.

> 
>>>
>>>> +            folio = page_folio(page);
>>>> +            mapping = folio_mapping(folio);
>>>>
>>>
Miaohe Lin April 16, 2024, 12:13 p.m. UTC | #5
On 2024/3/21 11:27, Kefeng Wang wrote:
> Use newfolio/folio for migrate_folio_extra()/migrate_folio() to
> save four compound_head() calls.
> 
> Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---

Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Thanks.
.
diff mbox series

Patch

diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index b6c27c76e1a0..ee4d60951670 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) {
@@ -728,14 +729,13 @@  static void __migrate_device_pages(unsigned long *src_pfns,
 			continue;
 		}
 
-		mapping = page_mapping(page);
+		newfolio = page_folio(newpage);
+		folio = page_folio(page);
+		mapping = folio_mapping(folio);
 
-		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;
 	}