From: Kefeng Wang <wangkefeng.wang@huawei.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@redhat.com>,
Matthew Wilcox <willy@infradead.org>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Zi Yan <ziy@nvidia.com>, Alistair Popple <apopple@nvidia.com>,
Jonathan Corbet <corbet@lwn.net>, <linux-mm@kvack.org>,
Kefeng Wang <wangkefeng.wang@huawei.com>
Subject: [PATCH 1/6] mm: migrate_device: convert to migrate_device_coherent_folio()
Date: Mon, 26 Aug 2024 14:58:09 +0800 [thread overview]
Message-ID: <20240826065814.1336616-2-wangkefeng.wang@huawei.com> (raw)
In-Reply-To: <20240826065814.1336616-1-wangkefeng.wang@huawei.com>
Save few calls to compound_head() and use folio throughout.
Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
---
mm/gup.c | 2 +-
mm/internal.h | 2 +-
mm/migrate_device.c | 30 +++++++++++++++---------------
3 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index d19884e097fd..5defd5e6d8f8 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2335,7 +2335,7 @@ static int migrate_longterm_unpinnable_folios(
folio_get(folio);
gup_put_folio(folio, 1, FOLL_PIN);
- if (migrate_device_coherent_page(&folio->page)) {
+ if (migrate_device_coherent_folio(folio)) {
ret = -EBUSY;
goto err;
}
diff --git a/mm/internal.h b/mm/internal.h
index e1e139e412d1..0f4750f77f59 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -1209,7 +1209,7 @@ int numa_migrate_check(struct folio *folio, struct vm_fault *vmf,
int *last_cpupid);
void free_zone_device_folio(struct folio *folio);
-int migrate_device_coherent_page(struct page *page);
+int migrate_device_coherent_folio(struct folio *folio);
/*
* mm/gup.c
diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 6d66dc1c6ffa..82d75205dda8 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -708,7 +708,7 @@ static void __migrate_device_pages(unsigned long *src_pfns,
/*
* The only time there is no vma is when called from
- * migrate_device_coherent_page(). However this isn't
+ * migrate_device_coherent_folio(). However this isn't
* called if the page could not be unmapped.
*/
VM_BUG_ON(!migrate);
@@ -921,38 +921,38 @@ int migrate_device_range(unsigned long *src_pfns, unsigned long start,
EXPORT_SYMBOL(migrate_device_range);
/*
- * Migrate a device coherent page back to normal memory. The caller should have
- * a reference on page which will be copied to the new page if migration is
+ * Migrate a device coherent folio back to normal memory. The caller should have
+ * a reference on folio which will be copied to the new folio if migration is
* successful or dropped on failure.
*/
-int migrate_device_coherent_page(struct page *page)
+int migrate_device_coherent_folio(struct folio *folio)
{
unsigned long src_pfn, dst_pfn = 0;
- struct page *dpage;
+ struct folio *dfolio;
- WARN_ON_ONCE(PageCompound(page));
+ WARN_ON_ONCE(folio_test_large(folio));
- lock_page(page);
- src_pfn = migrate_pfn(page_to_pfn(page)) | MIGRATE_PFN_MIGRATE;
+ folio_lock(folio);
+ src_pfn = migrate_pfn(folio_pfn(folio)) | MIGRATE_PFN_MIGRATE;
/*
* We don't have a VMA and don't need to walk the page tables to find
- * the source page. So call migrate_vma_unmap() directly to unmap the
- * page as migrate_vma_setup() will fail if args.vma == NULL.
+ * the source folio. So call migrate_vma_unmap() directly to unmap the
+ * folio as migrate_vma_setup() will fail if args.vma == NULL.
*/
migrate_device_unmap(&src_pfn, 1, NULL);
if (!(src_pfn & MIGRATE_PFN_MIGRATE))
return -EBUSY;
- dpage = alloc_page(GFP_USER | __GFP_NOWARN);
- if (dpage) {
- lock_page(dpage);
- dst_pfn = migrate_pfn(page_to_pfn(dpage));
+ dfolio = folio_alloc(GFP_USER | __GFP_NOWARN, 0);
+ if (dfolio) {
+ folio_lock(dfolio);
+ dst_pfn = migrate_pfn(folio_pfn(dfolio));
}
migrate_device_pages(&src_pfn, &dst_pfn, 1);
if (src_pfn & MIGRATE_PFN_MIGRATE)
- copy_highpage(dpage, page);
+ folio_copy(dfolio, folio);
migrate_device_finalize(&src_pfn, &dst_pfn, 1);
if (src_pfn & MIGRATE_PFN_MIGRATE)
--
2.27.0
next prev parent reply other threads:[~2024-08-26 6:58 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-26 6:58 [PATCH 0/6] mm: finish isolate/putback_lru_page() Kefeng Wang
2024-08-26 6:58 ` Kefeng Wang [this message]
2024-08-26 15:04 ` [PATCH 1/6] mm: migrate_device: convert to migrate_device_coherent_folio() David Hildenbrand
2024-08-26 17:52 ` Vishal Moola
2024-08-27 5:42 ` Alistair Popple
2024-08-26 6:58 ` [PATCH 2/6] mm: migrate_device: use a folio in migrate_device_range() Kefeng Wang
2024-08-26 15:05 ` David Hildenbrand
2024-08-26 17:53 ` Vishal Moola
2024-08-27 5:46 ` Alistair Popple
2024-08-26 6:58 ` [PATCH 3/6] mm: migrate_device: use more folio in migrate_device_unmap() Kefeng Wang
2024-08-26 15:06 ` David Hildenbrand
2024-08-26 17:53 ` Vishal Moola
2024-08-27 5:47 ` Alistair Popple
2024-08-26 6:58 ` [PATCH 4/6] mm: migrate_device: use more folio in migrate_device_finalize() Kefeng Wang
2024-08-26 17:53 ` Vishal Moola
2024-08-27 5:48 ` Alistair Popple
2024-08-26 6:58 ` [PATCH 5/6] mm: remove isolate_lru_page() Kefeng Wang
2024-08-26 13:05 ` Matthew Wilcox
2024-08-26 13:52 ` Kefeng Wang
2024-08-26 14:41 ` [PATCH 5-fix/6] mm: remove isolate_lru_page() fix Kefeng Wang
2024-08-26 17:54 ` Vishal Moola
2024-08-26 6:58 ` [PATCH 6/6] mm: remove putback_lru_page() Kefeng Wang
2024-08-26 15:08 ` David Hildenbrand
2024-08-26 17:54 ` Vishal Moola
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=20240826065814.1336616-2-wangkefeng.wang@huawei.com \
--to=wangkefeng.wang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=corbet@lwn.net \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
--cc=ziy@nvidia.com \
/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;
as well as URLs for NNTP newsgroup(s).