Re: [PATCH v1 0/8] Batched zswap_store() with compression batching

From: Kanchana P. Sridhar

Date: Fri Oct 16 2026 - 23:07:59 EST


On Thu, Oct 15, 2026 at 9:38 PM Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Thu, Oct 15, 2026 at 08:32:21PM -0700, Kanchana P. Sridhar wrote:
> >
> > If you are Ok with all this, we will need Herbert's Ok for this change
> > in patch 3:
> >
> > diff --git a/crypto/acompress.c b/crypto/acompress.c
> > index 192ea996e779..db8e4c82b900 100644
> > --- a/crypto/acompress.c
> > +++ b/crypto/acompress.c
> > @@ -293,8 +293,12 @@ int crypto_acomp_compress(struct acomp_req *req)
> > return -EAGAIN;
> >
> > if (likely(req->unit_size && acomp_request_issg(req))) {
> > - if (!crypto_acomp_req_seg(tfm))
> > - return acomp_do_req_chain(req, true);
> > + if (likely(!crypto_acomp_req_seg(tfm))) {
> > + int err = tfm->compress(req);
> > +
> > + req->dst->length = unlikely(err) ? err : req->dlen;
> > + return err;
> > + }
>
> What if you put this short-circuit into acomp_do_req_chain instead,
> does it still give you the same performance boost?

I made the suggested change as follows:

diff --git a/crypto/acompress.c b/crypto/acompress.c
index 192ea996e779..6697cf5944a3 100644
--- a/crypto/acompress.c
+++ b/crypto/acompress.c
@@ -271,11 +271,19 @@ static void acomp_reqchain_done(void *data, int err)

static int acomp_do_req_chain(struct acomp_req *req, bool comp)
{
+ struct crypto_acomp *tfm = crypto_acomp_reqtfm(req);
int err;

if (unlikely(req->unit_size && req->slen > req->unit_size))
return -ENOSYS;

+ if (likely(acomp_request_issg(req) &&
+ !crypto_acomp_req_seg(tfm) && comp)) {
+ err = tfm->compress(req);
+ req->dst->length = unlikely(err) ? err : req->dlen;
+ return err;
+ }
+
acomp_save_req(req, acomp_reqchain_done);

err = acomp_do_one_req(req, comp);
@@ -293,7 +301,7 @@ int crypto_acomp_compress(struct acomp_req *req)
return -EAGAIN;

if (likely(req->unit_size && acomp_request_issg(req))) {
- if (!crypto_acomp_req_seg(tfm))
+ if (likely(!crypto_acomp_req_seg(tfm)))
return acomp_do_req_chain(req, true);

return tfm->compress(req);

The Average throughput of 10 iterations usemem is 19,058 KB/s. IOW, I
don't get the same performance boost as making the localized change in
crypto_acomp_compress(), likely because of added computes per compress
call (one function call, two conditionals).

I think the localized change in crypto_acomp_compress() looks a bit
cleaner as compared to the special-casing for "comp" in the generic
acomp_do_req_chain().

In any case, please let me know if the above data helps.

Thanks!

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