Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2991152imm; Fri, 24 Aug 2018 08:42:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaBmrRCJwBCN/HOrl6vcHCgFwGHz838YQpvgwdf/LqKkrgCvs/yEdqL/w56TYexOA1etv3P X-Received: by 2002:a65:6143:: with SMTP id o3-v6mr2305084pgv.52.1535125333014; Fri, 24 Aug 2018 08:42:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535125332; cv=none; d=google.com; s=arc-20160816; b=fspEtjwe/yaC/ua1gbUQ2p/Piy2J/P/tgxi6YqU9T2aX73TfRbeExu/b1p9AIgOov3 V4aKpXFG4cm1zkxiZ821ikAtwT/tygPXZcBhWUeVC6YLY+p2hYZr5Gs8xwPsOjeXu8ks +r8MF2GIBUvS3cxx78hVXV4tbtjNJG+QWYkRE2VYKDK/g/+D9Ciz0CgilIZXiM1PW0wq 9QzKfnmMef5KueaumuZhqgIGw3QZ9SLFkK7RbioaP7ELwq/siyonV6SRmmHi6+Me30d9 cCQ98IW9zQ3Mx1mJM5o9pgWIhQ2ry+vtz95CVfbepnzQdXzzgdO0aVPTPoji5VLJ27Ev pBFw== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=Ezry/Y3Wgw+4f1feLnZlgoHsZiJ7oMHPTRCWsKS9KNE=; b=z11e+LlxrVScPLGF+y7n/G8GoD8WCFScIwU1BONDq9t5ur5oA4KwyD0hFQ7dC0Pnno 2cQX8u3BpN+XCAx0oSJFWy1XMhjqOrDNL35q7f/5L7ZFL6c0l3tmUBYAMMRd0W8jq9dC k+b6Y4j5TJPvVJDmRBJeworKggPFf/8ihAMrL+IVXP8/VKKdRzTrDjRYLKd74cmoXsBc 7ZpfidQY0+7rozULLuArV7aD8bcPySek/411NSnXHixXPfnUGHbWRAY5YO6Icd2gxgOg h9kqp3K1Ym0KTTmBHKFISh4qKMxstcDJJJBtNRRc7rrGhRo2kbmpkBoP3a9qCEpn+5U3 cWmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gM0sDmJa; 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 f3-v6si6847466plb.207.2018.08.24.08.41.56; Fri, 24 Aug 2018 08:42:12 -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=gM0sDmJa; 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 S1727880AbeHXTO7 (ORCPT + 99 others); Fri, 24 Aug 2018 15:14:59 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:36427 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbeHXTO7 (ORCPT ); Fri, 24 Aug 2018 15:14:59 -0400 Received: by mail-it0-f67.google.com with SMTP id p16-v6so2492594itp.1 for ; Fri, 24 Aug 2018 08:39:48 -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:content-transfer-encoding; bh=Ezry/Y3Wgw+4f1feLnZlgoHsZiJ7oMHPTRCWsKS9KNE=; b=gM0sDmJaqaXijOBsoaTcRdZZ0aKEHL6H5YVxPhUAJTI9kkja0V/kkdonCdA6eyrEwQ mYopqvGVWBsADYAMSl5WPfu0OwYcAwxzC2WJ3azGoSz+y7BIcHqV+AoacEj09LPTY8gh gjoV7yop6xn68WMrh1Lp5+T+pqkJTtoudh1jo= 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:content-transfer-encoding; bh=Ezry/Y3Wgw+4f1feLnZlgoHsZiJ7oMHPTRCWsKS9KNE=; b=tJPj/JCGhkgmg+ycLLx2/WlC64Gpli7akOfOuyDCSUkGZXwSfjb7QrAU59NKOzT9hg 16NHir1yU1sNG2Yyv73XCskshEe//FzpzSP3TOOdmdpBujWE3qW1AauCHi4ld2T9cf7i e6jPsfnwSUWCBCqWibzog5GSja4KN7h/QUU/OZUXvAb2dKHdU/AcnbolAWKXN3b/tavM H2YGaRv1oGdzBqJurDgnO5sAv5KtkdGP1dfVZDtCktc7R7E1zfqQUGwY/B1MsZaJkshU vRsVHEhWyE4+0kj+2Ug6IwojcnhtjArN65qCUpoTWRuvDnEwqQg2/3UjRhr2SMmevHUb lv1g== X-Gm-Message-State: APzg51CiOlpk6J+aLIABDQ2ut+mNk5kPuvNqyPCJEL46TxnZE1ezbMV5 b/UYc01Ta079mLeiWIuDq5D5XgmuwAU5qWFfuulDig== X-Received: by 2002:a24:57cb:: with SMTP id u194-v6mr1811115ita.148.1535125188026; Fri, 24 Aug 2018 08:39:48 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:ac05:0:0:0:0:0 with HTTP; Fri, 24 Aug 2018 08:39:47 -0700 (PDT) In-Reply-To: References: <1533928331-21303-1-git-send-email-jeff.lien@wdc.com> <20180822062016.GA10356@infradead.org> From: Ard Biesheuvel Date: Fri, 24 Aug 2018 16:39:47 +0100 Message-ID: Subject: Re: [PATCH] Performance Improvement in CRC16 Calculations. To: Jeffrey Lien Cc: Christoph Hellwig , "Martin K. Petersen" , "linux-kernel@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "herbert@gondor.apana.org.au" , "tim.c.chen@linux.intel.com" , David Darrington , Jeff Furlong Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 24 August 2018 at 16:32, Jeffrey Lien wrote: > I rebuilt my 4.18 kernel with CONFIG_CRYPTO_CRCT10DIF_PCLMUL=3Dy as Marti= n recommended and got even better performance results vs the CRC Slice by 1= 6 changes. Here's a summary of the results > > FIO Sequential Write, 64K Block Size, Queue Depth 64 > PCLMUL =3D y Kernel: bw =3D 2237 MiB/s > Slice by 16 CRC Calc: bw =3D 1964 MiB/s > Base Kernel: bw =3D 357 MiB/s > > FIO Sequential Read, 64K Block Size, Queue Depth 64 > PCLMUL =3D y Kernel: bw =3D 3839 MiB/s > Slice by 16 CRC Calc: bw =3D 2730 MiB/s > Base Kernel: bw =3D 797 MiB/s > > So it seems the CONFIG_CRYPTO_CRCT10DIF_PCLMUL=3Dy provides the best perf= ormance. Are there any negative side effect to this config option? If no= t, does it make sense to recommend all the major distro's change their conf= ig options to have CONFIG_CRYPTO_CRCT10DIF_PCLMUL=3Dy as the default option= ? > I think the way the library version of crc_t10dif() invokes the crypto API should be revised. Would it be possible to allocate the crypto transform upon first use instead of from an initcall? If crc_t10dif() is mostly called from non-process context, that would not really work, but otherwise, we could simply defer it (and occasional calls from non-process context that do occur would use the generic code until the point where another call from process context allocates the transform) > -----Original Message----- > From: Christoph Hellwig [mailto:hch@infradead.org] > Sent: Wednesday, August 22, 2018 1:20 AM > To: Martin K. Petersen > Cc: Jeffrey Lien ; linux-kernel@vger.kernel.org; linux= -crypto@vger.kernel.org; linux-block@vger.kernel.org; linux-scsi@vger.kerne= l.org; herbert@gondor.apana.org.au; tim.c.chen@linux.intel.com; David Darri= ngton ; Jeff Furlong > Subject: Re: [PATCH] Performance Improvement in CRC16 Calculations. > > On Tue, Aug 21, 2018 at 09:40:34PM -0400, Martin K. Petersen wrote: >> When crc-t10dif is initialized, the crypto infrastructure will pick >> the algorithm with the highest priority currently registered. Both >> block and SCSI will cause crc-t10dif to be compiled as a built-in so >> this selection happens very early. > > Ouch. This might actually happen in a lot of other users of the crypto f= unctionality as well. > >> However, it seems like a bit of a deficiency in crypto that there is >> no way to upgrade existing transformations if higher priority >> algorithms become available. btrfs and a few others work around this >> issue by not using the generic lib/ CRC functions (which defeats the >> purpose of having these in the first place). Instead they are >> registering their own transformation at a later time where any >> accelerator modules are more likely to be loaded. > > If we can't fix this in crypto (which doesn't seem that easy), we should = at least clearly document the issue somewhere, and fix this in the t10pi co= de by initializing crct10dif_tfm in a lazy fashion only once the fist block= device starts using it.