From: Sidhartha Kumar <sidhartha.kumar@oracle.com>
To: linux-kernel@vger.kernel.org, linux-mm@kvack.org
Cc: akpm@linux-foundation.org, willy@infradead.org,
apopple@nvidia.com, Sidhartha Kumar <sidhartha.kumar@oracle.com>
Subject: [PATCH v2 4/6] mm/migrate_device: convert __migrate_device_pages() to folios
Date: Fri, 16 Feb 2024 13:13:18 -0800 [thread overview]
Message-ID: <20240216211320.222431-4-sidhartha.kumar@oracle.com> (raw)
In-Reply-To: <20240216211320.222431-1-sidhartha.kumar@oracle.com>
Use migrate_pfn_to_folio() so we can work with folios directly in
__migrate_device_pages().
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
mm/migrate_device.c | 36 +++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 81623f2d72c2b..d9633c7b1d21b 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -687,17 +687,17 @@ static void __migrate_device_pages(unsigned long *src_pfns,
bool notified = false;
for (i = 0; i < npages; i++) {
- struct page *newpage = migrate_pfn_to_page(dst_pfns[i]);
- struct page *page = migrate_pfn_to_page(src_pfns[i]);
+ struct folio *dst = migrate_pfn_to_folio(dst_pfns[i]);
+ struct folio *src = migrate_pfn_to_folio(src_pfns[i]);
struct address_space *mapping;
int r;
- if (!newpage) {
+ if (!dst) {
src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
continue;
}
- if (!page) {
+ if (!src) {
unsigned long addr;
if (!(src_pfns[i] & MIGRATE_PFN_MIGRATE))
@@ -719,33 +719,29 @@ static void __migrate_device_pages(unsigned long *src_pfns,
migrate->pgmap_owner);
mmu_notifier_invalidate_range_start(&range);
}
- migrate_vma_insert_page(migrate, addr, newpage,
+ migrate_vma_insert_page(migrate, addr, &dst->page,
&src_pfns[i]);
continue;
}
- mapping = page_mapping(page);
+ mapping = folio_mapping(src);
- if (is_device_private_page(newpage) ||
- is_device_coherent_page(newpage)) {
+ if (folio_is_device_private(dst) ||
+ folio_is_device_coherent(dst)) {
if (mapping) {
- struct folio *folio;
-
- folio = page_folio(page);
-
/*
* For now only support anonymous memory migrating to
* device private or coherent memory.
*
* Try to get rid of swap cache if possible.
*/
- if (!folio_test_anon(folio) ||
- !folio_free_swap(folio)) {
+ if (!folio_test_anon(src) ||
+ !folio_free_swap(src)) {
src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
continue;
}
}
- } else if (is_zone_device_page(newpage)) {
+ } else if (folio_is_zone_device(dst)) {
/*
* Other types of ZONE_DEVICE page are not supported.
*/
@@ -753,13 +749,11 @@ static void __migrate_device_pages(unsigned long *src_pfns,
continue;
}
- if (migrate && migrate->fault_page == page)
- r = migrate_folio_extra(mapping, page_folio(newpage),
- page_folio(page),
- MIGRATE_SYNC_NO_COPY, 1);
+ if (migrate && migrate->fault_page == &src->page)
+ r = migrate_folio_extra(mapping, dst, src,
+ MIGRATE_SYNC_NO_COPY, 1);
else
- r = migrate_folio(mapping, page_folio(newpage),
- page_folio(page), MIGRATE_SYNC_NO_COPY);
+ r = migrate_folio(mapping, dst, src, MIGRATE_SYNC_NO_COPY);
if (r != MIGRATEPAGE_SUCCESS)
src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
}
--
2.42.0
next prev parent reply other threads:[~2024-02-16 21:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 21:13 [PATCH v2 1/6] mm/migrate: introduce migrate_pfn_to_folio() Sidhartha Kumar
2024-02-16 21:13 ` [PATCH v2 2/6] mm/migrate_device: further convert migrate_device_unmap() to folios Sidhartha Kumar
2024-02-16 21:51 ` Matthew Wilcox
2024-02-16 21:13 ` [PATCH v2 3/6] mm/migrate_device: further convert migrate_device_finalize() " Sidhartha Kumar
2024-02-16 21:13 ` Sidhartha Kumar [this message]
2024-02-16 21:55 ` [PATCH v2 4/6] mm/migrate_device: convert __migrate_device_pages() " Matthew Wilcox
2024-02-16 22:00 ` Sidhartha Kumar
2024-02-16 23:19 ` Matthew Wilcox
2024-02-19 9:49 ` Alistair Popple
2024-02-16 21:13 ` [PATCH v2 5/6] mm/migrate_device: convert migrate_device_coherent_page() to migrate_device_coherent_folio() Sidhartha Kumar
2024-02-16 21:13 ` [PATCH v2 6/6] mm/migrate_device: convert migrate_device_range() to folios Sidhartha Kumar
2024-02-16 21:50 ` [PATCH v2 1/6] mm/migrate: introduce migrate_pfn_to_folio() Matthew Wilcox
2024-02-16 22:03 ` Sidhartha Kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240216211320.222431-4-sidhartha.kumar@oracle.com \
--to=sidhartha.kumar@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox