mbox series

[00/11] Wire up CRC-T10DIF library functions to arch-optimized code

Message ID 20241117002244.105200-1-ebiggers@kernel.org
Headers show
Series Wire up CRC-T10DIF library functions to arch-optimized code | expand

Message

Eric Biggers Nov. 17, 2024, 12:22 a.m. UTC
This patchset is also available in git via:

    git fetch https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git crc-t10dif-lib-v1

This patchset updates the kernel's CRC-T10DIF library functions to be
directly optimized for x86, arm, arm64, and powerpc without taking an
unnecessary and inefficient detour through the crypto API.  It follows
the same approach that I'm taking for CRC32 in the patchset
https://lore.kernel.org/linux-crypto/20241103223154.136127-1-ebiggers@kernel.org

This patchset also adds a CRC KUnit test suite that covers multiple CRC
variants, and deletes some older ad-hoc tests that are obsoleted by it.

This patchset has several dependencies including my CRC32 patchset and
patches queued in several trees for 6.13.  It can be retrieved from git
using the command given above.  This is targeting 6.14.

Eric Biggers (11):
  lib/crc-t10dif: stop wrapping the crypto API
  lib/crc-t10dif: add support for arch overrides
  crypto: crct10dif - expose arch-optimized lib function
  x86/crc-t10dif: expose CRC-T10DIF function through lib
  arm/crc-t10dif: expose CRC-T10DIF function through lib
  arm64/crc-t10dif: expose CRC-T10DIF function through lib
  powerpc/crc-t10dif: expose CRC-T10DIF function through lib
  lib/crc_kunit.c: add KUnit test suite for CRC library functions
  lib/crc32test: delete obsolete crc32test.c
  powerpc/crc: delete obsolete crc-vpmsum_test.c
  MAINTAINERS: add entry for CRC library

 MAINTAINERS                                   |  11 +
 arch/arm/Kconfig                              |   1 +
 arch/arm/crypto/Kconfig                       |  11 -
 arch/arm/crypto/Makefile                      |   2 -
 arch/arm/crypto/crct10dif-ce-glue.c           | 124 ---
 arch/arm/lib/Makefile                         |   3 +
 .../crc-t10dif-core.S}                        |   0
 arch/arm/lib/crc-t10dif-glue.c                |  77 ++
 arch/arm64/Kconfig                            |   1 +
 arch/arm64/configs/defconfig                  |   1 -
 arch/arm64/crypto/Kconfig                     |  10 -
 arch/arm64/crypto/Makefile                    |   3 -
 arch/arm64/crypto/crct10dif-ce-glue.c         | 132 ---
 arch/arm64/lib/Makefile                       |   3 +
 .../crc-t10dif-core.S}                        |   0
 arch/arm64/lib/crc-t10dif-glue.c              |  78 ++
 arch/m68k/configs/amiga_defconfig             |   1 -
 arch/m68k/configs/apollo_defconfig            |   1 -
 arch/m68k/configs/atari_defconfig             |   1 -
 arch/m68k/configs/bvme6000_defconfig          |   1 -
 arch/m68k/configs/hp300_defconfig             |   1 -
 arch/m68k/configs/mac_defconfig               |   1 -
 arch/m68k/configs/multi_defconfig             |   1 -
 arch/m68k/configs/mvme147_defconfig           |   1 -
 arch/m68k/configs/mvme16x_defconfig           |   1 -
 arch/m68k/configs/q40_defconfig               |   1 -
 arch/m68k/configs/sun3_defconfig              |   1 -
 arch/m68k/configs/sun3x_defconfig             |   1 -
 arch/powerpc/Kconfig                          |   1 +
 arch/powerpc/configs/powernv_defconfig        |   1 -
 arch/powerpc/configs/ppc64_defconfig          |   2 -
 arch/powerpc/crypto/Kconfig                   |  20 -
 arch/powerpc/crypto/Makefile                  |   3 -
 arch/powerpc/crypto/crc-vpmsum_test.c         | 133 ---
 arch/powerpc/lib/Makefile                     |   3 +
 .../crc-t10dif-glue.c}                        |  69 +-
 .../{crypto => lib}/crct10dif-vpmsum_asm.S    |   2 +-
 arch/s390/configs/debug_defconfig             |   1 -
 arch/x86/Kconfig                              |   1 +
 arch/x86/crypto/Kconfig                       |  10 -
 arch/x86/crypto/Makefile                      |   3 -
 arch/x86/crypto/crct10dif-pclmul_glue.c       | 143 ---
 arch/x86/lib/Makefile                         |   3 +
 arch/x86/lib/crc-t10dif-glue.c                |  51 ++
 .../{crypto => lib}/crct10dif-pcl-asm_64.S    |   0
 crypto/Kconfig                                |   1 +
 crypto/Makefile                               |   3 +-
 crypto/crct10dif_common.c                     |  82 --
 crypto/crct10dif_generic.c                    |  82 +-
 include/linux/crc-t10dif.h                    |  28 +-
 lib/Kconfig                                   |  43 +-
 lib/Kconfig.debug                             |  20 +
 lib/Makefile                                  |   2 +-
 lib/crc-t10dif.c                              | 156 +---
 lib/crc32test.c                               | 852 ------------------
 lib/crc_kunit.c                               | 428 +++++++++
 .../testing/selftests/arm64/fp/kernel-test.c  |   3 +-
 57 files changed, 867 insertions(+), 1748 deletions(-)
 delete mode 100644 arch/arm/crypto/crct10dif-ce-glue.c
 rename arch/arm/{crypto/crct10dif-ce-core.S => lib/crc-t10dif-core.S} (100%)
 create mode 100644 arch/arm/lib/crc-t10dif-glue.c
 delete mode 100644 arch/arm64/crypto/crct10dif-ce-glue.c
 rename arch/arm64/{crypto/crct10dif-ce-core.S => lib/crc-t10dif-core.S} (100%)
 create mode 100644 arch/arm64/lib/crc-t10dif-glue.c
 delete mode 100644 arch/powerpc/crypto/crc-vpmsum_test.c
 rename arch/powerpc/{crypto/crct10dif-vpmsum_glue.c => lib/crc-t10dif-glue.c} (50%)
 rename arch/powerpc/{crypto => lib}/crct10dif-vpmsum_asm.S (99%)
 delete mode 100644 arch/x86/crypto/crct10dif-pclmul_glue.c
 create mode 100644 arch/x86/lib/crc-t10dif-glue.c
 rename arch/x86/{crypto => lib}/crct10dif-pcl-asm_64.S (100%)
 delete mode 100644 crypto/crct10dif_common.c
 delete mode 100644 lib/crc32test.c
 create mode 100644 lib/crc_kunit.c

Comments

Martin K. Petersen Nov. 19, 2024, 1:33 a.m. UTC | #1
Eric,

> This patchset updates the kernel's CRC-T10DIF library functions to be
> directly optimized for x86, arm, arm64, and powerpc without taking an
> unnecessary and inefficient detour through the crypto API.

LGTM. Always found it odd to have to use the crypto API for this.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Ard Biesheuvel Nov. 19, 2024, 8:59 a.m. UTC | #2
On Sun, 17 Nov 2024 at 01:23, Eric Biggers <ebiggers@kernel.org> wrote:
>
> This patchset is also available in git via:
>
>     git fetch https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git crc-t10dif-lib-v1
>
> This patchset updates the kernel's CRC-T10DIF library functions to be
> directly optimized for x86, arm, arm64, and powerpc without taking an
> unnecessary and inefficient detour through the crypto API.  It follows
> the same approach that I'm taking for CRC32 in the patchset
> https://lore.kernel.org/linux-crypto/20241103223154.136127-1-ebiggers@kernel.org
>
> This patchset also adds a CRC KUnit test suite that covers multiple CRC
> variants, and deletes some older ad-hoc tests that are obsoleted by it.
>
> This patchset has several dependencies including my CRC32 patchset and
> patches queued in several trees for 6.13.  It can be retrieved from git
> using the command given above.  This is targeting 6.14.
>
> Eric Biggers (11):
>   lib/crc-t10dif: stop wrapping the crypto API
>   lib/crc-t10dif: add support for arch overrides
>   crypto: crct10dif - expose arch-optimized lib function
>   x86/crc-t10dif: expose CRC-T10DIF function through lib
>   arm/crc-t10dif: expose CRC-T10DIF function through lib
>   arm64/crc-t10dif: expose CRC-T10DIF function through lib
>   powerpc/crc-t10dif: expose CRC-T10DIF function through lib
>   lib/crc_kunit.c: add KUnit test suite for CRC library functions
>   lib/crc32test: delete obsolete crc32test.c
>   powerpc/crc: delete obsolete crc-vpmsum_test.c
>   MAINTAINERS: add entry for CRC library
>

Nice work. The shash API glue was particularly nasty, so good riddance.

For the series,

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

Happy to take a R: or M: as well, if you need the help.
Zhihang Shao Nov. 19, 2024, 10:29 a.m. UTC | #3
On 2024/11/17 8:22, Eric Biggers wrote:

This patchset is also available in git via:

     git fetch 
https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git 
crc-t10dif-lib-v1

This patchset updates the kernel's CRC-T10DIF library functions to be
directly optimized for x86, arm, arm64, and powerpc without taking an
unnecessary and inefficient detour through the crypto API.  It follows
the same approach that I'm taking for CRC32 in the patchset
https://lore.kernel.org/linux-crypto/20241103223154.136127-1-ebiggers@kernel.org

This patchset also adds a CRC KUnit test suite that covers multiple CRC
variants, and deletes some older ad-hoc tests that are obsoleted by it.

This patchset has several dependencies including my CRC32 patchset and
patches queued in several trees for 6.13.  It can be retrieved from git
using the command given above.  This is targeting 6.14.

Eric Biggers (11):
   lib/crc-t10dif: stop wrapping the crypto API
   lib/crc-t10dif: add support for arch overrides
   crypto: crct10dif - expose arch-optimized lib function
   x86/crc-t10dif: expose CRC-T10DIF function through lib
   arm/crc-t10dif: expose CRC-T10DIF function through lib
   arm64/crc-t10dif: expose CRC-T10DIF function through lib
   powerpc/crc-t10dif: expose CRC-T10DIF function through lib
   lib/crc_kunit.c: add KUnit test suite for CRC library functions
   lib/crc32test: delete obsolete crc32test.c
   powerpc/crc: delete obsolete crc-vpmsum_test.c
   MAINTAINERS: add entry for CRC library

  MAINTAINERS                                   |  11 +
  arch/arm/Kconfig                              |   1 +
  arch/arm/crypto/Kconfig                       |  11 -
  arch/arm/crypto/Makefile                      |   2 -
  arch/arm/crypto/crct10dif-ce-glue.c           | 124 ---
  arch/arm/lib/Makefile                         |   3 +
  .../crc-t10dif-core.S}                        |   0
  arch/arm/lib/crc-t10dif-glue.c                |  77 ++
  arch/arm64/Kconfig                            |   1 +
  arch/arm64/configs/defconfig                  |   1 -
  arch/arm64/crypto/Kconfig                     |  10 -
  arch/arm64/crypto/Makefile                    |   3 -
  arch/arm64/crypto/crct10dif-ce-glue.c         | 132 ---
  arch/arm64/lib/Makefile                       |   3 +
  .../crc-t10dif-core.S}                        |   0
  arch/arm64/lib/crc-t10dif-glue.c              |  78 ++
  arch/m68k/configs/amiga_defconfig             |   1 -
  arch/m68k/configs/apollo_defconfig            |   1 -
  arch/m68k/configs/atari_defconfig             |   1 -
  arch/m68k/configs/bvme6000_defconfig          |   1 -
  arch/m68k/configs/hp300_defconfig             |   1 -
  arch/m68k/configs/mac_defconfig               |   1 -
  arch/m68k/configs/multi_defconfig             |   1 -
  arch/m68k/configs/mvme147_defconfig           |   1 -
  arch/m68k/configs/mvme16x_defconfig           |   1 -
  arch/m68k/configs/q40_defconfig               |   1 -
  arch/m68k/configs/sun3_defconfig              |   1 -
  arch/m68k/configs/sun3x_defconfig             |   1 -
  arch/powerpc/Kconfig                          |   1 +
  arch/powerpc/configs/powernv_defconfig        |   1 -
  arch/powerpc/configs/ppc64_defconfig          |   2 -
  arch/powerpc/crypto/Kconfig                   |  20 -
  arch/powerpc/crypto/Makefile                  |   3 -
  arch/powerpc/crypto/crc-vpmsum_test.c         | 133 ---
  arch/powerpc/lib/Makefile                     |   3 +
  .../crc-t10dif-glue.c}                        |  69 +-
  .../{crypto => lib}/crct10dif-vpmsum_asm.S    |   2 +-
  arch/s390/configs/debug_defconfig             |   1 -
  arch/x86/Kconfig                              |   1 +
  arch/x86/crypto/Kconfig                       |  10 -
  arch/x86/crypto/Makefile                      |   3 -
  arch/x86/crypto/crct10dif-pclmul_glue.c       | 143 ---
  arch/x86/lib/Makefile                         |   3 +
  arch/x86/lib/crc-t10dif-glue.c                |  51 ++
  .../{crypto => lib}/crct10dif-pcl-asm_64.S    |   0
  crypto/Kconfig                                |   1 +
  crypto/Makefile                               |   3 +-
  crypto/crct10dif_common.c                     |  82 --
  crypto/crct10dif_generic.c                    |  82 +-
  include/linux/crc-t10dif.h                    |  28 +-
  lib/Kconfig                                   |  43 +-
  lib/Kconfig.debug                             |  20 +
  lib/Makefile                                  |   2 +-
  lib/crc-t10dif.c                              | 156 +---
  lib/crc32test.c                               | 852 ------------------
  lib/crc_kunit.c                               | 428 +++++++++
  .../testing/selftests/arm64/fp/kernel-test.c  |   3 +-
  57 files changed, 867 insertions(+), 1748 deletions(-)
  delete mode 100644 arch/arm/crypto/crct10dif-ce-glue.c
  rename arch/arm/{crypto/crct10dif-ce-core.S => lib/crc-t10dif-core.S} 
(100%)
  create mode 100644 arch/arm/lib/crc-t10dif-glue.c
  delete mode 100644 arch/arm64/crypto/crct10dif-ce-glue.c
  rename arch/arm64/{crypto/crct10dif-ce-core.S => 
lib/crc-t10dif-core.S} (100%)
  create mode 100644 arch/arm64/lib/crc-t10dif-glue.c
  delete mode 100644 arch/powerpc/crypto/crc-vpmsum_test.c
  rename arch/powerpc/{crypto/crct10dif-vpmsum_glue.c => 
lib/crc-t10dif-glue.c} (50%)
  rename arch/powerpc/{crypto => lib}/crct10dif-vpmsum_asm.S (99%)
  delete mode 100644 arch/x86/crypto/crct10dif-pclmul_glue.c
  create mode 100644 arch/x86/lib/crc-t10dif-glue.c
  rename arch/x86/{crypto => lib}/crct10dif-pcl-asm_64.S (100%)
  delete mode 100644 crypto/crct10dif_common.c
  delete mode 100644 lib/crc32test.c
  create mode 100644 lib/crc_kunit.c

Good job. It's great to see the code being simplified.

I still want to submit an optimization patch about CRC-T10DIF for RISC-V.

I don't know if it would be more appropriate for me to rewrite a patch 
after your patch is officially applied.

What do you think?
Eric Biggers Nov. 19, 2024, 5:46 p.m. UTC | #4
On Tue, Nov 19, 2024 at 09:59:53AM +0100, Ard Biesheuvel wrote:
> > Eric Biggers (11):
> >   lib/crc-t10dif: stop wrapping the crypto API
> >   lib/crc-t10dif: add support for arch overrides
> >   crypto: crct10dif - expose arch-optimized lib function
> >   x86/crc-t10dif: expose CRC-T10DIF function through lib
> >   arm/crc-t10dif: expose CRC-T10DIF function through lib
> >   arm64/crc-t10dif: expose CRC-T10DIF function through lib
> >   powerpc/crc-t10dif: expose CRC-T10DIF function through lib
> >   lib/crc_kunit.c: add KUnit test suite for CRC library functions
> >   lib/crc32test: delete obsolete crc32test.c
> >   powerpc/crc: delete obsolete crc-vpmsum_test.c
> >   MAINTAINERS: add entry for CRC library
> >
> 
> Nice work. The shash API glue was particularly nasty, so good riddance.
> 
> For the series,
> 
> Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
> 
> Happy to take a R: or M: as well, if you need the help.

Thanks Ard.  I will add an R: entry for you in MAINTAINERS.

- Eric
Eric Biggers Nov. 19, 2024, 5:53 p.m. UTC | #5
Hi Zhihang,

On Tue, Nov 19, 2024 at 06:05:58PM +0800, Zhihang Shao wrote:
> 
> I still want to submit an optimization patchabout CRC-T10DIFfor RISC-V.
> 
> I don't know if it would be more appropriate for me to rewrite a patch after
> your patch is officially applied.
> 
> What do you think?

Please go ahead and rebase your patch on top of this patchset, i.e. on top of
the git branch I gave at the beginning of the cover letter.  You'll need to move
your code into arch/riscv/lib/ and drop the shash stuff.  You can test it using
the new KUnit test I added (CONFIG_CRC_KUNIT_TEST=y).

After that I'll be glad to apply your patch when I apply this patchset for 6.14.

Thanks!

- Eric