Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp188648lqt; Wed, 5 Jun 2024 23:59:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW9v1+ABBZi3C/sCYKn6IcHeNPRtBglcLI97QRrf/aPYg55nwlffBMXd7etScTYN7bwSoRnew32Jv6G/W0ebeekKyDdb6IMbElBUszH1A== X-Google-Smtp-Source: AGHT+IFkBbWxPdSflxfM78logW1f5IMItdCrQzskWDPUxno9LTcYmvKlQlcTC91ShzG0bGgU/JoR X-Received: by 2002:a54:4514:0:b0:3c8:3490:4a05 with SMTP id 5614622812f47-3d2045ecf5fmr5327020b6e.50.1717657146419; Wed, 05 Jun 2024 23:59:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717657146; cv=pass; d=google.com; s=arc-20160816; b=djAqJG6BroXSY7RVEjGNdE+ZkUj3NV9Jnq+aBgUCh4nfqoQXS2AjE5fUt8HgaiToQp JmuBJ9970MadN8WO+rgZIonOBwcPSVTWasnraA78zCbGljsbg6dNNymFEjaYWf8MB/pu 3tfX4J6Wrm32W5iGSHEiWH+M9HOEAOXhEeMw3pd0aInVfivN16okAilIUH/s5TbL/zXZ NuVeYytTK53BKei2FbtFrl7ZXceDFVnyqvNuzRj9Lchy7DIrAH+Tdblb48rYDI+83yB8 O9Tp3UMbYChPmUhHNgOyfiPCdJt0lEovsoL171xgF5KQsOuO0+iJRXtrJ+jNxsNtJftu 4MEw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=ek8mKsO6nXm+I1tG4fGF4PrWPkDcJl0P3E/YYCdxL1A=; fh=itjNDGRzrGkZgxfuwL4de6m8IYiHiUzRUQQvgjN/bVQ=; b=z4rU7fMa9/0Oy6+TyYXHwoQkgOjz+rmtPg+mzZsfNyDxl3QBJWGbKf7RmcQ3wabU22 UcLGC/Kaa/QDxyweUNURTn7PULNY+qck3u0sHiuHkJUL8qX1IIx6gM/rxuW+9sIW5rru PsuqJpK24wttmwwxcgOk0f+9MJVJyNmKXPTb64tD4lfGt8vzjOUQ2NHP1l78pkDWRQIs 44ckEhreZ6et99NEMhlCPxhpanGNBNdMtAeL+wGdtyHeKg5IvbeHfoaskeX7U89de1Z9 u2yw1Jq5PWQ4LPuF37i5swNjI2TR8Gyp407TSB88XTACBFjfLk+m5ySTot3bYf/qxj5e T6vA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jH4dMWr0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-795332ed1dasi77193285a.456.2024.06.05.23.59.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 23:59:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jH4dMWr0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4775-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4775-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 280251C22B29 for ; Thu, 6 Jun 2024 06:59:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2A1813A40F; Thu, 6 Jun 2024 06:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jH4dMWr0" X-Original-To: linux-crypto@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C17E19D898; Thu, 6 Jun 2024 06:59:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717657140; cv=none; b=PEMPoeVboHeXp/jPOTednpn/dtVwaSp8j2/LwNIm3kOxCi58v6+/khS0n8pMFQNp38mN1ZPTbh91AthnE5U5Z7uJagwlOs/FH3sECkx0TyR+CQ/LZCbQINFDoFRthcStry07fhxAoekcEtD1Qhsngr3zkChXK70hyogMH93bFsw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717657140; c=relaxed/simple; bh=87LH+aaU1KT+V0MM3MNI+6hzSZdEAjajZB97hmhjhBc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=EbQ+x51aQuMREuLcFEseSGnwAB5hDXZFV3cIezpcl6kF3fQfEHJxBMozHeJqg/JBq7BWeUv7C1wfLcSDiZth+vH8oyfLOumOAWLepV63oJBmNcC2+pdb56D24E/zHzR7xOni3sixXjcCpwQwUIwmj1aw+qhp56E92Vxx1Ig8abE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jH4dMWr0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1F3AC4AF12; Thu, 6 Jun 2024 06:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717657140; bh=87LH+aaU1KT+V0MM3MNI+6hzSZdEAjajZB97hmhjhBc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jH4dMWr07DETa2BkS0tc8A3a5D8JBHx3CiJmQrz+Ny9JpZPF8h/wzB34qhSg8Kl9J cSuIMjyGju8e0FSobLeUh6MQNM7w5XzyVShcQADQnJPYNISyyoiShe8nN5e8XVstm0 xyFjzTG5GTfmibC4Wvv5dMqkz/s0St4lkLluod/oM1P4nLJWTicBYCbFZMTL3yDUj6 zNGOjcRyfhXyo1vULD2AVSXZmTZBPyhUYKlgyhxqZSQMSTjIvIJIhm4dj/1+hifdtP CMRf8PkW5E4fSGFdpIpMFpVaI4QZ8H9FJFxQyDIBBnDo4tX4VyFKVFCGvzJRBqrK7y ADzrua+FnjKfA== Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2e6f2534e41so6175721fa.0; Wed, 05 Jun 2024 23:58:59 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCW+SO7er6kKoHFW/GuQEBX/zKGENHVlEraXJjwpj3BCpCkhGcNsiyvp43wtc2z7Piyut6mO4XGDJdItdFXpQBXsAfzQgM44p6NgOeySPn51WQNAtRQl1CmfyUkUBZn6xs0E6Mfg X-Gm-Message-State: AOJu0YyswfldTHrzm+wY1pKltVuG+9IvV8VbnTMiTxJ/4QzV0QlkCrsb O7KdkrOQDLCASC94VtWPILFO+OvZjZtX7GjdnVnu6MCilr6byME+cN3evrwGO5d0pE4JL9km9q1 U4sKfIa3d/O1I2NnpxhqNLcnn8a0= X-Received: by 2002:a2e:b607:0:b0:2ea:8ae5:92c with SMTP id 38308e7fff4ca-2eac7a7089cmr23831261fa.47.1717657138214; Wed, 05 Jun 2024 23:58:58 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240603183731.108986-1-ebiggers@kernel.org> <20240603183731.108986-7-ebiggers@kernel.org> <20240604184220.GC1566@sol.localdomain> <20240605191410.GB1222@sol.localdomain> <20240606052801.GA324380@sol.localdomain> In-Reply-To: From: Ard Biesheuvel Date: Thu, 6 Jun 2024 08:58:47 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 6/8] fsverity: improve performance by using multibuffer hashing To: Herbert Xu Cc: Eric Biggers , Steffen Klassert , netdev@vger.kernel.org, linux-crypto@vger.kernel.org, fsverity@lists.linux.dev, dm-devel@lists.linux.dev, x86@kernel.org, linux-arm-kernel@lists.infradead.org, Sami Tolvanen , Bart Van Assche , Megha Dey , Tim Chen Content-Type: text/plain; charset="UTF-8" On Thu, 6 Jun 2024 at 07:41, Herbert Xu wrote: > > On Wed, Jun 05, 2024 at 10:28:01PM -0700, Eric Biggers wrote: > > > > With AES, interleaving would only help with non-parallelizable modes such as CBC > > encryption. Anyone who cares about IPsec performance should of course be using > > AES-GCM, which is parallelizable. Especially since my other patch > > https://lore.kernel.org/linux-crypto/20240602222221.176625-2-ebiggers@kernel.org/ > > is making AES-GCM twice as fast... > > Algorithm selection may be limited by peer capability. For IPsec, > if SHA is being used, then most likely CBC is also being used. > IPSec users relying on software crypto and authenc() and caring about performance seems like a rather niche use case to me. > > In any case, it seems that what you're asking for at this point is far beyond > > the scope of this patchset. > > I'm more than happy to take this over if you don't wish to extend > it beyond the storage usage cases. According to the original Intel > sha2-mb submission, this should result in at least a two-fold > speed-up. > I'm struggling to follow this debate. Surely, if this functionality needs to live in ahash, the shash fallbacks need to implement this parallel scheme too, or ahash would end up just feeding the requests into shash sequentially, defeating the purpose. It is then up to the API client to choose between ahash or shash, just as it can today. So Eric has a pretty strong case for his shash implementation; kmap_local() is essentially a NOP on architectures that anyone still cares about (unlike kmap_atomic() which still disables preemption), so I don't have a problem with the caller relying on that in order to be able to use shash directly. The whole scatterlist / request alloc dance is just too tedious and pointless, given that in practice, it all gets relegated to shash anyway. But my point is that even if we go with Herbert's proposal for the ahash, we'll still need something like Eric's code on the shash side. For the true async accelerator use case, none of this should make any difference, right? If the caller already tolerates async (but in-order) completion, implementing this request chaining doesn't buy it anything. So only when the caller is sync and the implementation is async, we might be able to do something smart where the caller waits on a single completion that signals the completion of a set of inputs. But this is also rather niche, so not worth holding up this effort. So Herbert, what would the ahash_to_shash plumbing look like for the ahash API that you are proposing? What changes would it require to shash, and how much to they deviate from what Eric is suggesting?