Commit 34f4c198 authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Andrew Morton

zswap: make zswap_store() take a folio

Patch series "Followup folio conversions for zswap".

With frontswap killed, it's worth converting the zswap_load() and
zswap_store() functions to take a folio instead of a page pointer.  They
aren't converted to support large folios, but there are a lot of
unnecessary calls to compound_head() that are removed by these patches.


This patch (of 4):

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().

Link: https://lkml.kernel.org/r/20230715042343.434588-1-willy@infradead.org
Link: https://lkml.kernel.org/r/20230715042343.434588-3-willy@infradead.orgSigned-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Domenico Cerasuolo <cerasuolodomenico@gmail.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Cc: Vitaly Wool <vitaly.wool@konsulko.com>
Cc: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 42c06a0e
...@@ -10,7 +10,7 @@ extern atomic_t zswap_stored_pages; ...@@ -10,7 +10,7 @@ extern atomic_t zswap_stored_pages;
#ifdef CONFIG_ZSWAP #ifdef CONFIG_ZSWAP
bool zswap_store(struct page *page); bool zswap_store(struct folio *folio);
bool zswap_load(struct page *page); bool zswap_load(struct page *page);
void zswap_invalidate(int type, pgoff_t offset); void zswap_invalidate(int type, pgoff_t offset);
void zswap_swapon(int type); void zswap_swapon(int type);
...@@ -18,7 +18,7 @@ void zswap_swapoff(int type); ...@@ -18,7 +18,7 @@ void zswap_swapoff(int type);
#else #else
static inline bool zswap_store(struct page *page) static inline bool zswap_store(struct folio *folio)
{ {
return false; return false;
} }
......
...@@ -195,7 +195,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc) ...@@ -195,7 +195,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
folio_unlock(folio); folio_unlock(folio);
return ret; return ret;
} }
if (zswap_store(&folio->page)) { if (zswap_store(folio)) {
folio_start_writeback(folio); folio_start_writeback(folio);
folio_unlock(folio); folio_unlock(folio);
folio_end_writeback(folio); folio_end_writeback(folio);
......
...@@ -1223,11 +1223,12 @@ static void zswap_fill_page(void *ptr, unsigned long value) ...@@ -1223,11 +1223,12 @@ static void zswap_fill_page(void *ptr, unsigned long value)
memset_l(page, value, PAGE_SIZE / sizeof(unsigned long)); 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); int type = swp_type(swp);
pgoff_t offset = swp_offset(swp); pgoff_t offset = swp_offset(swp);
struct page *page = &folio->page;
struct zswap_tree *tree = zswap_trees[type]; struct zswap_tree *tree = zswap_trees[type];
struct zswap_entry *entry, *dupentry; struct zswap_entry *entry, *dupentry;
struct scatterlist input, output; struct scatterlist input, output;
...@@ -1242,11 +1243,11 @@ bool zswap_store(struct page *page) ...@@ -1242,11 +1243,11 @@ bool zswap_store(struct page *page)
gfp_t gfp; gfp_t gfp;
int ret; int ret;
VM_WARN_ON_ONCE(!PageLocked(page)); VM_WARN_ON_ONCE(!folio_test_locked(folio));
VM_WARN_ON_ONCE(!PageSwapCache(page)); VM_WARN_ON_ONCE(!folio_test_swapcache(folio));
/* THP isn't supported */ /* Large folios aren't supported */
if (PageTransHuge(page)) if (folio_test_large(folio))
return false; return false;
if (!zswap_enabled || !tree) if (!zswap_enabled || !tree)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment