From: Eric Biggers <ebiggers@kernel.org>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: dm-devel@lists.linux.dev, Alasdair Kergon <agk@redhat.com>,
Mike Snitzer <snitzer@kernel.org>,
Mikulas Patocka <mpatocka@redhat.com>,
linux-kernel@vger.kernel.org,
Sami Tolvanen <samitolvanen@google.com>,
Bart Van Assche <bvanassche@acm.org>
Subject: Re: [PATCH 7/7] dm-verity: hash blocks with shash import+finup when possible
Date: Tue, 2 Jul 2024 17:16:40 +0000 [thread overview]
Message-ID: <20240702171640.GA1049704@google.com> (raw)
In-Reply-To: <CAMj1kXFE45J9fDJ9XtMyJiUP1F-odZUmH0zLKkuZeWL_bLdDZQ@mail.gmail.com>
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
next prev parent reply other threads:[~2024-07-02 17:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 6:48 [PATCH 0/7] dm-verity cleanups and optimizations Eric Biggers
2024-07-02 6:48 ` [PATCH 1/7] dm-verity: move hash algorithm setup into its own function Eric Biggers
2024-07-02 6:48 ` [PATCH 2/7] dm-verity: move data hash mismatch handling " Eric Biggers
2024-07-02 6:48 ` [PATCH 3/7] dm-verity: make real_digest and want_digest fixed-length Eric Biggers
2024-07-02 6:48 ` [PATCH 4/7] dm-verity: provide dma_alignment limit in io_hints Eric Biggers
2024-07-02 7:16 ` Christoph Hellwig
2024-07-02 6:48 ` [PATCH 5/7] dm-verity: always "map" the data blocks Eric Biggers
2024-07-02 6:48 ` [PATCH 6/7] dm-verity: make verity_hash() take dm_verity_io instead of ahash_request Eric Biggers
2024-07-02 6:48 ` [PATCH 7/7] dm-verity: hash blocks with shash import+finup when possible Eric Biggers
2024-07-02 7:41 ` Ard Biesheuvel
2024-07-02 17:16 ` Eric Biggers [this message]
2024-07-03 13:17 ` Ard Biesheuvel
2024-07-03 19:15 ` [PATCH 0/7] dm-verity cleanups and optimizations Eric Biggers
2024-07-04 15:05 ` Mikulas Patocka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240702171640.GA1049704@google.com \
--to=ebiggers@kernel.org \
--cc=agk@redhat.com \
--cc=ardb@kernel.org \
--cc=bvanassche@acm.org \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatocka@redhat.com \
--cc=samitolvanen@google.com \
--cc=snitzer@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.