Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp228199lqt; Thu, 6 Jun 2024 01:33:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVhHyM5wtR0/20ZY0UZbEc1x94FV8inaWHjA8IpsxXdy6sBarOJhflkRwZL17nvcC5czB8MbKJkTlrfEzDBR9jSK6XNIMyq7Amz4CAojw== X-Google-Smtp-Source: AGHT+IEvBt1evtluqhPOfSNAQExtjnu9s1U3m+UYKVCArpdFff7hSMN2hwR0i2JCUGQPxszKz+Vx X-Received: by 2002:a05:6359:459b:b0:19f:1644:d45e with SMTP id e5c5f4694b2df-19f1644d940mr24729155d.8.1717662831156; Thu, 06 Jun 2024 01:33:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717662831; cv=pass; d=google.com; s=arc-20160816; b=ElgOn5IRabzzMJtTSF42HBXahAyBvP8D/8r0Dcy/yUoNPkQjaYdJrlYjoVcPtKxt04 rtRL4iWNneehmv+52Y8xm+UztkIOjvfigaIEL7zO16RVwsjuteU4ANI7HBcst58TF7Q7 K8IprFcwZqqJZ9xLIvTswx9X11K+vvEq05COrClWPU1P+t8Idygl9Rx+gsCpIbH8c1TE JJnHUNEF98Ghtjl5/v3V7cCUdj/1qVoC2//ChMrRlRXetC8/Lfy90tNaZF0J5l3slQuL IENixg5HhsZAYbTg6ImMaWnqT+nIlSVp9PggNTt1KI/ah5KMI2MWjLxFHeE+gVx+5MNZ Ml9A== 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=dxaspsuICKaxtVDDWf6yKOxem3HGsrtV/YoTJq5IcYo=; fh=8qmZOxGxMAzxxCnG8idjFXtPTvMT7opXmy0nP10eR4k=; b=cw2TmEztTOz3Oy21bVBwl71dqiiOWmyHihVhYzLNYh6xuEjwGE9lK/3jq62zA3qraa x8Y14hi23R7dpJoAy6qOXNoscsmrpEi63iD65UJNFxApvcLHThmas/dOY+HvF7VMNIq2 uP8W7bPUV8KizPKOEJtBuDCWM1E690yKCsOAx3ByS1Zm+LNmO4lDlPXESPgHJS9ZVAIk uyLYb68RFUB0iijKP/Gbax7M4LkM86S/NPhlrQ1S6FmF21xpkLK24jExMNKcucvlH+Z+ 2uQUNV6fljHTeDzOvJ8dbcDLvfSN/1gRFvFX5SPEwXmXCJ9e5RUL9UajyXyV+M8ETxr1 pwYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=po1DSTJP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4780-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de261c9a50si763212a12.340.2024.06.06.01.33.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 01:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=po1DSTJP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4780-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D80D0B21876 for ; Thu, 6 Jun 2024 08:33:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5024113A418; Thu, 6 Jun 2024 08:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="po1DSTJP" 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 0D05326292; Thu, 6 Jun 2024 08:33:29 +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=1717662810; cv=none; b=GFt/mn28PDRK45pWgkGN4rxYvuhkQcvLESgyELr9za6vVJPeJTwANACn11pc7dIgXSIqMkNF15uyq+90+ZwqlDuy5zzs8sN4PZZk58DkPvi/G2PdCVwjAWEq78/5zt3WLKST24LEFxvnXD/kq60l610mKhFAMu587bc9M+M62oA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717662810; c=relaxed/simple; bh=YU8DtIKwHmMDfcku625+Vpqv5ex7ZLivp9rvHDTWByE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=PB/GpTxnWCvccAD+thzOgtogGcq0a4qE9C57uVR1op6+8gM8RW9rVU9coSAcE+QW42I3v4L5pCV+bZlDR9ItvWb//4DO0MguPyn9BVGaNyFUPt7rkQYrpD0w5cGrZbc1kLLQPWvRvGWZgZmLd44kF8RwcO/oen8XyGXBr5Cdpzs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=po1DSTJP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A330CC4AF0A; Thu, 6 Jun 2024 08:33:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717662809; bh=YU8DtIKwHmMDfcku625+Vpqv5ex7ZLivp9rvHDTWByE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=po1DSTJPR7pCkBP++C9n0OVIEUUHGYM4Clm7DsESYlFedwNWo0hXKL1ODuR+rsWoD a8MsvY8lCHPE0FFF8K+KlgQ+/PODp9A2/HbhcUulz9ytIXMGL2GznC3GG/nsq/q8ow Tle1vCwc96KAY4K7LOztRsxT8VRUrmZhe56jp2lEimu0gQd1OO9jJGPBoiSiXOdFmU aPluFG5dT8IkyqRn86PA/srqXRDEn8ZHVXqtfsL4opkcvnoiBe7ezBT44xFvt20pFG Kg81cK1Dmzo6SlWmcnn32f3lRgOMJ9zLVKz1bNAC0ja9Uje18dnEAuvGrLLHkju4o2 8b+vcGLtxVqYA== Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2e6f2534e41so6961811fa.0; Thu, 06 Jun 2024 01:33:29 -0700 (PDT) X-Forwarded-Encrypted: i=1; AJvYcCWeJg9MuGqxmmiV8mwi02uhIGutUR7xkeifRDRtgnpn/6laxV2mT75gGcEhWiGHdEahKyGKVNDOH1QkOwo3jL1BivqD9q9MqahC5hUjosEAp7U6xBo60lUy4aTZSoPI2Sp2lohL X-Gm-Message-State: AOJu0YxngvwrMSpfmKZUlpbS1VfXp5Om1uHooxo1G6I5IQA8l2XdjCl+ x+uzzpoEQBB01t+VAvwGSiUjRd1H2Bj+hZA5V5VoyTa2JoTkfmU7tURiqagFIB3jWeon1QKeO+B Sfljq7ZdKIasFbsslEk/CFtSEl8k= X-Received: by 2002:a05:651c:a11:b0:2df:b0e3:b548 with SMTP id 38308e7fff4ca-2eac7a52b32mr31799341fa.42.1717662808019; Thu, 06 Jun 2024 01:33:28 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240605191410.GB1222@sol.localdomain> <20240606052801.GA324380@sol.localdomain> In-Reply-To: From: Ard Biesheuvel Date: Thu, 6 Jun 2024 10:33:15 +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 , Tim Chen Content-Type: text/plain; charset="UTF-8" On Thu, 6 Jun 2024 at 10:08, Herbert Xu wrote: > > On Thu, Jun 06, 2024 at 09:55:56AM +0200, Ard Biesheuvel wrote: > > > > So again, how would that work for ahash falling back to shash. Are you > > saying every existing shash implementation should be duplicated into > > an ahash so that the multibuffer optimization can be added? shash is a > > public interface so we cannot just remove the existing ones and we'll > > end up carrying both forever. > > It should do the same thing for ahash algorithms that do not support > multiple requests. IOW it should process the requests one by one. > That is not what I am asking. Are you suggesting that, e.g., the arm64 sha2 shash implementation that is modified by this series should instead expose both an shash as before, and an ahash built around the same asm code that exposes the multibuffer capability? > > Sure, but the block I/O world is very different. Forcing it to use an > > API modeled after how IPsec might use it seems, again, unreasonable. > > It's not different at all. You can see that by the proliferation > of kmap calls in fs/verity. It's a fundamental issue. You can't > consistently get a large contiguous allocation beyond one page due > to fragmentation. So large data is always going to be scattered. > I don't think this is true for many uses of the block layer. > BTW, I'm all for elminating the overhead when you already have a > linear address for scattered memory, e.g., through vmalloc. We > should definitely improve our interface for ahash/skcipher/aead so > that vmalloc addresses (as well as kmalloc virtual addresses by > extension) are supported as first class citizens, and we don't turn > them into SG lists unless it's necessary for DMA. > Yes, this is something I've been pondering for a while. An ahash/skcipher/aead with CRYPTO_ALG_ASYNC cleared (which would guarantee that any provided VA would not be referenced after the algo invocation returns) should be able to consume a request that carries virtual addresses rather than SG lists. Given that it is up to the caller to choose between sync and async, it would be in a good position also to judge whether it wants to use stack/vmalloc addresses. I'll have a stab at this.