Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp3234365imm; Sun, 16 Sep 2018 13:01:11 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZfrkZtOEb5NL9RLt6lGN6YLEP53Hs4BC5duGv1WzudB//eJ9ZDmHQakTzPfK2twvV7yJoF X-Received: by 2002:a17:902:e00b:: with SMTP id ca11-v6mr21411245plb.224.1537128071624; Sun, 16 Sep 2018 13:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537128071; cv=none; d=google.com; s=arc-20160816; b=sl/4czzDsmx3Kxm3lLvP9rnehDITALnBRIE3lQrC6zDZXO+5y4C8RTSb+toq5zyV8K D4GqTm2CNt40t1JbWa77Zw8emu0towGzWJNK3kUFjvPOi3vApWQgJpzZmgMC/rNa9qEv v1xmsEo0dYjQBuUZEokzri6zkKlgr2VMJhSucQePcuiifvNVXM1Q6nKiSgv9mYzlUyBa zDB4nhkDs7iD0P6sNp2XlkJZt2X/VDTyNeNqNGAzD1ZaKAgFcpqo8o05H784Ru/51dMY 4ifmWX+D1GEOB7QdnEg+NbhazlsaHlpGEMBOGlsdTdgSBl/mCJfCFyPq8BKEsiwWB/YH lAQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=/5+1qmnkM8rsJZdUYICeJ9+O7tG+JAdfvgtk31l0m2c=; b=IyLQYjMI3gVCkJ8QjLI21g5dCEc7DTRvJs5T6U9/Pe7UANpJg1yB958GhZgCFZMm9A C/074UOyfZ73HCH0AOhjJrhGCk/9XIEvjyyZD8PViqYP0SCPnf3zXfU4uNZ6HuIeYzUq 9yUKQk6aAcb2a8PpuOPv76bhVB4LirnmhzkvBrPuPz9vFBHbWJD/rZKsZbGwah8EjVTb C3S+D3JS5vgQYaXBd2eOVX/bkUc25jfp4OWMswWL/FL3jUTqzFuSIg0EK9q2K1hsanuK 8y9NwVlciAkZdUa5AcwTZzFcdFaVquQE0gy7CzYWDqjuAwZ5xKUaLdDn+cduRhfnRB+3 /FDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c72-v6si13774557pfb.178.2018.09.16.13.00.39; Sun, 16 Sep 2018 13:01:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728532AbeIQBVM (ORCPT + 99 others); Sun, 16 Sep 2018 21:21:12 -0400 Received: from sitav-80046.hsr.ch ([152.96.80.46]:52733 "EHLO mail.strongswan.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728474AbeIQBVM (ORCPT ); Sun, 16 Sep 2018 21:21:12 -0400 X-Greylist: delayed 314 seconds by postgrey-1.27 at vger.kernel.org; Sun, 16 Sep 2018 21:21:10 EDT Received: from book (unknown [IPv6:2a01:2a8:8506:9001:6fd1:b471:395b:f578]) by mail.strongswan.org (Postfix) with ESMTPSA id 51D1140196; Sun, 16 Sep 2018 21:51:58 +0200 (CEST) Message-ID: <72e893e7efbef428d4fd23b7332d9e829acd5e7d.camel@strongswan.org> Subject: Re: [PATCH net-next v4 18/20] crypto: port ChaCha20 to Zinc From: Martin Willi To: "Jason A. Donenfeld" Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-crypto@vger.kernel.org, davem@davemloft.net, gregkh@linuxfoundation.org, Samuel Neves , Andy Lutomirski , Jean-Philippe Aumasson , Eric Biggers Date: Sun, 16 Sep 2018 21:51:53 +0200 In-Reply-To: <20180914162240.7925-19-Jason@zx2c4.com> References: <20180914162240.7925-1-Jason@zx2c4.com> <20180914162240.7925-19-Jason@zx2c4.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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