[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240702171640.GA1049704@google.com>
Date: Tue, 2 Jul 2024 17:16:40 +0000
From: Eric Biggers <ebiggers@...nel.org>
To: Ard Biesheuvel <ardb@...nel.org>
Cc: dm-devel@...ts.linux.dev, Alasdair Kergon <agk@...hat.com>,
Mike Snitzer <snitzer@...nel.org>,
Mikulas Patocka <mpatocka@...hat.com>, linux-kernel@...r.kernel.org,
Sami Tolvanen <samitolvanen@...gle.com>,
Bart Van Assche <bvanassche@....org>
Subject: Re: [PATCH 7/7] dm-verity: hash blocks with shash import+finup when
possible
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
Powered by blists - more mailing lists