linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org, fsverity@lists.linux.dev,
	dm-devel@lists.linux.dev, x86@kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Ard Biesheuvel <ardb@kernel.org>,
	Sami Tolvanen <samitolvanen@google.com>,
	Bart Van Assche <bvanassche@acm.org>
Subject: Re: [PATCH v4 6/8] fsverity: improve performance by using multibuffer hashing
Date: Wed, 5 Jun 2024 11:58:13 -0700	[thread overview]
Message-ID: <20240605185813.GA1222@sol.localdomain> (raw)
In-Reply-To: <ZmAthcxC8V3V3sm3@gondor.apana.org.au>

On Wed, Jun 05, 2024 at 05:19:01PM +0800, Herbert Xu wrote:
> On Tue, Jun 04, 2024 at 11:42:20AM -0700, Eric Biggers wrote:
> >
> > This doesn't make any sense, though.  First, the requests need to be enqueued
> > for the task, but crypto_ahash_finup() would only have the ability to enqueue it
> > in a queue associated with the tfm, which is shared by many tasks.  So it can't
> 
> OK I screwed up that one.  But that's not hard to fix.  We could
> simply add request chaining:
> 
> 	ahash_request_chain(req1, req2);
> 	ahash_request_chain(req2, req3);
> 	...
> 	ahash_request_chain(reqn1, reqn);
> 
> 	err = crypto_ahash_finup(req1);

So after completely changing several times your proposal is getting a bit closer
to mine, but it still uses a very clumsy API based around ahash that would be
much harder to use and implement correctly.  It also says nothing about what the
API would look like on the shash side, which would be needed anyway because
ahash is almost always just a pointless wrapper for shash.  Is there a different
API that you are asking for on the shash side?  If so, what?

> > actually work unless the tfm maintained a separate queue for each task, which
> > would be really complex.  Second, it adds a memory allocation per block which is
> > very undesirable.  You claim that it's needed anyway, but actually it's not;
> > with my API there is only one initial hash state regardless of how high the
> > interleaving factor is.  In fact, if multiple initial states were allowed,
> 
> Sure you don't need it for two interleaved requests.  But as you
> scale up to 16 and beyond, surely at some point you're going to
> want to move the hash states off the stack.

To reiterate, with my proposal there is only one state in memory.  It's a simple
API that can't be misused by providing inconsistent properties in the requests.
Yes, separate states would be needed if we were to support arbitrary updates,
but why add all that complexity before it's actually needed?

Also, "16 and beyond" is highly unlikely to be useful for kernel use cases.

> > multibuffer hashing would become much more complex because the underlying
> > algorithm would need to validate that these different states are synced up.  My
> > proposal is much simpler and avoids all this unnecessary overhead.
> 
> We could simply state that these chained requests must be on block
> boundaries, similar to how we handle block ciphers.  This is not a
> big deal.

... which would make it useless for most dm-verity users, as dm-verity uses a
32-byte salt with SHA-256 (which has a 64-byte block size) by default.

> 
> > Really the only reason to even consider ahash at all would be try to support
> > software hashing and off-CPU hardware accelerators using the "same" code.
> > However, your proposal would not achieve that either, as it would not use the
> > async callback.  Note, as far as I know no one actually cares about off-CPU
> > hardware accelerator support in fsverity anyway...
> 
> The other thing is that verity doesn't benefit from shash at all.
> It appears to be doing kmap's on every single request.

The diff from switching fsverity from ahash to shash clearly demonstrates
otherwise.  Yes, fsverity has to map the pages to pass into shash, but that's a
very minor thing compared to all the complexity of ahash that was saved.  And
fsverity already had to map most of the pages anyway to access them.

- Eric

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2024-06-05 18:58 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-03 18:37 [PATCH v4 0/8] Optimize dm-verity and fsverity using multibuffer hashing Eric Biggers
2024-06-03 18:37 ` [PATCH v4 1/8] crypto: shash - add support for finup_mb Eric Biggers
2024-06-04 18:55   ` Ard Biesheuvel
2024-06-04 19:25     ` Eric Biggers
2024-06-03 18:37 ` [PATCH v4 2/8] crypto: testmgr - generate power-of-2 lengths more often Eric Biggers
2024-06-03 18:37 ` [PATCH v4 3/8] crypto: testmgr - add tests for finup_mb Eric Biggers
2024-06-03 18:37 ` [PATCH v4 4/8] crypto: x86/sha256-ni - add support " Eric Biggers
2024-06-03 18:37 ` [PATCH v4 5/8] crypto: arm64/sha256-ce " Eric Biggers
2024-06-04 19:00   ` Ard Biesheuvel
2024-06-03 18:37 ` [PATCH v4 6/8] fsverity: improve performance by using multibuffer hashing Eric Biggers
2024-06-04  9:37   ` Herbert Xu
2024-06-04 18:42     ` Eric Biggers
2024-06-05  9:19       ` Herbert Xu
2024-06-05  9:22         ` Herbert Xu
2024-06-05  9:46           ` Herbert Xu
2024-06-05 19:14             ` Eric Biggers
2024-06-06  2:00               ` Herbert Xu
2024-06-06  5:28                 ` Eric Biggers
2024-06-06  5:41                   ` Herbert Xu
2024-06-06  6:58                     ` Ard Biesheuvel
2024-06-06  7:34                       ` Herbert Xu
2024-06-06  7:55                         ` Ard Biesheuvel
2024-06-06  8:08                           ` Herbert Xu
2024-06-06  8:33                             ` Ard Biesheuvel
2024-06-06  9:15                               ` Herbert Xu
2024-06-10 16:42                                 ` Eric Biggers
2024-06-11 15:21                                   ` Herbert Xu
2024-06-11 15:39                                     ` Herbert Xu
2024-06-11 20:32                                       ` Eric Biggers
2024-06-11 15:46                                     ` Ard Biesheuvel
2024-06-11 15:51                                       ` Herbert Xu
2024-06-11 20:18                                     ` Eric Biggers
2024-06-05 18:58         ` Eric Biggers [this message]
2024-06-03 18:37 ` [PATCH v4 7/8] dm-verity: hash blocks with shash import+finup when possible Eric Biggers
2024-06-03 18:37 ` [PATCH v4 8/8] dm-verity: improve performance by using multibuffer hashing Eric Biggers

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=20240605185813.GA1222@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=ardb@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=dm-devel@lists.linux.dev \
    --cc=fsverity@lists.linux.dev \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=samitolvanen@google.com \
    --cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).