From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-mm@kvack.org
Subject: [PATCH 10/13] mm: Convert swap_readpage() to swap_read_folio()
Date: Wed, 13 Dec 2023 21:58:39 +0000 [thread overview]
Message-ID: <20231213215842.671461-11-willy@infradead.org> (raw)
In-Reply-To: <20231213215842.671461-1-willy@infradead.org>
All callers have a folio, so pass it in, saving two calls to
compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/memory.c | 4 ++--
mm/page_io.c | 18 +++++++++---------
mm/swap.h | 5 +++--
mm/swap_state.c | 12 ++++++------
mm/swapfile.c | 2 +-
5 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/mm/memory.c b/mm/memory.c
index e402340e3f46..2f7b212b7d71 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -3882,9 +3882,9 @@ vm_fault_t do_swap_page(struct vm_fault *vmf)
folio_add_lru(folio);
- /* To provide entry to swap_readpage() */
+ /* To provide entry to swap_read_folio() */
folio->swap = entry;
- swap_readpage(page, true, NULL);
+ swap_read_folio(folio, true, NULL);
folio->private = NULL;
}
} else {
diff --git a/mm/page_io.c b/mm/page_io.c
index 6736c56526bf..09c6a4f316f3 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -420,7 +420,7 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
mempool_free(sio, sio_pool);
}
-static void swap_readpage_fs(struct folio *folio, struct swap_iocb **plug)
+static void swap_read_folio_fs(struct folio *folio, struct swap_iocb **plug)
{
struct swap_info_struct *sis = swp_swap_info(folio->swap);
struct swap_iocb *sio = NULL;
@@ -454,7 +454,7 @@ static void swap_readpage_fs(struct folio *folio, struct swap_iocb **plug)
*plug = sio;
}
-static void swap_readpage_bdev_sync(struct folio *folio,
+static void swap_read_folio_bdev_sync(struct folio *folio,
struct swap_info_struct *sis)
{
struct bio_vec bv;
@@ -474,7 +474,7 @@ static void swap_readpage_bdev_sync(struct folio *folio,
put_task_struct(current);
}
-static void swap_readpage_bdev_async(struct folio *folio,
+static void swap_read_folio_bdev_async(struct folio *folio,
struct swap_info_struct *sis)
{
struct bio *bio;
@@ -487,10 +487,10 @@ static void swap_readpage_bdev_async(struct folio *folio,
submit_bio(bio);
}
-void swap_readpage(struct page *page, bool synchronous, struct swap_iocb **plug)
+void swap_read_folio(struct folio *folio, bool synchronous,
+ struct swap_iocb **plug)
{
- struct folio *folio = page_folio(page);
- struct swap_info_struct *sis = page_swap_info(page);
+ struct swap_info_struct *sis = swp_swap_info(folio->swap);
bool workingset = folio_test_workingset(folio);
unsigned long pflags;
bool in_thrashing;
@@ -514,11 +514,11 @@ void swap_readpage(struct page *page, bool synchronous, struct swap_iocb **plug)
folio_mark_uptodate(folio);
folio_unlock(folio);
} else if (data_race(sis->flags & SWP_FS_OPS)) {
- swap_readpage_fs(folio, plug);
+ swap_read_folio_fs(folio, plug);
} else if (synchronous || (sis->flags & SWP_SYNCHRONOUS_IO)) {
- swap_readpage_bdev_sync(folio, sis);
+ swap_read_folio_bdev_sync(folio, sis);
} else {
- swap_readpage_bdev_async(folio, sis);
+ swap_read_folio_bdev_async(folio, sis);
}
if (workingset) {
diff --git a/mm/swap.h b/mm/swap.h
index b81587740cf1..859ae8f0fd2d 100644
--- a/mm/swap.h
+++ b/mm/swap.h
@@ -10,7 +10,8 @@ struct mempolicy;
/* linux/mm/page_io.c */
int sio_pool_init(void);
struct swap_iocb;
-void swap_readpage(struct page *page, bool do_poll, struct swap_iocb **plug);
+void swap_read_folio(struct folio *folio, bool do_poll,
+ struct swap_iocb **plug);
void __swap_read_unplug(struct swap_iocb *plug);
static inline void swap_read_unplug(struct swap_iocb *plug)
{
@@ -63,7 +64,7 @@ static inline unsigned int folio_swap_flags(struct folio *folio)
}
#else /* CONFIG_SWAP */
struct swap_iocb;
-static inline void swap_readpage(struct page *page, bool do_poll,
+static inline void swap_read_folio(struct folio *folio, bool do_poll,
struct swap_iocb **plug)
{
}
diff --git a/mm/swap_state.c b/mm/swap_state.c
index d4e25d9b5dc6..efff7148a59d 100644
--- a/mm/swap_state.c
+++ b/mm/swap_state.c
@@ -539,7 +539,7 @@ struct folio *__read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
* the swap entry is no longer in use.
*
* get/put_swap_device() aren't needed to call this function, because
- * __read_swap_cache_async() call them and swap_readpage() holds the
+ * __read_swap_cache_async() call them and swap_read_folio() holds the
* swap cache folio lock.
*/
struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
@@ -557,7 +557,7 @@ struct page *read_swap_cache_async(swp_entry_t entry, gfp_t gfp_mask,
mpol_cond_put(mpol);
if (page_allocated)
- swap_readpage(&folio->page, false, plug);
+ swap_read_folio(folio, false, plug);
return folio_file_page(folio, swp_offset(entry));
}
@@ -674,7 +674,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
if (!folio)
continue;
if (page_allocated) {
- swap_readpage(&folio->page, false, &splug);
+ swap_read_folio(folio, false, &splug);
if (offset != entry_offset) {
folio_set_readahead(folio);
count_vm_event(SWAP_RA);
@@ -690,7 +690,7 @@ struct page *swap_cluster_readahead(swp_entry_t entry, gfp_t gfp_mask,
folio = __read_swap_cache_async(entry, gfp_mask, mpol, ilx,
&page_allocated, false);
if (unlikely(page_allocated))
- swap_readpage(&folio->page, false, NULL);
+ swap_read_folio(folio, false, NULL);
zswap_folio_swapin(folio);
return folio_file_page(folio, swp_offset(entry));
}
@@ -848,7 +848,7 @@ static struct page *swap_vma_readahead(swp_entry_t targ_entry, gfp_t gfp_mask,
if (!folio)
continue;
if (page_allocated) {
- swap_readpage(&folio->page, false, &splug);
+ swap_read_folio(folio, false, &splug);
if (i != ra_info.offset) {
folio_set_readahead(folio);
count_vm_event(SWAP_RA);
@@ -866,7 +866,7 @@ static struct page *swap_vma_readahead(swp_entry_t targ_entry, gfp_t gfp_mask,
folio = __read_swap_cache_async(targ_entry, gfp_mask, mpol, targ_ilx,
&page_allocated, false);
if (unlikely(page_allocated))
- swap_readpage(&folio->page, false, NULL);
+ swap_read_folio(folio, false, NULL);
zswap_folio_swapin(folio);
return folio_file_page(folio, swp_offset(entry));
}
diff --git a/mm/swapfile.c b/mm/swapfile.c
index b22c47b11d65..f3e23a3d26ae 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2225,7 +2225,7 @@ EXPORT_SYMBOL_GPL(add_swap_extent);
/*
* A `swap extent' is a simple thing which maps a contiguous range of pages
* onto a contiguous range of disk blocks. A rbtree of swap extents is
- * built at swapon time and is then used at swap_writepage/swap_readpage
+ * built at swapon time and is then used at swap_writepage/swap_read_folio
* time for locating where on disk a page belongs.
*
* If the swapfile is an S_ISBLK block device, a single extent is installed.
--
2.42.0
next prev parent reply other threads:[~2023-12-13 21:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-13 21:58 [PATCH 00/13] More swap folio conversions Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 01/13] mm: Return the folio from __read_swap_cache_async() Matthew Wilcox (Oracle)
2023-12-13 23:14 ` Andrew Morton
2023-12-13 21:58 ` [PATCH 02/13] mm: Pass a folio to __swap_writepage() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 03/13] mm: Pass a folio to swap_writepage_fs() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 04/13] mm: Pass a folio to swap_writepage_bdev_sync() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 05/13] mm: Pass a folio to swap_writepage_bdev_async() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 06/13] mm: Pass a folio to swap_readpage_fs() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 07/13] mm: Pass a folio to swap_readpage_bdev_sync() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 08/13] mm: Pass a folio to swap_readpage_bdev_async() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 09/13] mm: Convert swap_page_sector() to swap_folio_sector() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` Matthew Wilcox (Oracle) [this message]
2023-12-13 21:58 ` [PATCH 11/13] mm: Remove page_swap_info() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 12/13] mm: Return a folio from read_swap_cache_async() Matthew Wilcox (Oracle)
2023-12-13 21:58 ` [PATCH 13/13] mm: Convert swap_cluster_readahead and swap_vma_readahead to return a folio Matthew Wilcox (Oracle)
2023-12-16 13:58 ` Kairui Song
2023-12-20 0:54 ` Matthew Wilcox
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=20231213215842.671461-11-willy@infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.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