diff options
author | Kefeng Wang <wangkefeng.wang@huawei.com> | 2024-08-26 08:58:10 +0200 |
---|---|---|
committer | Andrew Morton <akpm@linux-foundation.org> | 2024-09-10 01:38:58 +0200 |
commit | 53456b7b3f4c3427ff04ae5c92e6dba1b9bfbb23 (patch) | |
tree | 89e97d12a0c6e7599d30b496cb73c4352ab3bbab /mm/migrate_device.c | |
parent | mm: migrate_device: convert to migrate_device_coherent_folio() (diff) | |
download | linux-53456b7b3f4c3427ff04ae5c92e6dba1b9bfbb23.tar.xz linux-53456b7b3f4c3427ff04ae5c92e6dba1b9bfbb23.zip |
mm: migrate_device: use a folio in migrate_device_range()
Save two calls to compound_head() and use folio throughout.
Link: https://lkml.kernel.org/r/20240826065814.1336616-3-wangkefeng.wang@huawei.com
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
Acked-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
Reviewed-by: Alistair Popple <apopple@nvidia.com>
Cc: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to '')
-rw-r--r-- | mm/migrate_device.c | 9 |
1 files 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; } |