Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5540338ybp; Tue, 8 Oct 2019 04:39:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyp9Emo0vYpvTs4f54KsBLGRr3yC9I6/n4SaAdIaKbzre52ZvXWrF2DcB0Nn2m+VU/x4OZF X-Received: by 2002:a50:fa09:: with SMTP id b9mr33599108edq.165.1570534750766; Tue, 08 Oct 2019 04:39:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570534750; cv=none; d=google.com; s=arc-20160816; b=IfK3iLsOmR2UoQlEXmiaIuDDKLd3KK2aJ52mJSmX6RKQqVdS1rJEWWJlRvwRd+YhpA XKx612Xmn/jXBQCe+E9MMRIbZLATzbQzjr61h14NNL8CJpoNReC2Y7Uce+hFVuOWmwsl Zx1wNlaSORpNFa2Gu6MJ7XiKbYszBFWQ7FQS2WzlStKZAgOQ+VSVKsFwPnmotrW8qtAh 80ZWFrz3tzkuGnletCc2+ECY/I8pqH6CKhI5C7/ovRxrDclFBi/HM6xp+0Si+KVc0stQ UvFxzZSU0CjT2oleyAN7jUT4kaKRV7sTLWc2n8TvrK/TZkkeQxshrqGAaEOEkcauxack vawQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=E0w6kl3R1ZHB2CAUvXr+VflLYCvARCAbvltXdlAInKk=; b=q63jBiN1sJWc/N0+sQVUASG5nPbM4ivYeBapd/Ln/l5O4YX44rQx6lIN4fqbF2IvIn To0HGD6iYh03/ZD4feOVNxfGSDy29lNOIPvKyQbRHHmaR5Z68pmfMwV3OJ1XosFc0go3 E/Amx6H3GXBSpQRzNFYbtmxfLrv3LGqlbwmYO50SG+auO6ALlhAUYyRMKAv6BLGSZBeq jZsFrvj25uDzXS584Fm4HZZIQKCfpaWxPlKh4t/la/VL7WgsnwNVVe0l8MvEroBWLYEB tm9RenAABjhZpArgO3N1mfYyh818kBhybpyOoJ8YePcSUhcVVLHZdJZtZ9XiEo1wN0lF y3BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cryptogams.org header.s=gmail header.b=EHsaVef7; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 p15si10434003eda.294.2019.10.08.04.38.45; Tue, 08 Oct 2019 04:39:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@cryptogams.org header.s=gmail header.b=EHsaVef7; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730690AbfJHLin (ORCPT + 99 others); Tue, 8 Oct 2019 07:38:43 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:35668 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730608AbfJHLim (ORCPT ); Tue, 8 Oct 2019 07:38:42 -0400 Received: by mail-ed1-f67.google.com with SMTP id v8so15340306eds.2 for ; Tue, 08 Oct 2019 04:38:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cryptogams.org; s=gmail; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=E0w6kl3R1ZHB2CAUvXr+VflLYCvARCAbvltXdlAInKk=; b=EHsaVef7VY9FmLzaZBPtiviWYFsXPScBumrIAFYiN5iUmzIvdeC+P314lWdhoyQmBo +DHKjSpLlmKEhovGscI9FF7oi5PelcBySsMWUcHRDzgYfy7luzEEqFL4cmPz6B9KldJN oabn6ZSi86osLECYxS4kBD+4ZqBgg+Dn5M8AcN5/xmTDY7y3njs6jK/C9ykm6Z1CyVfi BjfXhoJlfJ717VIDR7+h78wAWcreDDXSshRYQrFScECj388EbyZ3Gjbk+yBL/NIypGXM xJ4AKXg4t4alizS0NOAI1X3a6DpGvT7iPB0YAR5AXTEfQpaahn8hbwd0wondzm5NbuDo 5rjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=E0w6kl3R1ZHB2CAUvXr+VflLYCvARCAbvltXdlAInKk=; b=p6SYCz4n2Xz8NE2UspwOcKMqfhswP8Tb+IFgHXB2Hyh5jbasK3c+L9MCxwaGWOh8Le qYgyRsKfXFR3+NB2qM9ZMItK4NWmnk+VjsPr3wdt42nRa9AeKFMrp3l25ZhgWHnRxMdk dgePz3Wt6ZuKFFaMjZmruvcenAn/XIJO2oW+sBK8gY7DCu8JPnC0ydKkIHT3fBME2nM1 eJ0PIUKMkASpHZ4gQxvSonU0Mwcl3EvCQHDOg47qbO4fItSMl+as43s0liA+MySVIfnD 8cjISvimC7V6BOMDxLmhvczm5EYEMxM9fjBj57vyktlwAkLCD+/LJQUCUw4QNsFXbBPU 5ECw== X-Gm-Message-State: APjAAAXXz4PUXO7eUOzvabkyrLeBcsH6dymZzf3kURCO+G2r36QNAG+O 6BKvYf+ycrDET0Ts4SxJw2QZ8Q== X-Received: by 2002:aa7:d698:: with SMTP id d24mr33865221edr.32.1570534721209; Tue, 08 Oct 2019 04:38:41 -0700 (PDT) Received: from ?IPv6:2001:6b0:2:2f1a:d6be:d9ff:feb7:f247? ([2001:6b0:2:2f1a:d6be:d9ff:feb7:f247]) by smtp.gmail.com with ESMTPSA id b16sm2273358eju.74.2019.10.08.04.38.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Oct 2019 04:38:40 -0700 (PDT) Subject: Re: [PATCH v3 19/29] crypto: mips/poly1305 - incorporate OpenSSL/CRYPTOGAMS optimized implementation To: =?UTF-8?Q?Ren=c3=a9_van_Dorst?= , Ard Biesheuvel Cc: linux-crypto@vger.kernel.org, Herbert Xu , David Miller , "Jason A . Donenfeld" , Samuel Neves , Arnd Bergmann , Eric Biggers , Andy Lutomirski , Martin Willi References: <20191007164610.6881-1-ard.biesheuvel@linaro.org> <20191007164610.6881-20-ard.biesheuvel@linaro.org> <20191007210242.Horde.FiSEhRSAuhKHgFx9ROLFIco@www.vdorst.com> From: Andy Polyakov Message-ID: Date: Tue, 8 Oct 2019 13:38:39 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191007210242.Horde.FiSEhRSAuhKHgFx9ROLFIco@www.vdorst.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Hi, On 10/7/19 11:02 PM, René van Dorst wrote: > Quoting Ard Biesheuvel : > >> This is a straight import of the OpenSSL/CRYPTOGAMS Poly1305 >> implementation >> for MIPS authored by Andy Polyakov, and contributed by him to the OpenSSL >> project. Formally speaking this is a little bit misleading statement. Cryptogams poly1305-mips module implements both 64- and 32-bit code paths, while what you'll find in OpenSSL is 64-only implementation. But in either case... >> > > Hi Ard, > > Is it also an option to include my mip32r2 optimized poly1305 version? > > Below the results which shows a good improvement over the Andy Polyakov > version. > I swapped the poly1305 assembly file and rename the function to > _mips > Full WireGuard source with the changes [0] > > bytes |  RvD | openssl | delta | delta / openssl >  ... >  4096 | 9160 | 11755   | -2595 | -22,08% I assume that the presented results depict regression after switch to cryptogams module. Right? RvD implementation distinguishes itself in two ways: 1. some of additions in inner loop are replaced with multiply-by-1-n-add; 2. carry chain at the end of the inner loop is effectively fused with beginning of the said loop/taken out of the loop. I recall attempting 1. and chosen not to do it with following rationale. On processor I have access to, Octeon II, it made no significant difference. It was better, but only marginally. And it's understandable, because Octeon II should have lesser difficulty pairing those additions with multiply-n-add instructions. But since multiplication is an expensive operation, it can be pretty slow, I reckoned that on processor less potent than Octeon II it might be more appropriate to minimize amount of multiplication-n-add instructions. In other words idea is not (and never has been) to get fixated on specific processor at hand, but try to find a sensible compromise that would produce reasonable performance on a range of processors. Of course problem is that it's just an assumption I made here, and it could turn wrong in practice:-) So I wonder which processor do you run on, René? For reference I measure >70MB/sec for 1KB blocks for chacha20poly1305 on 1GHz Octeon II. You report ~34MB/sec, so it ought to be something different. Given second data point it might be appropriate to reconsider and settle for multiply-by-1-n-add. As for 2. I haven't considered it. Since it's a back-to-back dependency chain, if fused with top of the loop, it actually has more promising potential than 1. And it would improve all results, not only MISP32R2. Would you trust me with adopting it to my module? Naturally with due credit. Cheers.