From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Linux Crypto Mailing List <linux-crypto@vger.kernel.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCH 1/3] crypto: scomp - Add setparam interface
Date: Fri, 31 May 2024 15:34:44 +0900 [thread overview]
Message-ID: <20240531063444.GG8400@google.com> (raw)
In-Reply-To: <20240531054759.GE8400@google.com>
On (24/05/31 14:47), Sergey Senozhatsky wrote:
> On (24/05/20 19:04), Herbert Xu wrote:
> [..]
> > +int crypto_scomp_setparam(struct crypto_scomp *tfm, const u8 *param,
> > + unsigned int len)
> > +{
> > + struct scomp_alg *scomp = crypto_scomp_alg(tfm);
> > + int err;
> > +
> > + err = scomp->setparam(tfm, param, len);
> > + if (unlikely(err)) {
> > + scomp_set_need_param(tfm, scomp);
> > + return err;
> > + }
> > +
> > + crypto_scomp_clear_flags(tfm, CRYPTO_TFM_NEED_KEY);
> > + return 0;
> > +}
>
> Is the idea here that each compression driver will have its own structure
> for params?
>
> In other words, something like this?
>
> static int setup_tfm(...)
> {
> ...
> this_cpu->tfm = crypto_alloc_comp(name, 0, 0);
>
> if (!strcmp(name, "zstd")) {
> struct crypto_comp_param_zstd param;
>
> param.dict = ...
> param.cleve = ...
>
> crypto_scomp_setparam(tfm, ¶m, sizeof(param));
> }
>
> if (!strcmp(name, "lz4")) {
> struct crupto_comp_param_lz4 param;
> ...
> }
>
> if (!strcmp(name, "lzo")) {
> struct crupto_comp_param_lzo param;
> ...
> }
> ...
> }
>
> Or should it be "struct crypto_comp_params param"?
So passing "raw" algorithm parameters to crypto_scomp_setparam(tfm) can be
suboptimal, depending on the compression driver. For instance, for zstd
(what is currently done in zram [1]) we pre-process "raw" parameters:
parse dictionary in order to get zstd_cdict and zstd_ddict which are then
shared by all tfm-s (as they access C/D dictionaries in read-only mode).
For zram/zswap doing this per-tfm would result in extra per-CPU
zstd_cdict/zstd_ddict allocations, which is a significant overhead.
Does this sound like adding two more callbacks to drivers
(e.g. parseparam/freeparam)?
[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/drivers/block/zram/backend_zstd.c?h=next-20240529
next prev parent reply other threads:[~2024-05-31 6:34 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 11:04 [PATCH 0/3] crypto: acomp - Add interface to set parameters Herbert Xu
2024-05-20 11:04 ` [PATCH 1/3] crypto: scomp - Add setparam interface Herbert Xu
2024-05-31 5:47 ` Sergey Senozhatsky
2024-05-31 6:34 ` Sergey Senozhatsky [this message]
2024-05-31 8:29 ` Herbert Xu
2024-06-01 0:24 ` Sergey Senozhatsky
2024-06-01 3:54 ` Herbert Xu
2024-06-03 2:34 ` Sergey Senozhatsky
2024-06-03 8:28 ` Sergey Senozhatsky
2024-06-03 8:34 ` Herbert Xu
2024-06-04 5:09 ` Sergey Senozhatsky
2024-06-04 8:48 ` Herbert Xu
2024-05-31 8:30 ` Herbert Xu
2024-05-20 11:04 ` [PATCH 2/3] crypto: acomp " Herbert Xu
2025-05-06 16:01 ` Cabiddu, Giovanni
2025-05-07 2:20 ` Herbert Xu
2025-05-07 13:16 ` Cabiddu, Giovanni
2025-05-08 5:01 ` Sergey Senozhatsky
2025-05-07 17:16 ` Eric Biggers
2025-05-08 5:42 ` Sergey Senozhatsky
2025-05-08 19:21 ` Kanchana P Sridhar
2024-05-20 11:04 ` [PATCH 3/3] crypto: acomp - Add comp_params helpers Herbert Xu
2024-05-31 5:49 ` Sergey Senozhatsky
2024-05-31 8:32 ` Herbert Xu
2024-05-31 5:07 ` [PATCH 0/3] crypto: acomp - Add interface to set parameters Herbert Xu
2024-05-31 5:12 ` Sergey Senozhatsky
2024-05-31 5:18 ` Sergey Senozhatsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240531063444.GG8400@google.com \
--to=senozhatsky@chromium.org \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).