linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Willi <martin@strongswan.org>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	linux-crypto@vger.kernel.org, davem@davemloft.net,
	gregkh@linuxfoundation.org, Samuel Neves <sneves@dei.uc.pt>,
	Andy Lutomirski <luto@kernel.org>,
	Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>,
	Eric Biggers <ebiggers@google.com>
Subject: Re: [PATCH net-next v4 18/20] crypto: port ChaCha20 to Zinc
Date: Sun, 16 Sep 2018 21:51:53 +0200	[thread overview]
Message-ID: <72e893e7efbef428d4fd23b7332d9e829acd5e7d.camel@strongswan.org> (raw)
In-Reply-To: <20180914162240.7925-19-Jason@zx2c4.com>

Hi Jason,

> Now that ChaCha20 is in Zinc, we can have the crypto API code simply
> call into it.

>  delete mode 100644 arch/x86/crypto/chacha20-avx2-x86_64.S
>  delete mode 100644 arch/x86/crypto/chacha20-ssse3-x86_64.S

I did some trivial benchmarking with tcrypt for the ChaCha20Poly1305
AEAD as used by IPsec. This is on a box with AVX2, which is probably
the configuration mostly used these days. With Zinc I get:

> testing speed of rfc7539esp(chacha20,poly1305) (rfc7539esp(chacha20-software,poly1305-software)) decryption
> test 0 (288 bit key, 16 byte blocks): 743510 operations in 1 seconds (11896160 bytes)
> test 1 (288 bit key, 64 byte blocks): 743190 operations in 1 seconds (47564160 bytes)
> test 2 (288 bit key, 256 byte blocks): 701461 operations in 1 seconds (179574016 bytes)
> test 3 (288 bit key, 512 byte blocks): 681567 operations in 1 seconds (348962304 bytes)
> test 4 (288 bit key, 1024 byte blocks): 572854 operations in 1 seconds (586602496 bytes)
> test 5 (288 bit key, 2048 byte blocks): 434477 operations in 1 seconds (889808896 bytes)
> test 6 (288 bit key, 4096 byte blocks): 293553 operations in 1 seconds (1202393088 bytes)
> test 7 (288 bit key, 8192 byte blocks): 173351 operations in 1 seconds (1420091392 bytes)

Using the existing implementation, this was:

> testing speed of rfc7539esp(chacha20,poly1305) (rfc7539esp(chacha20-simd,poly1305-simd)) decryption
> test 0 (288 bit key, 16 byte blocks): 1064524 operations in 1 seconds (17032384 bytes)
> test 1 (288 bit key, 64 byte blocks): 1016046 operations in 1 seconds (65026944 bytes)
> test 2 (288 bit key, 256 byte blocks): 829566 operations in 1 seconds (212368896 bytes)
> test 3 (288 bit key, 512 byte blocks): 778912 operations in 1 seconds (398802944 bytes)
> test 4 (288 bit key, 1024 byte blocks): 622331 operations in 1 seconds (637266944 bytes)
> test 5 (288 bit key, 2048 byte blocks): 441790 operations in 1 seconds (904785920 bytes)
> test 6 (288 bit key, 4096 byte blocks): 280616 operations in 1 seconds (1149403136 bytes)
> test 7 (288 bit key, 8192 byte blocks): 158800 operations in 1 seconds (1300889600 bytes)

I've also experimented with the SIMD context save/restore amortization
from patch one on the existing implementation:

> testing speed of rfc7539esp(chacha20,poly1305) (rfc7539esp(chacha20-simd,poly1305-simd)) decryption
> test 0 (288 bit key, 16 byte blocks): 1088215 operations in 1 seconds (17411440 bytes)
> test 1 (288 bit key, 64 byte blocks): 1001788 operations in 1 seconds (64114432 bytes)
> test 2 (288 bit key, 256 byte blocks): 870193 operations in 1 seconds (222769408 bytes)
> test 3 (288 bit key, 512 byte blocks): 822149 operations in 1 seconds (420940288 bytes)
> test 4 (288 bit key, 1024 byte blocks): 647447 operations in 1 seconds (662985728 bytes)
> test 5 (288 bit key, 2048 byte blocks): 454734 operations in 1 seconds (931295232 bytes)
> test 6 (288 bit key, 4096 byte blocks): 286995 operations in 1 seconds (1175531520 bytes)
> test 7 (288 bit key, 8192 byte blocks): 162028 operations in 1 seconds (1327333376 bytes)

For large blocks your implementation is faster; for typical IPsec MTUs
this degrades performance by ~10% and more.

Martin

  parent reply	other threads:[~2018-09-16 19:57 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-14 16:22 [PATCH net-next v4 00/20] WireGuard: Secure Network Tunnel Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 01/20] asm: simd context helper API Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 02/20] zinc: introduce minimal cryptography library Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 03/20] zinc: ChaCha20 generic C implementation Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 04/20] zinc: ChaCha20 ARM and ARM64 implementations Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 05/20] zinc: ChaCha20 x86_64 implementation Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 06/20] zinc: ChaCha20 MIPS32r2 implementation Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 07/20] zinc: Poly1305 generic C implementations and selftest Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 08/20] zinc: Poly1305 ARM and ARM64 implementations Jason A. Donenfeld
2018-09-14 17:27   ` Ard Biesheuvel
2018-09-14 17:45     ` Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 09/20] zinc: Poly1305 x86_64 implementation Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 10/20] zinc: Poly1305 MIPS32r2 and MIPS64 implementations Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 11/20] zinc: ChaCha20Poly1305 construction and selftest Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 12/20] zinc: BLAKE2s generic C implementation " Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 13/20] zinc: BLAKE2s x86_64 implementation Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 14/20] zinc: Curve25519 generic C implementations and selftest Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 15/20] zinc: Curve25519 ARM implementation Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 16/20] zinc: Curve25519 x86_64 implementation Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 17/20] crypto: port Poly1305 to Zinc Jason A. Donenfeld
2018-09-15 23:02   ` kbuild test robot
2018-09-16  0:31     ` Jason A. Donenfeld
2018-09-15 23:39   ` kbuild test robot
2018-09-14 16:22 ` [PATCH net-next v4 18/20] crypto: port ChaCha20 " Jason A. Donenfeld
2018-09-14 17:38   ` Ard Biesheuvel
2018-09-14 17:49     ` Jason A. Donenfeld
     [not found]   ` <201809160711.HzjdJedZ%fengguang.wu@intel.com>
2018-09-15 23:21     ` Jason A. Donenfeld
2018-09-16 19:51   ` Martin Willi [this message]
2018-09-17  4:54     ` Jason A. Donenfeld
2018-09-17 11:35   ` kbuild test robot
2018-09-14 16:22 ` [PATCH net-next v4 19/20] security/keys: rewrite big_key crypto to use Zinc Jason A. Donenfeld
2018-09-15 23:52   ` kbuild test robot
2018-09-16  0:29     ` Jason A. Donenfeld
2018-09-14 16:22 ` [PATCH net-next v4 20/20] net: WireGuard secure network tunnel Jason A. Donenfeld
2018-09-15 22:17   ` kbuild test robot
2018-09-15 23:14     ` Jason A. Donenfeld
2018-09-15 23:01   ` kbuild test robot
2018-09-15 23:48     ` Jason A. Donenfeld

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=72e893e7efbef428d4fd23b7332d9e829acd5e7d.camel@strongswan.org \
    --to=martin@strongswan.org \
    --cc=Jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=ebiggers@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeanphilippe.aumasson@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sneves@dei.uc.pt \
    /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).