The patch titled Subject: mm: migrate_device: use more folio in migrate_device_unmap() has been added to the -mm mm-unstable branch. Its filename is mm-migrate_device-use-more-folio-in-migrate_device_unmap.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-migrate_device-use-more-folio-in-migrate_device_unmap.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> Subject: mm: migrate_device: use more folio in migrate_device_unmap() Date: Mon, 26 Aug 2024 14:58:11 +0800 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@xxxxxxxxxx Signed-off-by: Kefeng Wang <wangkefeng.wang@xxxxxxxxxx> Acked-by: David Hildenbrand <david@xxxxxxxxxx> Reviewed-by: Vishal Moola (Oracle) <vishal.moola@xxxxxxxxx> Reviewed-by: Alistair Popple <apopple@xxxxxxxxxx> Cc: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx> Cc: Jonathan Corbet <corbet@xxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Zi Yan <ziy@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/migrate_device.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/mm/migrate_device.c~mm-migrate_device-use-more-folio-in-migrate_device_unmap +++ a/mm/migrate_device.c @@ -379,33 +379,33 @@ static unsigned long migrate_device_unma continue; } - /* ZONE_DEVICE pages are not on LRU */ - if (!is_zone_device_page(page)) { - if (!PageLRU(page) && allow_drain) { + folio = page_folio(page); + /* ZONE_DEVICE folios are not on LRU */ + if (!folio_is_zone_device(folio)) { + if (!folio_test_lru(folio) && allow_drain) { /* Drain CPU's lru cache */ lru_add_drain_all(); allow_drain = false; } - if (!isolate_lru_page(page)) { + if (!folio_isolate_lru(folio)) { src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; restore++; continue; } /* Drop the reference we took in collect */ - put_page(page); + folio_put(folio); } - folio = page_folio(page); if (folio_mapped(folio)) try_to_migrate(folio, 0); - if (page_mapped(page) || + if (folio_mapped(folio) || !migrate_vma_check_page(page, fault_page)) { - if (!is_zone_device_page(page)) { - get_page(page); - putback_lru_page(page); + if (!folio_is_zone_device(folio)) { + folio_get(folio); + folio_putback_lru(folio); } src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; _ Patches currently in -mm which might be from wangkefeng.wang@xxxxxxxxxx are mm-hugetlb-remove-left-over-comment-about-follow_huge_foo.patch mm-remove-migration-for-hugepage-in-isolate_single_pageblock.patch mm-memory_hotplug-remove-head-variable-in-do_migrate_range.patch mm-memory-failure-add-unmap_poisoned_folio.patch mm-memory_hotplug-check-hwpoisoned-page-firstly-in-do_migrate_range.patch mm-migrate-add-isolate_folio_to_list.patch mm-memory_hotplug-unify-huge-lru-non-lru-movable-folio-isolation.patch mm-migrate_device-convert-to-migrate_device_coherent_folio.patch mm-migrate_device-use-a-folio-in-migrate_device_range.patch mm-migrate_device-use-more-folio-in-migrate_device_unmap.patch mm-migrate_device-use-more-folio-in-migrate_device_finalize.patch mm-remove-isolate_lru_page.patch mm-remove-isolate_lru_page-fix.patch mm-remove-putback_lru_page.patch