Re: [RFC PATCH 7/7] mm: zswap: Use acomp virtual address interface

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

 



On Tue, Mar 04, 2025 at 05:33:05PM +0900, Sergey Senozhatsky wrote:
>
> And at some point you do memcpy() from SG list to a local buffer?
> 
> zsmalloc map() has a shortcut - for objects that fit one physical
> page (that includes huge incompressible PAGE_SIZE-ed objects)
> zsmalloc kmap the physical page in question and returns a pointer
> to that mapping.

If the SG list only has a single entry, there will be no copies
whatsoever even with the existing scomp code (crypto/scompress.c):

static int scomp_acomp_comp_decomp(struct acomp_req *req, int dir)
{

	...
        if (sg_nents(req->src) == 1 && !PageHighMem(sg_page(req->src))) {
                src = page_to_virt(sg_page(req->src)) + req->src->offset;
	} else {
		Use scratch buffer and do a copy
	}

This still does an unnecessary copy for highmem, but that will
disappear after my acomp patch-set:

                if (sg_nents(req->src) == 1 &&
                    (!PageHighMem(sg_page(req->src)) ||
                     req->src->offset + slen <= PAGE_SIZE))
                        src = kmap_local_page(sg_page(req->src)) + req->src->offset;
		else
			Use scratch buffer and do a copy

I've also modified LZO decompression to handle SG lists which I will
post soon.  That will mean that no copies will ever occur for LZO
decompression.  The same change could be extended to other algorithms
if someone wishes to eliminate the copy for their favourite algorithm.

Cheers,
-- 
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