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 2/6] mm/migrate_device: further convert migrate_device_unmap() to folios
Date: Fri, 16 Feb 2024 13:13:16 -0800 [thread overview]
Message-ID: <20240216211320.222431-2-sidhartha.kumar@oracle.com> (raw)
In-Reply-To: <20240216211320.222431-1-sidhartha.kumar@oracle.com>
migrate_device_unmap() already has a folio, we can use the folio
versions of is_zone_device_page() and putback_lru_page.
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
v1 -> v2:
use migrate_pfn_to_folio() to directly work with a folio
per Alistair Popple.
mm/migrate_device.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index b6c27c76e1a0b..3d3c2593b5b64 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -368,42 +368,40 @@ static unsigned long migrate_device_unmap(unsigned long *src_pfns,
lru_add_drain();
for (i = 0; i < npages; i++) {
- struct page *page = migrate_pfn_to_page(src_pfns[i]);
- struct folio *folio;
+ struct folio *folio = migrate_pfn_to_folio(src_pfns[i]);
- if (!page) {
+ if (!folio) {
if (src_pfns[i] & MIGRATE_PFN_MIGRATE)
unmapped++;
continue;
}
/* ZONE_DEVICE pages are not on LRU */
- if (!is_zone_device_page(page)) {
- if (!PageLRU(page) && allow_drain) {
+ 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) ||
- !migrate_vma_check_page(page, fault_page)) {
- if (!is_zone_device_page(page)) {
- get_page(page);
- putback_lru_page(page);
+ if (folio_mapped(folio) ||
+ !migrate_vma_check_page(&folio->page, fault_page)) {
+ if (!folio_is_zone_device(folio)) {
+ folio_get(folio);
+ folio_putback_lru(folio);
}
src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
@@ -415,13 +413,11 @@ static unsigned long migrate_device_unmap(unsigned long *src_pfns,
}
for (i = 0; i < npages && restore; i++) {
- struct page *page = migrate_pfn_to_page(src_pfns[i]);
- struct folio *folio;
+ struct folio *folio = migrate_pfn_to_folio(src_pfns[i]);
- if (!page || (src_pfns[i] & MIGRATE_PFN_MIGRATE))
+ if (!folio || (src_pfns[i] & MIGRATE_PFN_MIGRATE))
continue;
- folio = page_folio(page);
remove_migration_ptes(folio, folio, false);
src_pfns[i] = 0;
--
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 ` Sidhartha Kumar [this message]
2024-02-16 21:51 ` [PATCH v2 2/6] mm/migrate_device: further convert migrate_device_unmap() to folios 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 ` [PATCH v2 4/6] mm/migrate_device: convert __migrate_device_pages() " Sidhartha Kumar
2024-02-16 21:55 ` 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-2-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