Skip to content

Commit b014eca

Browse files
author
Rafael Aquini
committed
mm: migrate_device: use more folio in migrate_device_unmap()
JIRA: https://issues.redhat.com/browse/RHEL-84184 JIRA: https://issues.redhat.com/browse/RHEL-83249 This patch is a backport of the following upstream commit: commit 39e618d Author: Kefeng Wang <wangkefeng.wang@huawei.com> Date: Mon Aug 26 14:58:11 2024 +0800 mm: migrate_device: use more folio in migrate_device_unmap() The page for migrate_device_unmap() already has a reference, so it is safe to convert the page to folio to save a few calls to compound_head(), which removes the last isolate_lru_page() call. Link: https://lkml.kernel.org/r/20240826065814.1336616-4-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> Signed-off-by: Rafael Aquini <raquini@redhat.com>
1 parent eb64fc6 commit b014eca

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

mm/migrate_device.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,33 +374,33 @@ static unsigned long migrate_device_unmap(unsigned long *src_pfns,
374374
continue;
375375
}
376376

377-
/* ZONE_DEVICE pages are not on LRU */
378-
if (!is_zone_device_page(page)) {
379-
if (!PageLRU(page) && allow_drain) {
377+
folio = page_folio(page);
378+
/* ZONE_DEVICE folios are not on LRU */
379+
if (!folio_is_zone_device(folio)) {
380+
if (!folio_test_lru(folio) && allow_drain) {
380381
/* Drain CPU's lru cache */
381382
lru_add_drain_all();
382383
allow_drain = false;
383384
}
384385

385-
if (!isolate_lru_page(page)) {
386+
if (!folio_isolate_lru(folio)) {
386387
src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
387388
restore++;
388389
continue;
389390
}
390391

391392
/* Drop the reference we took in collect */
392-
put_page(page);
393+
folio_put(folio);
393394
}
394395

395-
folio = page_folio(page);
396396
if (folio_mapped(folio))
397397
try_to_migrate(folio, 0);
398398

399-
if (page_mapped(page) ||
399+
if (folio_mapped(folio) ||
400400
!migrate_vma_check_page(page, fault_page)) {
401-
if (!is_zone_device_page(page)) {
402-
get_page(page);
403-
putback_lru_page(page);
401+
if (!folio_is_zone_device(folio)) {
402+
folio_get(folio);
403+
folio_putback_lru(folio);
404404
}
405405

406406
src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;

0 commit comments

Comments
 (0)