From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
vitaly.wool@konsulko.com, cerasuolodomenico@gmail.com,
nphamcs@gmail.com, hch@infradead.org, yosryahmed@google.com,
akpm@linux-foundation.org
Subject: [PATCH 2/5] zswap: Make zswap_store() take a folio
Date: Sat, 15 Jul 2023 05:23:40 +0100 [thread overview]
Message-ID: <20230715042343.434588-3-willy@infradead.org> (raw)
In-Reply-To: <20230715042343.434588-1-willy@infradead.org>
Only convert a few easy parts of this function to use the folio passed
in; convert back to struct page for the majority of it. This does
remove a few hidden calls to compound_head().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
include/linux/zswap.h | 4 ++--
mm/page_io.c | 2 +-
mm/zswap.c | 13 +++++++------
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/include/linux/zswap.h b/include/linux/zswap.h
index 850c377d9b6d..9f318c8bc367 100644
--- a/include/linux/zswap.h
+++ b/include/linux/zswap.h
@@ -10,7 +10,7 @@ extern atomic_t zswap_stored_pages;
#ifdef CONFIG_ZSWAP
-bool zswap_store(struct page *page);
+bool zswap_store(struct folio *folio);
bool zswap_load(struct page *page);
void zswap_invalidate(int type, pgoff_t offset);
void zswap_swapon(int type);
@@ -18,7 +18,7 @@ void zswap_swapoff(int type);
#else
-static inline bool zswap_store(struct page *page)
+static inline bool zswap_store(struct folio *folio)
{
return false;
}
diff --git a/mm/page_io.c b/mm/page_io.c
index 32afc2a52982..b9fda7fb4e75 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -198,7 +198,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
folio_unlock(folio);
return ret;
}
- if (zswap_store(&folio->page)) {
+ if (zswap_store(folio)) {
folio_start_writeback(folio);
folio_unlock(folio);
folio_end_writeback(folio);
diff --git a/mm/zswap.c b/mm/zswap.c
index f6a78e085479..ba50b186ee27 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -1201,11 +1201,12 @@ static void zswap_fill_page(void *ptr, unsigned long value)
memset_l(page, value, PAGE_SIZE / sizeof(unsigned long));
}
-bool zswap_store(struct page *page)
+bool zswap_store(struct folio *folio)
{
- swp_entry_t swp = { .val = page_private(page), };
+ swp_entry_t swp = folio_swap_entry(folio);
int type = swp_type(swp);
pgoff_t offset = swp_offset(swp);
+ struct page *page = &folio->page;
struct zswap_tree *tree = zswap_trees[type];
struct zswap_entry *entry, *dupentry;
struct scatterlist input, output;
@@ -1219,11 +1220,11 @@ bool zswap_store(struct page *page)
gfp_t gfp;
int ret;
- VM_WARN_ON_ONCE(!PageLocked(page));
- VM_WARN_ON_ONCE(!PageSwapCache(page));
+ VM_WARN_ON_ONCE(!folio_test_locked(folio));
+ VM_WARN_ON_ONCE(!folio_test_swapcache(folio));
- /* THP isn't supported */
- if (PageTransHuge(page))
+ /* Large folios aren't supported */
+ if (folio_test_large(folio))
return false;
if (!zswap_enabled || !tree)
--
2.39.2
next prev parent reply other threads:[~2023-07-15 4:23 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 19:46 [PATCH] mm: kill frontswap Johannes Weiner
2023-07-14 21:10 ` Konrad Rzeszutek Wilk
2023-07-14 22:25 ` Nhat Pham
2023-07-15 3:42 ` Matthew Wilcox
2023-07-17 14:12 ` Johannes Weiner
2023-07-17 14:31 ` Vlastimil Babka
2023-07-17 16:02 ` Johannes Weiner
2023-07-17 16:07 ` Matthew Wilcox
2023-07-17 21:51 ` Johannes Weiner
2023-07-17 22:58 ` Nhat Pham
2023-07-18 18:52 ` Yosry Ahmed
2023-07-19 14:28 ` Johannes Weiner
2023-07-19 15:22 ` Yosry Ahmed
2024-01-16 20:09 ` Andrew Morton
2024-01-16 20:18 ` Matthew Wilcox
2024-01-16 20:22 ` Yosry Ahmed
2024-01-16 21:35 ` Andrew Morton
2023-07-15 4:23 ` [PATCH 0/5] Followup folio conversions for zswap Matthew Wilcox (Oracle)
2023-07-15 4:23 ` [PATCH 1/5] fix-frontswap Matthew Wilcox (Oracle)
2023-07-15 4:23 ` Matthew Wilcox (Oracle) [this message]
2023-07-15 4:23 ` [PATCH 3/5] memcg: Convert get_obj_cgroup_from_page to get_obj_cgroup_from_folio Matthew Wilcox (Oracle)
2023-07-15 4:23 ` [PATCH 4/5] swap: Remove some calls to compound_head() in swap_readpage() Matthew Wilcox (Oracle)
2023-07-15 4:23 ` [PATCH 5/5] zswap: Make zswap_load() take a folio Matthew Wilcox (Oracle)
2023-07-20 6:00 ` [PATCH] mm: kill frontswap Christoph Hellwig
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=20230715042343.434588-3-willy@infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=cerasuolodomenico@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nphamcs@gmail.com \
--cc=vitaly.wool@konsulko.com \
--cc=yosryahmed@google.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