[PATCH v2 6/6] mm/migrate_device: convert migrate_device_range() to folios

From: Sidhartha Kumar
Date: Fri Feb 16 2024 - 16:14:33 EST


Use pfn_folio() to get a folio and use the folio equivalent page
functions throughout migrate_device_range().

Signed-off-by: Sidhartha Kumar <sidhartha.kumar@xxxxxxxxxx>
---
mm/migrate_device.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 5c239de0f08b2..0c8d86851e631 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -888,16 +888,16 @@ 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 = pfn_folio(pfn);

- if (!get_page_unless_zero(page)) {
+ if (!folio_try_get(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;
}

--
2.42.0