crypto: replace cpumask_next with better API
Subsystems (3)
cover crypto: replace cpumask_next with better API
From: Yury Norov [NVIDIA] <[email protected]>
Recently added cpumask_next_wrap() and cpumask_nth() work better than cpumask_next(). Use them where appropriate.
Yury Norov [NVIDIA] (2):
crypto: pcrypt: Optimize pcrypt_aead_init_tfm()
crypto: caam - Fix opencoded cpumask_next_wrap() in
caam_drv_ctx_init()
crypto/pcrypt.c | 7 ++----- drivers/crypto/caam/qi.c | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/2 crypto: pcrypt: Optimize pcrypt_aead_init_tfm()
From: Yury Norov [NVIDIA] <[email protected]>
The function opencodes cpumask_nth(). The dedicated helper is faster than an open for-loop.
--- crypto/pcrypt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
crypto/pcrypt.c +2 -5
@@ -178,7 +178,7 @@ static int pcrypt_aead_decrypt(struct aead_request *req)static int pcrypt_aead_init_tfm (struct crypto_aead *tfm) { -int cpu, cpu_index; +int cpu_index;struct aead_instance *inst =aead_alg_instance (tfm);struct pcrypt_instance_ctx *ictx =aead_instance_ctx (inst);struct pcrypt_aead_ctx *ctx =crypto_aead_ctx (tfm);
@@ -187,10 +187,7 @@ static int pcrypt_aead_init_tfm(struct crypto_aead *tfm) cpu_index = (unsigned int )atomic_inc_return (&ictx->tfm_count) %cpumask_weight (cpu_online_mask); - ctx->cb_cpu =cpumask_first (cpu_online_mask); -for (cpu =0 ; cpu < cpu_index; cpu++) - ctx->cb_cpu =cpumask_next (ctx->cb_cpu, cpu_online_mask); - + ctx->cb_cpu =cpumask_nth (cpu_index, cpu_online_mask); cipher =crypto_spawn_aead (&ictx->spawn);if (IS_ERR (cipher))
Signature · 1 line
2.43.0
PATCH 2/2 crypto: caam - Fix opencoded cpumask_next_wrap() in caam_drv_ctx_init()
In reply to Yury NorovFrom: Yury Norov [NVIDIA] <[email protected]>
The dedicated cpumask_next_wrap() is more verbose and better optimized comparing to cpumask_next() followed by cpumask_first().
--- drivers/crypto/caam/qi.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/crypto/caam/qi.c +1 -4
@@ -442,11 +442,8 @@ struct caam_drv_ctx *caam_drv_ctx_init(struct device *qidev,if (!cpumask_test_cpu (*cpu, cpus)) {int *pcpu = &get_cpu_var (last_cpu); - *pcpu =cpumask_next (*pcpu, cpus); -if (*pcpu >= nr_cpu_ids) - *pcpu =cpumask_first (cpus); + *pcpu =cpumask_next_wrap (*pcpu, cpus); *cpu = *pcpu; -put_cpu_var (last_cpu); } drv_ctx->cpu = *cpu;
Signature · 1 line
2.43.0
Herbert Xu
maintainerQuoted 5 lines · Yury Norov
From: Yury Norov [NVIDIA] <[email protected]>
Recently added
cpumask_next_wrap()andcpumask_nth()work better thancpumask_next(). Use them where appropriate.
Quoted 11 lines
Yury Norov [NVIDIA] (2):
crypto: pcrypt: Optimizepcrypt_aead_init_tfm()
crypto: caam - Fix opencodedcpumask_next_wrap()incaam_drv_ctx_init()crypto/pcrypt.c | 7 ++----- drivers/crypto/caam/qi.c | 5 +---- 2 files changed, 3 insertions(+), 9 deletions(-)Signature · 1 line
2.43.0
All applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt