diff options
| author | Eric Biggers <ebiggers@kernel.org> | 2026-05-22 00:30:26 -0500 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-05-28 17:45:46 -0700 |
| commit | 3065170bfc7f256f9d1339062dae331f731c6763 (patch) | |
| tree | 649d7939c5cc51ce40b60ef02c4854970b61d863 | |
| parent | 590a46c68a7b0f9ebbd0248a5a00c472f249c204 (diff) | |
| download | linux-next-history-3065170bfc7f256f9d1339062dae331f731c6763.tar.gz | |
crypto: api - Remove per-tfm refcount
This reverts commit ae131f4970f0 ("crypto: api - Add crypto_tfm_get").
The refcount in struct crypto_tfm was added solely to support
crypto_clone_tfm(). Before then it was a simple non-refcounted object.
Since crypto_clone_tfm() has been removed, remove the refcount as well.
Note that this eliminates an expensive atomic operation from every tfm
freeing operation. So this revert doesn't just remove unused code, but
it also fixes a performance regression.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Link: https://patch.msgid.link/20260522053028.91165-5-ebiggers@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | crypto/api.c | 4 | ||||
| -rw-r--r-- | crypto/internal.h | 6 | ||||
| -rw-r--r-- | include/linux/crypto.h | 1 |
3 files changed, 0 insertions, 11 deletions
diff --git a/crypto/api.c b/crypto/api.c index d019d1979857d..be9ee104ffc2d 100644 --- a/crypto/api.c +++ b/crypto/api.c @@ -418,7 +418,6 @@ struct crypto_tfm *__crypto_alloc_tfmgfp(struct crypto_alg *alg, u32 type, goto out_err; tfm->__crt_alg = alg; - refcount_set(&tfm->refcnt, 1); if (!tfm->exit && alg->cra_init && (err = alg->cra_init(tfm))) goto cra_init_failed; @@ -519,7 +518,6 @@ static void *crypto_alloc_tfmmem(struct crypto_alg *alg, tfm = (struct crypto_tfm *)(mem + tfmsize); tfm->__crt_alg = alg; tfm->node = node; - refcount_set(&tfm->refcnt, 1); return mem; } @@ -649,8 +647,6 @@ void crypto_destroy_tfm(void *mem, struct crypto_tfm *tfm) if (IS_ERR_OR_NULL(mem)) return; - if (!refcount_dec_and_test(&tfm->refcnt)) - return; alg = tfm->__crt_alg; if (!tfm->exit && alg->cra_exit) diff --git a/crypto/internal.h b/crypto/internal.h index 96f84abfac91e..b6e437f463d42 100644 --- a/crypto/internal.h +++ b/crypto/internal.h @@ -10,7 +10,6 @@ #include <crypto/algapi.h> #include <linux/completion.h> -#include <linux/err.h> #include <linux/jump_label.h> #include <linux/list.h> #include <linux/module.h> @@ -209,10 +208,5 @@ static inline int crypto_is_test_larval(struct crypto_larval *larval) return larval->alg.cra_driver_name[0]; } -static inline struct crypto_tfm *crypto_tfm_get(struct crypto_tfm *tfm) -{ - return refcount_inc_not_zero(&tfm->refcnt) ? tfm : ERR_PTR(-EOVERFLOW); -} - #endif /* _CRYPTO_INTERNAL_H */ diff --git a/include/linux/crypto.h b/include/linux/crypto.h index a2137e19be7d8..b7c97f1c47c92 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -409,7 +409,6 @@ int crypto_has_alg(const char *name, u32 type, u32 mask); */ struct crypto_tfm { - refcount_t refcnt; u32 crt_flags; |
