Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp18900178rwd; Wed, 28 Jun 2023 02:10:00 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KepBWMjk3qI+aVg3WXsOwSpmVMenKqgPp3rB87eU9nEIHJxKNXiQx+EiIUQWXYss/7OXN X-Received: by 2002:a05:6a20:7fa0:b0:100:b92b:e8be with SMTP id d32-20020a056a207fa000b00100b92be8bemr47289406pzj.2.1687943400076; Wed, 28 Jun 2023 02:10:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687943400; cv=none; d=google.com; s=arc-20160816; b=dvg/TYSOkYXqV1rQmWVrOUuDhCcqkh57GKHTTks7+7YALI3EDFA9F0TA3Sairax5r1 yPBFqOy7KO7329xrzUN7pWDreXVF44s0KELHFbW1RZv51/7nkz2nv5DcYvjK6Ryl1O8I CHAI41vv/SaW3dugpxOQfIjw3B9YOZUfg77QvrC27m8xqGRPnrGnyleGAmtZQHcrArMB b/UBK0WGIJN+zsNczDYJFQi/crhwVDeVCcA8V8K8XMO2nZTBPkuAwXYA1bRnmK3p9ySk Xo6cLLEYSqhC+JWWKGcy0I1q4RKLqN4JELDmGpQhEyO35r/BxmgaWeQ12GslvSjzUYEe CrPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QMUjEbfMdAlW8FB63kze6fF9aCqpOQ9myk7AFC6fk9s=; fh=q2O35+vJksd6vmRdRxH92gdbP+PQk/Ugvenxrxe7UPM=; b=gA1EFY1sqNzEuUUzh8Tk/NLu6dFOXwNcxmUSGqhA1FSM25y4pVFZF0lBUBcfW84VQ/ c2qNRnf7uJjadMjRhBX5ypWKiiAX/YQ2p7tOWG7XidqgB3JI2VNA66Iv4FTp1MogcCsS E+dJuVdu2QWiSPkqZ2qy9VKQy4TMSOsE/p9PVQvnfzFtKL17n/X9VpV8gOSYsvsGgBFh ycFqEUl7U1BfeKx88w09bGXtQIp+PPKrzaQrUQtRYg70WT9IAVGccn8tMsve4jSRMTD/ bJq/nzLNLaWPW5gvOjdK2IzbWHEDfRqDDgL2gdWc3wiEFqajUgKl5D7Olw19oiQV+XDE P+5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LXHOTJgE; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a656649000000b0055785aa5282si9530858pgv.81.2023.06.28.02.09.21; Wed, 28 Jun 2023 02:10:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LXHOTJgE; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S237105AbjF1JIe (ORCPT + 99 others); Wed, 28 Jun 2023 05:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233956AbjF1IuN (ORCPT ); Wed, 28 Jun 2023 04:50:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DB2A1FED; Wed, 28 Jun 2023 01:49:50 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 057076131A; Wed, 28 Jun 2023 06:21:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 060BAC433C8; Wed, 28 Jun 2023 06:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687933282; bh=S0mOI7jpmYwxZG2bLczj5KSpX82KzQBUCLq1L8pxtlU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LXHOTJgEaUDoz43LYSW97aaS0yNe+xmOKt/tUoVfhd2a1mqId6tHjbDMaS+rAwZ4G 54ZaLFLJQIgqsV91HkAeX/upPc43skWMZ9xxK+zXhivnEKGA1EORTNWph8tlmtEksG 72EJNyXCEXGoWqIkxX6mU9QjMYuHUEFDNGVXCbHdIH2puUPquNtqKA7zT5Fo1sIzPk AjucFoQn/sLacxEQAmZ4qmKaoBKyWKZ45SqHXdY52ddTjEOriKoYA8gJMGrZaUDnY7 9cZ43Ip/hIg1InVUHrxPn14hCwn1QWMFKM7ADc3kl6ZSCTU5E5SKquMESAJ0/V72Ip RCaEdT3WCk+yg== Date: Tue, 27 Jun 2023 23:21:20 -0700 From: Eric Biggers To: Herbert Xu Cc: Ard Biesheuvel , David Howells , Linus Torvalds , Roberto Sassu , Stefan Berger , Mimi Zohar , dmitry.kasatkin@gmail.com, Jarkko Sakkinen , keyrings@vger.kernel.org, Linux Crypto Mailing List Subject: Re: [v2 PATCH 0/5] crypto: Add akcipher interface without SGs Message-ID: <20230628062120.GA7546@sol.localdomain> References: <570802.1686660808@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Jun 26, 2023 at 06:13:44PM +0800, Herbert Xu wrote: > On Mon, Jun 26, 2023 at 12:03:04PM +0200, Ard Biesheuvel wrote: > > > > In any case, what I would like to see addressed is the horrid scomp to > > acomp layer that ties up megabytes of memory in scratch space, just to > > emulate the acomp interface on top of scomp drivers, while no code > > exists that makes use of the async nature. Do you have an idea on how > > we might address this particular issue? > > The whole reason why need to allocate megabytes of memory is because > of the lack of SG lists in the underlying algorithm. If they > actually used SG lists and allocated pages as they went during > decompression, then we wouldn't need to pre-allocate any memory > at all. I don't think that is a realistic expectation. Decompressors generally need a contiguous buffer for decompressed data anyway, up to a certain size which is 32KB for DEFLATE but can be much larger for the more modern algorithms. This is because they decode "matches" that refer to previously decompressed data by offset, and it has to be possible to index the data efficiently. (Some decompressors, e.g. zlib, provide "streaming" APIs where you can read arbitrary amounts. But that works by actually decompressing into an internal buffer that has sufficient size, then copying to the user provided buffer.) The same applies to compressors too, with regards to the original data. I think the "input/output is a list of pages" model just fundamentally does not work well for software compression and decompression. To support it, either large temporary buffers are needed (they might be hidden inside the (de)compressor, but they are there), or vmap() or vm_map_ram() is needed. FWIW, f2fs compression uses vm_map_ram() and skips the crypto API entirely... If acomp has to be kept for the hardware support, then maybe its scomp backend should use vm_map_ram() instead of scratch buffers? - Eric