linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-fsdevel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	linux-aio@kvack.org, linux-btrfs@vger.kernel.org,
	linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com,
	linux-mm@kvack.org, linux-xfs@vger.kernel.org,
	linux-nfs@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net,
	ocfs2-devel@oss.oracle.com, linux-mtd@lists.infradead.org,
	virtualization@lists.linux-foundation.org
Subject: [PATCH v2 16/19] hugetlb: Convert to migrate_folio
Date: Wed,  8 Jun 2022 16:02:46 +0100	[thread overview]
Message-ID: <20220608150249.3033815-17-willy@infradead.org> (raw)
In-Reply-To: <20220608150249.3033815-1-willy@infradead.org>

This involves converting migrate_huge_page_move_mapping().  We also need a
folio variant of hugetlb_set_page_subpool(), but that's for a later patch.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/hugetlbfs/inode.c    | 23 ++++++++++++++---------
 include/linux/migrate.h |  6 +++---
 mm/migrate.c            | 18 +++++++++---------
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 14d33f725e05..eca1d0fabd7e 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -954,28 +954,33 @@ static int hugetlbfs_symlink(struct user_namespace *mnt_userns,
 	return error;
 }
 
-static int hugetlbfs_migrate_page(struct address_space *mapping,
-				struct page *newpage, struct page *page,
+#ifdef CONFIG_MIGRATION
+static int hugetlbfs_migrate_folio(struct address_space *mapping,
+				struct folio *dst, struct folio *src,
 				enum migrate_mode mode)
 {
 	int rc;
 
-	rc = migrate_huge_page_move_mapping(mapping, newpage, page);
+	rc = migrate_huge_page_move_mapping(mapping, dst, src);
 	if (rc != MIGRATEPAGE_SUCCESS)
 		return rc;
 
-	if (hugetlb_page_subpool(page)) {
-		hugetlb_set_page_subpool(newpage, hugetlb_page_subpool(page));
-		hugetlb_set_page_subpool(page, NULL);
+	if (hugetlb_page_subpool(&src->page)) {
+		hugetlb_set_page_subpool(&dst->page,
+					hugetlb_page_subpool(&src->page));
+		hugetlb_set_page_subpool(&src->page, NULL);
 	}
 
 	if (mode != MIGRATE_SYNC_NO_COPY)
-		migrate_page_copy(newpage, page);
+		folio_migrate_copy(dst, src);
 	else
-		migrate_page_states(newpage, page);
+		folio_migrate_flags(dst, src);
 
 	return MIGRATEPAGE_SUCCESS;
 }
+#else
+#define hugetlbfs_migrate_folio NULL
+#endif
 
 static int hugetlbfs_error_remove_page(struct address_space *mapping,
 				struct page *page)
@@ -1142,7 +1147,7 @@ static const struct address_space_operations hugetlbfs_aops = {
 	.write_begin	= hugetlbfs_write_begin,
 	.write_end	= hugetlbfs_write_end,
 	.dirty_folio	= noop_dirty_folio,
-	.migratepage    = hugetlbfs_migrate_page,
+	.migrate_folio  = hugetlbfs_migrate_folio,
 	.error_remove_page	= hugetlbfs_error_remove_page,
 };
 
diff --git a/include/linux/migrate.h b/include/linux/migrate.h
index 82f00ad69a54..59d64a1e6b4b 100644
--- a/include/linux/migrate.h
+++ b/include/linux/migrate.h
@@ -42,8 +42,8 @@ extern int isolate_movable_page(struct page *page, isolate_mode_t mode);
 
 extern void migrate_page_states(struct page *newpage, struct page *page);
 extern void migrate_page_copy(struct page *newpage, struct page *page);
-extern int migrate_huge_page_move_mapping(struct address_space *mapping,
-				  struct page *newpage, struct page *page);
+int migrate_huge_page_move_mapping(struct address_space *mapping,
+		struct folio *dst, struct folio *src);
 extern int migrate_page_move_mapping(struct address_space *mapping,
 		struct page *newpage, struct page *page, int extra_count);
 void migration_entry_wait_on_locked(swp_entry_t entry, pte_t *ptep,
@@ -74,7 +74,7 @@ static inline void migrate_page_copy(struct page *newpage,
 				     struct page *page) {}
 
 static inline int migrate_huge_page_move_mapping(struct address_space *mapping,
-				  struct page *newpage, struct page *page)
+				  struct folio *dst, struct folio *src)
 {
 	return -ENOSYS;
 }
diff --git a/mm/migrate.c b/mm/migrate.c
index 4d8115ca93bb..bed0de86f3ae 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -474,26 +474,26 @@ EXPORT_SYMBOL(folio_migrate_mapping);
  * of folio_migrate_mapping().
  */
 int migrate_huge_page_move_mapping(struct address_space *mapping,
-				   struct page *newpage, struct page *page)
+				   struct folio *dst, struct folio *src)
 {
-	XA_STATE(xas, &mapping->i_pages, page_index(page));
+	XA_STATE(xas, &mapping->i_pages, folio_index(src));
 	int expected_count;
 
 	xas_lock_irq(&xas);
-	expected_count = 2 + page_has_private(page);
-	if (!page_ref_freeze(page, expected_count)) {
+	expected_count = 2 + folio_has_private(src);
+	if (!folio_ref_freeze(src, expected_count)) {
 		xas_unlock_irq(&xas);
 		return -EAGAIN;
 	}
 
-	newpage->index = page->index;
-	newpage->mapping = page->mapping;
+	dst->index = src->index;
+	dst->mapping = src->mapping;
 
-	get_page(newpage);
+	folio_get(dst);
 
-	xas_store(&xas, newpage);
+	xas_store(&xas, dst);
 
-	page_ref_unfreeze(page, expected_count - 1);
+	folio_ref_unfreeze(src, expected_count - 1);
 
 	xas_unlock_irq(&xas);
 
-- 
2.35.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  parent reply	other threads:[~2022-06-08 15:05 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-08 15:02 [PATCH v2 00/19] Convert aops->migratepage to aops->migrate_folio Matthew Wilcox (Oracle)
2022-06-08 15:02 ` [PATCH v2 01/19] secretmem: Remove isolate_page Matthew Wilcox (Oracle)
2022-06-09 12:46   ` David Hildenbrand
2022-06-08 15:02 ` [PATCH v2 02/19] mm: Convert all PageMovable users to movable_operations Matthew Wilcox (Oracle)
2022-06-09 10:23   ` David Hildenbrand
2022-06-08 15:02 ` [PATCH v2 03/19] fs: Add aops->migrate_folio Matthew Wilcox (Oracle)
2022-06-09 12:50   ` David Hildenbrand
2022-06-09 14:35     ` Matthew Wilcox
2022-06-10 10:17       ` David Hildenbrand
2022-06-08 15:02 ` [PATCH v2 04/19] mm/migrate: Convert fallback_migrate_page() to fallback_migrate_folio() Matthew Wilcox (Oracle)
2022-06-08 15:02 ` [PATCH v2 05/19] mm/migrate: Convert writeout() to take a folio Matthew Wilcox (Oracle)
2022-06-08 15:02 ` [PATCH v2 06/19] mm/migrate: Convert buffer_migrate_page() to buffer_migrate_folio() Matthew Wilcox (Oracle)
2022-06-08 15:02 ` [PATCH v2 07/19] mm/migrate: Convert expected_page_refs() to folio_expected_refs() Matthew Wilcox (Oracle)
2022-07-08  2:50   ` Hugh Dickins
2022-07-08  3:29     ` Matthew Wilcox
2022-06-08 15:02 ` [PATCH v2 08/19] btrfs: Convert btree_migratepage to migrate_folio Matthew Wilcox (Oracle)
2022-06-09 16:25   ` David Sterba
2022-06-08 15:02 ` [PATCH v2 09/19] nfs: Convert " Matthew Wilcox (Oracle)
2022-06-08 15:02 ` [PATCH v2 10/19] mm/migrate: Convert migrate_page() to migrate_folio() Matthew Wilcox (Oracle)
2022-06-09 16:26   ` David Sterba
2022-06-08 15:02 ` [PATCH v2 11/19] mm/migrate: Add filemap_migrate_folio() Matthew Wilcox (Oracle)
2022-06-08 15:22   ` Darrick J. Wong
2022-06-08 15:02 ` [PATCH v2 12/19] btrfs: Convert btrfs_migratepage to migrate_folio Matthew Wilcox (Oracle)
2022-06-09 16:33   ` David Sterba
2022-06-09 17:40     ` Matthew Wilcox
2022-06-09 23:05       ` David Sterba
2022-06-08 15:02 ` [PATCH v2 13/19] ubifs: Convert to filemap_migrate_folio() Matthew Wilcox (Oracle)
2022-06-08 15:02 ` [PATCH v2 14/19] f2fs: " Matthew Wilcox (Oracle)
2022-06-15  8:11   ` [f2fs-dev] " Chao Yu
2022-06-08 15:02 ` [PATCH v2 15/19] aio: Convert to migrate_folio Matthew Wilcox (Oracle)
2022-06-08 15:02 ` Matthew Wilcox (Oracle) [this message]
2022-06-09  3:53   ` [PATCH v2 16/19] hugetlb: " Muchun Song
2022-06-09 20:51   ` Mike Kravetz
2022-06-08 15:02 ` [PATCH v2 17/19] secretmem: " Matthew Wilcox (Oracle)
2022-06-08 15:02 ` [PATCH v2 18/19] fs: Remove aops->migratepage() Matthew Wilcox (Oracle)
2022-06-08 15:02 ` [PATCH v2 19/19] mm/folio-compat: Remove migration compatibility functions Matthew Wilcox (Oracle)

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=20220608150249.3033815-17-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=cluster-devel@redhat.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-ntfs-dev@lists.sourceforge.net \
    --cc=linux-xfs@vger.kernel.org \
    --cc=ocfs2-devel@oss.oracle.com \
    --cc=virtualization@lists.linux-foundation.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;
as well as URLs for NNTP newsgroup(s).