diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2025-03-17 16:33:59 +0800 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2025-04-07 13:22:25 +0800 |
| commit | c47e1f4142a3823b6e963e14db295a8a733804b5 (patch) | |
| tree | 53b32f282ddba99c35212b498d18c452873d3f30 /include | |
| parent | crypto: api - Ensure cra_type->destroy is done in process context (diff) | |
| download | linux-c47e1f4142a3823b6e963e14db295a8a733804b5.tar.gz linux-c47e1f4142a3823b6e963e14db295a8a733804b5.zip | |
crypto: scomp - Allocate per-cpu buffer on first use of each CPU
Per-cpu buffers can be wasteful when the number of CPUs is large,
especially if the buffer itself is likely to never be used. Reduce
such wastage by only allocating them on first use of a particular
CPU.
On start-up allocate a single buffer on the first possible CPU.
For every other CPU a work struct will be scheduled on first use
to allocate the buffer for that CPU. Until the allocation succeeds
simply use the first CPU's buffer which is protected under a spin
lock.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'include')
| -rw-r--r-- | include/crypto/acompress.h | 6 | ||||
| -rw-r--r-- | include/crypto/internal/acompress.h | 1 | ||||
| -rw-r--r-- | include/crypto/internal/scompress.h | 13 |
3 files changed, 13 insertions, 7 deletions
diff --git a/include/crypto/acompress.h b/include/crypto/acompress.h index c497c73baf13..f0e01ff77d92 100644 --- a/include/crypto/acompress.h +++ b/include/crypto/acompress.h @@ -130,14 +130,8 @@ struct crypto_acomp { struct crypto_tfm base; }; -struct crypto_acomp_stream { - spinlock_t lock; - void *ctx; -}; - #define COMP_ALG_COMMON { \ struct crypto_alg base; \ - struct crypto_acomp_stream __percpu *stream; \ } struct comp_alg_common COMP_ALG_COMMON; diff --git a/include/crypto/internal/acompress.h b/include/crypto/internal/acompress.h index aaf59f3236fa..2af690819a83 100644 --- a/include/crypto/internal/acompress.h +++ b/include/crypto/internal/acompress.h @@ -37,7 +37,6 @@ * * @reqsize: Context size for (de)compression requests * @base: Common crypto API algorithm data structure - * @stream: Per-cpu memory for algorithm * @calg: Cmonn algorithm data structure shared with scomp */ struct acomp_alg { diff --git a/include/crypto/internal/scompress.h b/include/crypto/internal/scompress.h index f25aa2ea3b48..fd74e656ffd2 100644 --- a/include/crypto/internal/scompress.h +++ b/include/crypto/internal/scompress.h @@ -11,6 +11,8 @@ #include <crypto/acompress.h> #include <crypto/algapi.h> +#include <linux/cpumask_types.h> +#include <linux/workqueue_types.h> struct acomp_req; @@ -18,6 +20,11 @@ struct crypto_scomp { struct crypto_tfm base; }; +struct crypto_acomp_stream { + spinlock_t lock; + void *ctx; +}; + /** * struct scomp_alg - synchronous compression algorithm * @@ -27,6 +34,8 @@ struct crypto_scomp { * @decompress: Function performs a de-compress operation * @base: Common crypto API algorithm data structure * @stream: Per-cpu memory for algorithm + * @stream_work: Work struct to allocate stream memmory + * @stream_want: CPU mask for allocating stream memory * @calg: Cmonn algorithm data structure shared with acomp */ struct scomp_alg { @@ -39,6 +48,10 @@ struct scomp_alg { unsigned int slen, u8 *dst, unsigned int *dlen, void *ctx); + struct crypto_acomp_stream __percpu *stream; + struct work_struct stream_work; + cpumask_t stream_want; + union { struct COMP_ALG_COMMON; struct comp_alg_common calg; |
