Hi Ard, On Tue, Jul 02, 2024 at 09:41:19AM +0200, Ard Biesheuvel wrote: > > int verity_hash(struct dm_verity *v, struct dm_verity_io *io, > > const u8 *data, size_t len, u8 *digest, bool may_sleep) > > { > > - struct ahash_request *req = verity_io_hash_req(v, io); > > int r; > > - struct crypto_wait wait; > > - > > - r = verity_hash_init(v, req, &wait, may_sleep); > > - if (unlikely(r < 0)) > > - goto out; > > > > - r = verity_hash_update(v, req, data, len, &wait); > > - if (unlikely(r < 0)) > > - goto out; > > + if (static_branch_unlikely(&ahash_enabled) && !v->shash_tfm) { > > Is the static key really worth the hassle? Couldn't this just be > > if (unlikely(!v->shash_tfm)) { > > so that the ahash logic is moved to the cold path? We need to > dereference v->shash_tfm right away in any case, and if it is never > NULL, the branch predictor should be able to remember that. The value of the static key is indeed marginal. I included it because of the precedent of dm-verity's existing use_bh_wq_enabled static key, which exists for a similar purpose. As long as we're going through the trouble of doing that, I think it makes sense to use the same pattern for ahash too. It's another rarely needed option that can be patched in in the very rare case that it's needed. - Eric