Skip to content

RFC Add bulk skcipher requests to crypto API and dm-crypt

Ondrej Mosnacek dm-devel linux-crypto 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest6 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6crypto: skcipher - Add bulk request processing APIcrypto/Makefile crypto/skcipher.c crypto/skcipher_bulk.c +2 more+658 -10 replies
2/6crypto: skcipher - Add bulk request support to walkcrypto/skcipher.c include/crypto/internal/skcipher.h+153 -490 replies
3/6crypto: cryptd - Add skcipher bulk request supportcrypto/cryptd.c+111 -00 replies
4/6crypto: simd - Add bulk request supportcrypto/simd.c+61 -00 replies
5/6crypto: aesni-intel - Add bulk request supportarch/x86/crypto/aesni-intel_glue.c arch/x86/crypto/glue_helper.c arch/x86/include/asm/crypto/glue_helper.h+221 -712 replies
6/6dm-crypt: Add bulk crypto processing supportdrivers/md/dm-crypt.c+165 -892 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [RFC PATCH 0/6] Add bulk skcipher requests to crypto API and dm-crypt

Hi,

the goal of this patchset is to allow those skcipher API users that need to process batches of small messages (especially dm-crypt) to do so efficiently.

The first patch introduces a new request type (and corresponding encrypt/decrypt functions) to the skcipher API. The new API can be used to submit multiple messages at once, thus enabling the drivers to reduce overhead as opposed to processing each message separately.

The skcipher drivers can provide support for the new request type by setting the corresponding fields of their skcipher_alg structure. If 'native' support is not provided by a driver (i.e. the fields are left NULL), the crypto API transparently provides a generic fallback implementation, which simply processes the bulk request as a set of standard requests on the same tfm.

The second patch extends skcipher_walk so it can be used for processing the new bulk requests, while preserving equivalent functionality when used with standard requests.

The third and fourth patches add native bulk request support to the cryptd and SIMD helper wrappers, respectively.

The fifth patch adds bulk request support to the AES-NI skcipher drivers, in order to provide an example for both implementing the bulk request processing and the usage of the extended skcipher_walk in such implementation. Also, this patch provides a slight optimization, since the kernel_fpu_* functions are called just once per the whole bulk request. Note that both the standard and bulk implementation mostly use the same code under the hood.

The last patch converts dm-crypt to use bulk requests and makes it submit multiple sectors at once, whenever they are stored sequentially within a single page.

With all the patches applied, I was able to measure a small speedup (~5-10%) with AES-NI ciphers and dm-crypt device mapped over a ramdisk.

To-be-done:
testing the bulk API in testmgr.c
documentation update

Ondrej Mosnacek (6):
crypto: skcipher - Add bulk request processing API
crypto: skcipher - Add bulk request support to walk
crypto: cryptd - Add skcipher bulk request support
crypto: simd - Add bulk request support
crypto: aesni-intel - Add bulk request support
dm-crypt: Add bulk crypto processing support

 arch/x86/crypto/aesni-intel_glue.c        | 267 +++++++++++++++++++------
 arch/x86/crypto/glue_helper.c             |  23 +--
 arch/x86/include/asm/crypto/glue_helper.h |   2 +-
 crypto/Makefile                           |   1 +
 crypto/cryptd.c                           | 111 +++++++++++
 crypto/simd.c                             |  61 ++++++
 crypto/skcipher.c                         | 207 +++++++++++++++-----
 crypto/skcipher_bulk.c                    | 312 ++++++++++++++++++++++++++++++
 drivers/md/dm-crypt.c                     | 254 +++++++++++++++---------
 include/crypto/internal/skcipher.h        |  42 +++-
 include/crypto/skcipher.h                 | 299 +++++++++++++++++++++++++++-
 11 files changed, 1369 insertions(+), 210 deletions(-)
 create mode 100644 crypto/skcipher_bulk.c
Signature · 1 line
2.9.3