diff mbox series

[2/6] mm: migrate_device: use a folio in migrate_device_range()

Message ID 20240826065814.1336616-3-wangkefeng.wang@huawei.com (mailing list archive)
State New
Headers show
Series mm: finish isolate/putback_lru_page() | expand

Commit Message

Kefeng Wang Aug. 26, 2024, 6:58 a.m. UTC
Save two calls to compound_head() and use folio throughout.

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

Comments

David Hildenbrand Aug. 26, 2024, 3:05 p.m. UTC | #1
On 26.08.24 08:58, Kefeng Wang wrote:
> Save two calls to compound_head() and use folio throughout.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---

Acked-by: David Hildenbrand <david@redhat.com>
Vishal Moola Aug. 26, 2024, 5:53 p.m. UTC | #2
On Mon, Aug 26, 2024 at 02:58:10PM +0800, Kefeng Wang wrote:
> Save two calls to compound_head() and use folio throughout.
> 
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Alistair Popple Aug. 27, 2024, 5:46 a.m. UTC | #3
Kefeng Wang <wangkefeng.wang@huawei.com> writes:

> Save two calls to compound_head() and use folio throughout.
>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>

Reviewed-by: Alistair Popple <apopple@nvidia.com>

> ---
>  mm/migrate_device.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
> index 82d75205dda8..66db28b89f9b 100644
> --- a/mm/migrate_device.c
> +++ b/mm/migrate_device.c
> @@ -898,16 +898,17 @@ int migrate_device_range(unsigned long *src_pfns, unsigned long start,
>  	unsigned long i, pfn;
>  
>  	for (pfn = start, i = 0; i < npages; pfn++, i++) {
> -		struct page *page = pfn_to_page(pfn);
> +		struct folio *folio;
>  
> -		if (!get_page_unless_zero(page)) {
> +		folio = folio_get_nontail_page(pfn_to_page(pfn));
> +		if (!folio) {
>  			src_pfns[i] = 0;
>  			continue;
>  		}
>  
> -		if (!trylock_page(page)) {
> +		if (!folio_trylock(folio)) {
>  			src_pfns[i] = 0;
> -			put_page(page);
> +			folio_put(folio);
>  			continue;
>  		}
diff mbox series

Patch

diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 82d75205dda8..66db28b89f9b 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -898,16 +898,17 @@  int migrate_device_range(unsigned long *src_pfns, unsigned long start,
 	unsigned long i, pfn;
 
 	for (pfn = start, i = 0; i < npages; pfn++, i++) {
-		struct page *page = pfn_to_page(pfn);
+		struct folio *folio;
 
-		if (!get_page_unless_zero(page)) {
+		folio = folio_get_nontail_page(pfn_to_page(pfn));
+		if (!folio) {
 			src_pfns[i] = 0;
 			continue;
 		}
 
-		if (!trylock_page(page)) {
+		if (!folio_trylock(folio)) {
 			src_pfns[i] = 0;
-			put_page(page);
+			folio_put(folio);
 			continue;
 		}