Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1740202imm; Thu, 19 Jul 2018 07:10:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcH2M+jq16Q6ldVhdx7h4NgEmHWSw+1BAHvkQCyWHcCSOe2jUTkto3uDYzIwn/0clp5vEBE X-Received: by 2002:a17:902:6193:: with SMTP id u19-v6mr10158755plj.133.1532009400130; Thu, 19 Jul 2018 07:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532009400; cv=none; d=google.com; s=arc-20160816; b=iM13aZsLGx4mBLE4WJp1D4HuLKjTMcZ2+BhHcAM0zP4Fw6bCMZ9vO6J45wyFEM7Bpq t5nDayz51l0MO7YhbrAKMG2cDboUS/e4GmfuyXFhlMJIFVobq323NDO0z2PIGy2nbEtp uMfJXhLU9iiGXTsA1i6+wS1bbxRh8gD7AFmFVmE0w/xEzdx/G4nyRN7r80SXRcpKGN4a i0qMRdemWr4FfmMGCiKPTAi9IR3Tc/i4e1Tzq5x3Wv7wJigmichVUKcC2Dd9AFsjGWZj CmyxkNxyxvXEGY77IWBHnYlf8RsrkgX7MH6/3sDNIKUmmZKh4arNtRdd/RYXbN2N02lC Bhdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=dkWjQNn9a0ArV0jfLRsfivyiS66V30i3wp2Sc6sigk0=; b=mT9TLPnQFcnJC5MEMINEfCXA7OB83lYTnGpIVu0IOWy5WZ2HEtssP2OoCNg89quBk+ NkIJPF8PpbAGdudWf8QXP3fXRlDSuuUUGinNzkuQ6N7gYLqXwdxIqNHidQNvrqAu3WI/ dumC3WDfC4mXAu4D3OrP4LsRD7rSVraiCTgkE1/UfI5lqlAF3k5M0D/Ct16113pYUQtT dCJRHH+qRBMHe0kX+kgxaMF4+039/CXMuu3PTCDzGTO1KwRRWNsqfnCoyG0DvtexFmya TV5qZKpnFeQmoYaqbfVqvL8yg+iGWoAoLE45865v9FDdCVhqVo7Nt30S2TUCjKHp0Nkm NbgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BGdPGBLr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r7-v6si5712388pgn.491.2018.07.19.07.09.44; Thu, 19 Jul 2018 07:10:00 -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; dkim=pass header.i=@linaro.org header.s=google header.b=BGdPGBLr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731796AbeGSOwO (ORCPT + 99 others); Thu, 19 Jul 2018 10:52:14 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:43717 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731043AbeGSOwO (ORCPT ); Thu, 19 Jul 2018 10:52:14 -0400 Received: by mail-io0-f193.google.com with SMTP id y10-v6so7171550ioa.10 for ; Thu, 19 Jul 2018 07:08:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=dkWjQNn9a0ArV0jfLRsfivyiS66V30i3wp2Sc6sigk0=; b=BGdPGBLrt70E4JJN+eGtksCbauerKrYCySEzhONBz0acxKMngSryvU1WyGX6sGB6jE JP3GsGr2xZ65xMzMgHNsz3yV69od+MDbfHwC8neOwN7M+MOnrt25NaZ2iPVMFWq4xRPg ccIwOj++nLxuBBZV6YAdTo6bO4YAcMFh/XDYE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=dkWjQNn9a0ArV0jfLRsfivyiS66V30i3wp2Sc6sigk0=; b=GnZsuBvwZ9NugKOaH7FSiKG9d9mJzc3VP3yV3Q1F59KEpfWShngLvcAeZZqp4pOET2 xCf56cVpMNWdocK/kh1MnD53SEMMcQdiqtAGUHIOua/1VsNjCOBeef9FcsGWker7XpMu YGIgOpaNPAKvlyP1cl8Cj3iLHRg1sENn40Sre/wUu1uNi74oYFvS51jXfzgyLw0OZGQO hJDJ5PqebiPl8qJceLMeGJrilk4xc+sE08f3fBMv9imeFOc8LAJhHDf56cReatNINMGC P8JIVRSvLsi8tFwTdGoK/P1qaApfKOyH/YxPBRhK049KIaEzRMBK71lzYaMQFaDryBYl 6BwA== X-Gm-Message-State: AOUpUlFn9ah1mjKqBJsM0TCWyDUe8hyhuqLrbfKpvML+QBrDbfTEbtiY jxaSsYiHPp6fE+Ts8Gb0vOiV9ZJ3SpQaM2HNWiXFXQ== X-Received: by 2002:a6b:be83:: with SMTP id o125-v6mr8553453iof.173.1532009332906; Thu, 19 Jul 2018 07:08:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ac05:0:0:0:0:0 with HTTP; Thu, 19 Jul 2018 07:08:52 -0700 (PDT) In-Reply-To: <5d0bb72c-862e-63be-3cc5-83ed02b9a575@huawei.com> References: <1531899055-29362-1-git-send-email-wangxiongfeng2@huawei.com> <5d0bb72c-862e-63be-3cc5-83ed02b9a575@huawei.com> From: Ard Biesheuvel Date: Thu, 19 Jul 2018 23:08:52 +0900 Message-ID: Subject: Re: [PATCH 0/5] crypto: add IV generation templates To: Xiongfeng Wang Cc: Arnd Bergmann , Alasdair Kergon , Mike Snitzer , Herbert Xu , dm-devel@redhat.com, Linux Kernel Mailing List , Mark Brown , Jonathan Cameron Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19 July 2018 at 19:55, Xiongfeng Wang wrote: > Hi, > > On 2018/7/18 23:34, Ard Biesheuvel wrote: >> On 18 July 2018 at 19:59, Arnd Bergmann wrote: >>> On Wed, Jul 18, 2018 at 9:30 AM, Xiongfeng Wang >>> wrote: >>>> >>>> I tested the performance of software implemented ciphers before and after >>>> applying this patchset. The performance didn't change much except for >>>> slight regression when writting. The detail information is as follows. >>>> >>>> The command I used: >>>> cryptsetup -y -c aes-xts-plain -s 256 --hash sha256 luksFormat /dev/sdd1 >>>> cryptsetup -y -c aes-cbc-essiv:sha256 -s 256 --hash sha256 luksFormat /dev/sdd1 >>>> cryptsetup -y -c aes-cbc-benbi -s 256 --hash sha256 luksFormat /dev/sdd1 >>>> >>>> cryptsetup luksOpen /dev/sdd1 crypt_fun >>>> time dd if=/dev/mapper/crypt_fun of=/dev/null bs=1M count=500 iflag=direct >>>> time dd if=/dev/zero of=/dev/mapper/crypt_fun bs=1M count=500 oflag=direct >>>> >>>> Performance comparision: >>>> -------------------------------------------------------- >>>> algorithms | before applying | after applying >>>> -------------------------------------------------------- >>>> | read | write | read | write >>>> -------------------------------------------------------- >>>> aes-xts-plain | 145.34 | 145.09 | 145.89 | 144.2 >>>> -------------------------------------------------------- >>>> aes-cbc-essiv | 146.87 | 144.62 | 146.74 | 143.41 >>>> -------------------------------------------------------- >>>> aes-cbc-benbi | 146.03 | 144.74 | 146.77 | 144.46 >>>> -------------------------------------------------------- >>> >>> Do you have any estimate of the expected gains for hardware >>> implementations? >>> >>> Would it make sense to try out implementing aes-cbc-essiv >>> on the ARMv8 crypto extensions? I see that Ard has done >>> some prior work on aes-ccm in arch/arm64/crypto/aes-ce-ccm-* >>> that (AFAICT) has a similar goal of avoiding overhead by >>> combining the usual operations, so maybe the same can >>> be done here. >>> >> >> I am having trouble understanding what exactly this series aims to achieve. >> >> Calling into the crypto layer fewer times is a nice goal, but a disk >> sector seems like a reasonable granularity for the dm layer to operate >> on, and I don't think any hardware exists that operates on multi >> sector sequences, where it would pay off to amortize the latency of >> invoking the hardware over an entire bio. > > I don't know much about crypto hardware, but I think a crypto hardware can handle > data more than one sector at one time. So I think passing the whole bio to the hardware > at one time will decrease the overhead in passing each sector alternatively. > But this will only be the case if the accelerator is capable of doing the IV generation and en/decryption of multiple contiguous sectors in a single call. Otherwise, you are just shifting work from one layer to the next. So at this point, it would be useful to clarify what exactly these accelerators are doing and how.