On Wed, Feb 15, 2023 at 05:25:13PM +0800, Herbert Xu wrote: > Move all stat code specific to hash into the hash code. > > While we're at it, change the stats so that bytes and counts > are always incremented even in case of error. This allows the > reference counting to be removed as we can now increment the > counters prior to the operation. > > After the operation we simply increase the error count if necessary. > This is safe as errors can only occur synchronously (or rather, > the existing code already ignored asynchronous errors which are > only visible to the callback function). > > Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> > --- > > crypto/ahash.c | 82 +++++++++++++++++------------ > crypto/algapi.c | 24 -------- > crypto/crypto_user_stat.c | 38 ------------- > crypto/hash.h | 37 +++++++++++++ > crypto/shash.c | 128 ++++++++++++++++++++++++++++++++++++---------- > include/crypto/hash.h | 85 +++++++++++++++++++++++------- > include/linux/crypto.h | 20 ------- > 7 files changed, 250 insertions(+), 164 deletions(-) This patch is causing the 'BUG_ON(refcount_read(&alg->cra_refcnt) != 1);' in crypto_unregister_alg() to be hit at boot time. Most likely related to the way the algorithm structs are being rearranged (which really ought to be explained in the commit message). - Eric