On (25/03/04 16:42), Herbert Xu wrote: > 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): Nice. [..] > 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. That's interesting.