From: Jisheng Zhang <jszhang@kernel.org>
To: Minchan Kim <minchan@kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org
Subject: [PATCH] zram: use copy_page for full page copy
Date: Thu, 13 Jun 2024 08:04:22 +0800 [thread overview]
Message-ID: <20240613000422.1918-1-jszhang@kernel.org> (raw)
commit 42e99bd975fd ("zram: optimize memory operations with
clear_page()/copy_page()") optimize page copy/clean operations, but
then commit d72e9a7a93e4 ("zram: do not use copy_page with non-page
aligned address") removes the optimization because there's memory
corruption at that time, the reason was well explained. But after
commit 1f7319c74275 ("zram: partial IO refactoring"), partial IO uses
alloc_page() instead of kmalloc to allocate a page, so we can bring
back the optimization.
commit 80ba4caf8ba9 ("zram: use copy_page for full page copy") brings
back partial optimization, missed one point in zram_write_page().
optimize the full page copying in zram_write_page() with copy_page()
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
drivers/block/zram/zram_drv.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 3acd7006ad2c..4b2b5098062f 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1478,11 +1478,13 @@ static int zram_write_page(struct zram *zram, struct page *page, u32 index)
dst = zs_map_object(zram->mem_pool, handle, ZS_MM_WO);
src = zstrm->buffer;
- if (comp_len == PAGE_SIZE)
+ if (comp_len == PAGE_SIZE) {
src = kmap_local_page(page);
- memcpy(dst, src, comp_len);
- if (comp_len == PAGE_SIZE)
+ copy_page(dst, src);
kunmap_local(src);
+ } else {
+ memcpy(dst, src, comp_len);
+ }
zcomp_stream_put(zram->comps[ZRAM_PRIMARY_COMP]);
zs_unmap_object(zram->mem_pool, handle);
--
2.43.0
next reply other threads:[~2024-06-13 0:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 0:04 Jisheng Zhang [this message]
2024-06-13 3:17 ` [PATCH] zram: use copy_page for full page copy Sergey Senozhatsky
2024-06-13 12:58 ` Jisheng Zhang
2024-06-14 5:25 ` Christoph Hellwig
2024-06-14 5:31 ` Sergey Senozhatsky
-- strict thread matches above, loose matches on Subject: below --
2023-10-07 7:05 Mark-PK Tsai
2023-10-08 4:38 ` Sergey Senozhatsky
2024-02-05 6:43 ` Mark-PK Tsai (蔡沛剛)
2024-02-05 6:48 ` Sergey Senozhatsky
2024-02-05 6:50 ` Sergey Senozhatsky
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=20240613000422.1918-1-jszhang@kernel.org \
--to=jszhang@kernel.org \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=minchan@kernel.org \
--cc=senozhatsky@chromium.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).