Re: [PATCH 3/3] crypto: scompress: remove memcpy if sg_nents is 1

From: Barry Song
Date: Thu Feb 15 2024 - 22:49:39 EST


On Thu, Jan 25, 2024 at 10:58 PM Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Wed, Jan 03, 2024 at 10:50:06PM +1300, Barry Song wrote:
> >
> > + if (dst != scratch->dst)
> > + kunmap_local(dst);
>
> This is missing a flush_dcache_page.

Thanks, Herbert! I'd rather add flush_dcache_page()
to the below place so that we can avoid one redundant
flush for ENOSPC/ENOMEM case:

if (!ret) {
if (!req->dst) {
req->dst = sgl_alloc(req->dlen, GFP_ATOMIC, NULL);
if (!req->dst) {
ret = -ENOMEM;
goto out;
}
} else if (req->dlen > dlen) {
ret = -ENOSPC;
goto out;
}
if (dst == scratch->dst) {
scatterwalk_map_and_copy(scratch->dst, req->dst, 0,
req->dlen, 1);
} else {
+ flush_dcache_page(sg_page(req->dst));
}
}
out:
if (src != scratch->src)
kunmap_local(src);
if (dst != scratch->dst)
kunmap_local(dst);

>
> It may not matter for zswap, but this is API code and needs to
> work for every single case.
>
> Thanks,
> --
> Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
>

Thanks
Barry