* [PATCH 1/2] erofs: get rid of the remaining kmap_atomic()
@ 2023-06-27 16:12 Gao Xiang
2023-06-27 16:12 ` [PATCH 2/2] erofs: simplify z_erofs_transform_plain() Gao Xiang
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Gao Xiang @ 2023-06-27 16:12 UTC (permalink / raw)
To: linux-erofs; +Cc: LKML, Gao Xiang
It's unnecessary to use kmap_atomic() compared with kmap_local_page().
In addition, kmap_atomic() is deprecated now.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
preliminary tested with silesia dataset.
fs/erofs/decompressor.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index 2a29943fa5cc..ad53cf52d899 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -148,7 +148,7 @@ static void *z_erofs_lz4_handle_overlap(struct z_erofs_lz4_decompress_ctx *ctx,
*maptype = 0;
return inpage;
}
- kunmap_atomic(inpage);
+ kunmap_local(inpage);
might_sleep();
src = erofs_vm_map_ram(rq->in, ctx->inpages);
if (!src)
@@ -162,7 +162,7 @@ static void *z_erofs_lz4_handle_overlap(struct z_erofs_lz4_decompress_ctx *ctx,
src = erofs_get_pcpubuf(ctx->inpages);
if (!src) {
DBG_BUGON(1);
- kunmap_atomic(inpage);
+ kunmap_local(inpage);
return ERR_PTR(-EFAULT);
}
@@ -173,9 +173,9 @@ static void *z_erofs_lz4_handle_overlap(struct z_erofs_lz4_decompress_ctx *ctx,
min_t(unsigned int, total, PAGE_SIZE - *inputmargin);
if (!inpage)
- inpage = kmap_atomic(*in);
+ inpage = kmap_local_page(*in);
memcpy(tmp, inpage + *inputmargin, page_copycnt);
- kunmap_atomic(inpage);
+ kunmap_local(inpage);
inpage = NULL;
tmp += page_copycnt;
total -= page_copycnt;
@@ -214,7 +214,7 @@ static int z_erofs_lz4_decompress_mem(struct z_erofs_lz4_decompress_ctx *ctx,
int ret, maptype;
DBG_BUGON(*rq->in == NULL);
- headpage = kmap_atomic(*rq->in);
+ headpage = kmap_local_page(*rq->in);
/* LZ4 decompression inplace is only safe if zero_padding is enabled */
if (erofs_sb_has_zero_padding(EROFS_SB(rq->sb))) {
@@ -223,7 +223,7 @@ static int z_erofs_lz4_decompress_mem(struct z_erofs_lz4_decompress_ctx *ctx,
min_t(unsigned int, rq->inputsize,
rq->sb->s_blocksize - rq->pageofs_in));
if (ret) {
- kunmap_atomic(headpage);
+ kunmap_local(headpage);
return ret;
}
may_inplace = !((rq->pageofs_in + rq->inputsize) &
@@ -261,7 +261,7 @@ static int z_erofs_lz4_decompress_mem(struct z_erofs_lz4_decompress_ctx *ctx,
}
if (maptype == 0) {
- kunmap_atomic(headpage);
+ kunmap_local(headpage);
} else if (maptype == 1) {
vm_unmap_ram(src, ctx->inpages);
} else if (maptype == 2) {
@@ -289,7 +289,7 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq,
/* one optimized fast path only for non bigpcluster cases yet */
if (ctx.inpages == 1 && ctx.outpages == 1 && !rq->inplace_io) {
DBG_BUGON(!*rq->out);
- dst = kmap_atomic(*rq->out);
+ dst = kmap_local_page(*rq->out);
dst_maptype = 0;
goto dstmap_out;
}
@@ -311,7 +311,7 @@ static int z_erofs_lz4_decompress(struct z_erofs_decompress_req *rq,
dstmap_out:
ret = z_erofs_lz4_decompress_mem(&ctx, dst + rq->pageofs_out);
if (!dst_maptype)
- kunmap_atomic(dst);
+ kunmap_local(dst);
else if (dst_maptype == 2)
vm_unmap_ram(dst, ctx.outpages);
return ret;
--
2.24.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] erofs: simplify z_erofs_transform_plain()
2023-06-27 16:12 [PATCH 1/2] erofs: get rid of the remaining kmap_atomic() Gao Xiang
@ 2023-06-27 16:12 ` Gao Xiang
2023-06-28 6:38 ` Yue Hu
2023-07-11 15:28 ` Chao Yu
2023-06-28 7:57 ` [PATCH 1/2] erofs: get rid of the remaining kmap_atomic() Yue Hu
2023-07-11 15:26 ` Chao Yu
2 siblings, 2 replies; 6+ messages in thread
From: Gao Xiang @ 2023-06-27 16:12 UTC (permalink / raw)
To: linux-erofs; +Cc: LKML, Gao Xiang
Use memcpy_to_page() instead of open-coding them.
In addition, add a missing flush_dcache_page() even though almost all
modern architectures clear `PG_dcache_clean` flag for new file cache
pages so that it doesn't change anything in practice.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
preliminary tested with silesia dataset.
fs/erofs/decompressor.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index ad53cf52d899..cfad1eac7fd9 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -328,7 +328,7 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
const unsigned int lefthalf = rq->outputsize - righthalf;
const unsigned int interlaced_offset =
rq->alg == Z_EROFS_COMPRESSION_SHIFTED ? 0 : rq->pageofs_out;
- unsigned char *src, *dst;
+ u8 *src;
if (outpages > 2 && rq->alg == Z_EROFS_COMPRESSION_SHIFTED) {
DBG_BUGON(1);
@@ -341,22 +341,19 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
}
src = kmap_local_page(rq->in[inpages - 1]) + rq->pageofs_in;
- if (rq->out[0]) {
- dst = kmap_local_page(rq->out[0]);
- memcpy(dst + rq->pageofs_out, src + interlaced_offset,
- righthalf);
- kunmap_local(dst);
- }
+ if (rq->out[0])
+ memcpy_to_page(rq->out[0], rq->pageofs_out,
+ src + interlaced_offset, righthalf);
if (outpages > inpages) {
DBG_BUGON(!rq->out[outpages - 1]);
if (rq->out[outpages - 1] != rq->in[inpages - 1]) {
- dst = kmap_local_page(rq->out[outpages - 1]);
- memcpy(dst, interlaced_offset ? src :
- (src + righthalf), lefthalf);
- kunmap_local(dst);
+ memcpy_to_page(rq->out[outpages - 1], 0, src +
+ (interlaced_offset ? 0 : righthalf),
+ lefthalf);
} else if (!interlaced_offset) {
memmove(src, src + righthalf, lefthalf);
+ flush_dcache_page(rq->in[inpages - 1]);
}
}
kunmap_local(src);
--
2.24.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] erofs: simplify z_erofs_transform_plain()
2023-06-27 16:12 ` [PATCH 2/2] erofs: simplify z_erofs_transform_plain() Gao Xiang
@ 2023-06-28 6:38 ` Yue Hu
2023-07-11 15:28 ` Chao Yu
1 sibling, 0 replies; 6+ messages in thread
From: Yue Hu @ 2023-06-28 6:38 UTC (permalink / raw)
To: Gao Xiang; +Cc: linux-erofs, LKML, huyue2
On Wed, 28 Jun 2023 00:12:40 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:
> Use memcpy_to_page() instead of open-coding them.
>
> In addition, add a missing flush_dcache_page() even though almost all
> modern architectures clear `PG_dcache_clean` flag for new file cache
> pages so that it doesn't change anything in practice.
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Yue Hu <huyue2@coolpad.com>
> ---
> preliminary tested with silesia dataset.
>
> fs/erofs/decompressor.c | 19 ++++++++-----------
> 1 file changed, 8 insertions(+), 11 deletions(-)
>
> diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> index ad53cf52d899..cfad1eac7fd9 100644
> --- a/fs/erofs/decompressor.c
> +++ b/fs/erofs/decompressor.c
> @@ -328,7 +328,7 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
> const unsigned int lefthalf = rq->outputsize - righthalf;
> const unsigned int interlaced_offset =
> rq->alg == Z_EROFS_COMPRESSION_SHIFTED ? 0 : rq->pageofs_out;
> - unsigned char *src, *dst;
> + u8 *src;
>
> if (outpages > 2 && rq->alg == Z_EROFS_COMPRESSION_SHIFTED) {
> DBG_BUGON(1);
> @@ -341,22 +341,19 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
> }
>
> src = kmap_local_page(rq->in[inpages - 1]) + rq->pageofs_in;
> - if (rq->out[0]) {
> - dst = kmap_local_page(rq->out[0]);
> - memcpy(dst + rq->pageofs_out, src + interlaced_offset,
> - righthalf);
> - kunmap_local(dst);
> - }
> + if (rq->out[0])
> + memcpy_to_page(rq->out[0], rq->pageofs_out,
> + src + interlaced_offset, righthalf);
>
> if (outpages > inpages) {
> DBG_BUGON(!rq->out[outpages - 1]);
> if (rq->out[outpages - 1] != rq->in[inpages - 1]) {
> - dst = kmap_local_page(rq->out[outpages - 1]);
> - memcpy(dst, interlaced_offset ? src :
> - (src + righthalf), lefthalf);
> - kunmap_local(dst);
> + memcpy_to_page(rq->out[outpages - 1], 0, src +
> + (interlaced_offset ? 0 : righthalf),
> + lefthalf);
> } else if (!interlaced_offset) {
> memmove(src, src + righthalf, lefthalf);
> + flush_dcache_page(rq->in[inpages - 1]);
> }
> }
> kunmap_local(src);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] erofs: get rid of the remaining kmap_atomic()
2023-06-27 16:12 [PATCH 1/2] erofs: get rid of the remaining kmap_atomic() Gao Xiang
2023-06-27 16:12 ` [PATCH 2/2] erofs: simplify z_erofs_transform_plain() Gao Xiang
@ 2023-06-28 7:57 ` Yue Hu
2023-07-11 15:26 ` Chao Yu
2 siblings, 0 replies; 6+ messages in thread
From: Yue Hu @ 2023-06-28 7:57 UTC (permalink / raw)
To: Gao Xiang; +Cc: linux-erofs, LKML, huyue2
On Wed, 28 Jun 2023 00:12:39 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:
> It's unnecessary to use kmap_atomic() compared with kmap_local_page().
> In addition, kmap_atomic() is deprecated now.
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Yue Hu <huyue2@coolpad.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] erofs: get rid of the remaining kmap_atomic()
2023-06-27 16:12 [PATCH 1/2] erofs: get rid of the remaining kmap_atomic() Gao Xiang
2023-06-27 16:12 ` [PATCH 2/2] erofs: simplify z_erofs_transform_plain() Gao Xiang
2023-06-28 7:57 ` [PATCH 1/2] erofs: get rid of the remaining kmap_atomic() Yue Hu
@ 2023-07-11 15:26 ` Chao Yu
2 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2023-07-11 15:26 UTC (permalink / raw)
To: Gao Xiang, linux-erofs; +Cc: LKML
On 2023/6/28 0:12, Gao Xiang wrote:
> It's unnecessary to use kmap_atomic() compared with kmap_local_page().
> In addition, kmap_atomic() is deprecated now.
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] erofs: simplify z_erofs_transform_plain()
2023-06-27 16:12 ` [PATCH 2/2] erofs: simplify z_erofs_transform_plain() Gao Xiang
2023-06-28 6:38 ` Yue Hu
@ 2023-07-11 15:28 ` Chao Yu
1 sibling, 0 replies; 6+ messages in thread
From: Chao Yu @ 2023-07-11 15:28 UTC (permalink / raw)
To: Gao Xiang, linux-erofs; +Cc: LKML
On 2023/6/28 0:12, Gao Xiang wrote:
> Use memcpy_to_page() instead of open-coding them.
>
> In addition, add a missing flush_dcache_page() even though almost all
> modern architectures clear `PG_dcache_clean` flag for new file cache
> pages so that it doesn't change anything in practice.
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-07-11 15:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-27 16:12 [PATCH 1/2] erofs: get rid of the remaining kmap_atomic() Gao Xiang
2023-06-27 16:12 ` [PATCH 2/2] erofs: simplify z_erofs_transform_plain() Gao Xiang
2023-06-28 6:38 ` Yue Hu
2023-07-11 15:28 ` Chao Yu
2023-06-28 7:57 ` [PATCH 1/2] erofs: get rid of the remaining kmap_atomic() Yue Hu
2023-07-11 15:26 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox