Commit 5d19f5de authored by Yosry Ahmed's avatar Yosry Ahmed Committed by Andrew Morton

mm: zswap: use sg_set_folio() in zswap_{compress/decompress}()

Patch series "mm: zswap: trivial folio conversions".

Some trivial folio conversions in zswap code.


This patch (of 3):

sg_set_folio() is equivalent to sg_set_page() for order-0 folios, which
are the only ones supported by zswap. Now zswap_decompress() can take in
a folio directly.

Link: https://lkml.kernel.org/r/20240524033819.1953587-1-yosryahmed@google.com
Link: https://lkml.kernel.org/r/20240524033819.1953587-2-yosryahmed@google.comSigned-off-by: default avatarYosry Ahmed <yosryahmed@google.com>
Reviewed-by: default avatarChengming Zhou <chengming.zhou@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Nhat Pham <nphamcs@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent 90663284
...@@ -917,7 +917,7 @@ static bool zswap_compress(struct folio *folio, struct zswap_entry *entry) ...@@ -917,7 +917,7 @@ static bool zswap_compress(struct folio *folio, struct zswap_entry *entry)
dst = acomp_ctx->buffer; dst = acomp_ctx->buffer;
sg_init_table(&input, 1); sg_init_table(&input, 1);
sg_set_page(&input, &folio->page, PAGE_SIZE, 0); sg_set_folio(&input, folio, PAGE_SIZE, 0);
/* /*
* We need PAGE_SIZE * 2 here since there maybe over-compression case, * We need PAGE_SIZE * 2 here since there maybe over-compression case,
...@@ -971,7 +971,7 @@ static bool zswap_compress(struct folio *folio, struct zswap_entry *entry) ...@@ -971,7 +971,7 @@ static bool zswap_compress(struct folio *folio, struct zswap_entry *entry)
return comp_ret == 0 && alloc_ret == 0; return comp_ret == 0 && alloc_ret == 0;
} }
static void zswap_decompress(struct zswap_entry *entry, struct page *page) static void zswap_decompress(struct zswap_entry *entry, struct folio *folio)
{ {
struct zpool *zpool = zswap_find_zpool(entry); struct zpool *zpool = zswap_find_zpool(entry);
struct scatterlist input, output; struct scatterlist input, output;
...@@ -1000,7 +1000,7 @@ static void zswap_decompress(struct zswap_entry *entry, struct page *page) ...@@ -1000,7 +1000,7 @@ static void zswap_decompress(struct zswap_entry *entry, struct page *page)
sg_init_one(&input, src, entry->length); sg_init_one(&input, src, entry->length);
sg_init_table(&output, 1); sg_init_table(&output, 1);
sg_set_page(&output, page, PAGE_SIZE, 0); sg_set_folio(&output, folio, PAGE_SIZE, 0);
acomp_request_set_params(acomp_ctx->req, &input, &output, entry->length, PAGE_SIZE); acomp_request_set_params(acomp_ctx->req, &input, &output, entry->length, PAGE_SIZE);
BUG_ON(crypto_wait_req(crypto_acomp_decompress(acomp_ctx->req), &acomp_ctx->wait)); BUG_ON(crypto_wait_req(crypto_acomp_decompress(acomp_ctx->req), &acomp_ctx->wait));
BUG_ON(acomp_ctx->req->dlen != PAGE_SIZE); BUG_ON(acomp_ctx->req->dlen != PAGE_SIZE);
...@@ -1073,7 +1073,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry, ...@@ -1073,7 +1073,7 @@ static int zswap_writeback_entry(struct zswap_entry *entry,
return -ENOMEM; return -ENOMEM;
} }
zswap_decompress(entry, &folio->page); zswap_decompress(entry, folio);
count_vm_event(ZSWPWB); count_vm_event(ZSWPWB);
if (entry->objcg) if (entry->objcg)
...@@ -1580,7 +1580,7 @@ bool zswap_load(struct folio *folio) ...@@ -1580,7 +1580,7 @@ bool zswap_load(struct folio *folio)
return false; return false;
if (entry->length) if (entry->length)
zswap_decompress(entry, page); zswap_decompress(entry, folio);
else { else {
dst = kmap_local_page(page); dst = kmap_local_page(page);
zswap_fill_page(dst, entry->value); zswap_fill_page(dst, entry->value);
......
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