mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Leonid Ravich <lravich@amazon.com>
Cc: linux-crypto@vger.kernel.org, dm-devel@lists.linux.dev,
	davem@davemloft.net, ebiggers@kernel.org, agk@redhat.com,
	snitzer@kernel.org, mpatocka@redhat.com, bmarzins@redhat.com,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 0/6] crypto: skcipher - multi-data-unit request splitting
Date: Fri, 2 Oct 2026 17:47:26 +1000	[thread overview]
Message-ID: <ar9hjvFGLUKv3lEM@gondor.apana.org.au> (raw)
In-Reply-To: <20260924075846.28203-1-lravich@amazon.com>

On Thu, Sep 24, 2026 at 07:58:40AM +0000, Leonid Ravich wrote:
>
> 1. "Could you send me the patch so I can take a look?" (per-unit cost)
> ---------------------------------------------------------------------
> 
> Patch 4 is that patch -- the API-layer split, self-contained in
> crypto/skcipher.c.  The cost I measured, and where I believe it goes:
> 
> An in-kernel microbench of skcipher_crypt_unit() against the legacy
> per-unit loop (identical inner AES, VAES-AVX512, r7i.metal) shows a
> fixed ~48-52 ns per data unit, CV <1%, and it is the *same* ~50 ns
> for a 512 B unit and a 4096 B unit -- so it is per-call setup, not a
> crypto effect.  Against ~70 ns of VAES work for a 512 B sector that
> is ~+70% on the crypto call itself; end-to-end in dm-crypt it is
> ~2% of an ~18 us I/O and does not show up in fio at all (see the
> Performance section below).

I think the issue is that we're generating the IV twice.  Once
in the Crypto API and once again in the DM layer.  Not only is
this slow, but it is actually wrong for decryption.  You're ignoring
the IVs on the disk.

We really should only do it once, either in the DM layer or in
the Crypto API.  It should be transmitted via memory to the other
side.

My suggestion is to allocate memory for the IVs.  Of course
memory allocation can fail, but we have an easy fallback, which
is to use the existing single-unit path.

IOW if you succeed in allocating memory for storing the IVs,
then invoke the multi-unit code path, otherwise fall back to
the single-unit code path which iterates over the sectors one-
by-one.

To pass the IVs to the Crypto API (or back), just use the existing
IV pointer and extend it by the number of units.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  parent reply	other threads:[~2026-10-02  7:47 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24  7:58 Leonid Ravich
2026-09-24  7:58 ` [PATCH v6 1/6] crypto: skcipher - add per-request unit_size Leonid Ravich
2026-09-24  7:58 ` [PATCH v6 2/6] crypto: acomp - Add bit to indicate segmentation support Leonid Ravich
2026-09-24  7:58 ` [PATCH v6 3/6] crypto: skcipher - add crypto_skcipher_req_seg() helper Leonid Ravich
2026-09-24  7:58 ` [PATCH v6 4/6] crypto: skcipher - split multi-unit requests in the API layer Leonid Ravich
2026-09-24  7:58 ` [PATCH v6 5/6] crypto: testmgr - test multi-unit dispatch Leonid Ravich
2026-09-24  7:58 ` [PATCH v6 6/6] dm crypt: batch a bio segment's sectors via multi-unit requests Leonid Ravich
2026-09-25  9:10 ` [PATCH v6 0/6] crypto: skcipher - multi-data-unit request splitting Christoph Hellwig
2026-09-27  7:14   ` Leonid Ravich
2026-09-28  5:33     ` Christoph Hellwig
2026-10-02  7:47 ` Herbert Xu [this message]
2026-10-04  9:51   ` Leonid Ravich

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=ar9hjvFGLUKv3lEM@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=agk@redhat.com \
    --cc=bmarzins@redhat.com \
    --cc=davem@davemloft.net \
    --cc=dm-devel@lists.linux.dev \
    --cc=ebiggers@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lravich@amazon.com \
    --cc=mpatocka@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®