Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4225456pxu; Mon, 30 Nov 2020 22:35:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzPEr8P21b9+b+0aroK1fkKDi3iXsw0d972ON/8zu46Y/0XJWpPGdr5q0MSDrrxnP9NJ4l1 X-Received: by 2002:a17:906:54c8:: with SMTP id c8mr1562222ejp.253.1606804518956; Mon, 30 Nov 2020 22:35:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606804518; cv=none; d=google.com; s=arc-20160816; b=FWEgXHupxZ/a05K8XVHd64hY6LZyGTbl0OP7QASPjST8u0SjlXUz2IXDoutYrg/Ho2 VLlw57/2DOJhIi/1ivk3OeIHMfunUAu40Bjr4iSmwikkp5gr3/MjvwTMcnQjexozzB3J OCt8xql4nLNob0pRTDAl5uCPjuR+tfDrR64kkLlH3JIs9eFY6Jq918C1NPz1oQpcTloL NGbQ1CZw70DxL3X2Fjo6KxB2Blz+S3yvF9IZBoa9vsvxehyb40Ia+DI1ptre1H9xBHil cSPvDeIWq0H3BtFJDI4Mf3pgIbgyw+u56vPKyYetcEMlqH815D204EpB85h2ptBhYdch NwyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xBrtRpaQwiAljlt4qMCprE6FcEp2pWgGElluAa7sXpE=; b=T8x5nzocylHF0+ZaI/BjzUD4vDUlRi5qyp/BqV9fPP6u72oVtFWrX3nWE3fbR1mQH/ fP0Q55mpVLSnWiV2G6p+0A6DGnLmk3r3bSN4QD5rciTy1uMYaTgL5ApXDSbxN3DsbIFo 6QOvEbEL1RpTgDasT96Ja8tZtfnobZhrQtYGtNML/ywYaPU618FUY023BxLK6SuFL3lQ TpcDDAcWx1q4DjJ2i5eTYPXiwB7HDD0iA7UEAa7eGmUCDep58NXUWUCLJZUqUmYAiwwO XKR3VGpx/Xo5LLxXPoy7F4SPLisQD+cjP3IyPITs3cL0gD4cepzQPR/5br/n31uuIKBi k7SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KleEj1Fl; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si568570edj.260.2020.11.30.22.34.46; Mon, 30 Nov 2020 22:35:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KleEj1Fl; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727031AbgLAGdj (ORCPT + 99 others); Tue, 1 Dec 2020 01:33:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:38968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725859AbgLAGdj (ORCPT ); Tue, 1 Dec 2020 01:33:39 -0500 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8AA8820857 for ; Tue, 1 Dec 2020 06:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1606804378; bh=WdEJMU9jhUlyte7Ihqk7bKUBHAhWuc4AeFSkrg1ryQ0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KleEj1FlgLh5SUZ6zafBrFB/jc89eDhNjUyOCTyek/LI6TU+0aVgqwwOLrehK05eC wD3AIfIIeZr1F9mwdNW4EB0eTX9PhQokJNaDRu1jYw+lFMawoVrIE+lJmb4dIqTV8K IQstyjuny5g8j0uN6WLUDjdPzBbUXZ4fcoa/iW70= Received: by mail-ot1-f50.google.com with SMTP id f16so650827otl.11 for ; Mon, 30 Nov 2020 22:32:58 -0800 (PST) X-Gm-Message-State: AOAM531SgMttjcl+GfGzufkTvgVHDuSN+2qbgYj9gL8H4JpitU/8lslw 3dOOSnwxiCjq7Z6lCljZQYsR3DTkKUufogjNL5w= X-Received: by 2002:a05:6830:3099:: with SMTP id f25mr876717ots.77.1606804377750; Mon, 30 Nov 2020 22:32:57 -0800 (PST) MIME-Version: 1.0 References: <20201129182035.7015-1-ardb@kernel.org> <4e850713-af8b-f81f-bf3d-f4ee5185d99f@candelatech.com> In-Reply-To: <4e850713-af8b-f81f-bf3d-f4ee5185d99f@candelatech.com> From: Ard Biesheuvel Date: Tue, 1 Dec 2020 07:32:46 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] crypto: aesni - add ccm(aes) algorithm implementation To: Ben Greear Cc: Linux Crypto Mailing List , Herbert Xu , Steve deRosier Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, 30 Nov 2020 at 23:48, Ben Greear wrote: > > On 11/29/20 10:20 AM, Ard Biesheuvel wrote: > > From: Steve deRosier > > > > Add ccm(aes) implementation from linux-wireless mailing list (see > > http://permalink.gmane.org/gmane.linux.kernel.wireless.general/126679). > > > > This eliminates FPU context store/restore overhead existing in more > > general ccm_base(ctr(aes-aesni),aes-aesni) case in MAC calculation. > > > > Suggested-by: Ben Greear > > Co-developed-by: Steve deRosier > > Signed-off-by: Steve deRosier > > Signed-off-by: Ard Biesheuvel > > --- > > Ben, > > > > This is almost a rewrite of the original patch, switching to the new > > skcipher API, using the existing SIMD helper, and drop numerous unrelated > > changes. The basic approach is almost identical, though, so I expect this > > to perform on par or perhaps slightly faster than the original. > > > > Could you please confirm with some numbers? > > I tried this on my apu2 platform, here is perf top during a TCP download using > rx-sw-crypt (ie, the aesni cpu decrypt path): > > 18.77% [kernel] [k] acpi_idle_enter > 14.68% [kernel] [k] kernel_fpu_begin > 4.45% [kernel] [k] __crypto_xor > 3.46% [kernel] [k] _aesni_enc1 > > Total throughput is 127Mbps or so. This is with your patch applied to 5.8.0+ > kernel (it applied clean with 'git am') > > Is there a good way to verify at runtime that I've properly applied your patch? > > On my 5.4 kernel with the old version of the patch installed, I see 253Mbps throughput, > and perf-top shows: > > 13.33% [kernel] [k] acpi_idle_do_entry > 9.21% [kernel] [k] _aesni_enc1 > 4.49% [unknown] [.] 0x00007fbc3f00adb6 > 4.34% [unknown] [.] 0x00007fbc3f00adba > 3.85% [kernel] [k] memcpy > > > So, new patch is not working that well for me... > That is odd. The net number of invocations of kernel_fpu_begin() should be the same, so I cannot explain why they suddenly take more time. I am starting to think that this is a different issue altogether. One thing that you could try is dropping the '.cra_alignmask' line as we don't actually need it, but I am skeptical that this is the cause of this.