Re: [PATCH v6] crypto: scompress: remove memcpy if sg_nents is 1 and pages are lowmem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 22, 2024 at 03:06:17PM +1300, Barry Song wrote:
>
> -	scatterwalk_map_and_copy(scratch->src, req->src, 0, req->slen, 0);
> +	if (sg_nents(req->src) == 1 && !PageHighMem(sg_page(req->src))) {
> +		src = page_to_virt(sg_page(req->src)) + req->src->offset;

Incidentally this made me look at other uses of PageHighMem in
the kernel.

The one in copy_page_from_iter_atomic looks buggy because it assumes
that the kmap never maps a page if PageHighMem is false, which is not
the case for CONFIG_DEBUG_KMAP_LOCAL_FORCE_MAP.

> @@ -152,8 +165,12 @@ static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
>  			ret = -ENOSPC;
>  			goto out;
>  		}
> -		scatterwalk_map_and_copy(scratch->dst, req->dst, 0, req->dlen,
> -					 1);
> +		if (dst == scratch->dst) {
> +			scatterwalk_map_and_copy(scratch->dst, req->dst, 0,
> +						 req->dlen, 1);
> +		} else {
> +			flush_dcache_page(sg_page(req->dst));

I think this is still wrong for the > PAGE_SIZE case.  The existing
code flushes each page sequentially  but the new code only flushes the
first page.

Thanks,
-- 
Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt




[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux