From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Kees Cook <keescook@chromium.org>,
Geliang Tang <geliangtang@gmail.com>,
Arnd Bergmann <arnd@arndb.de>, Haren Myneni <haren@us.ibm.com>,
Anton Vorontsov <anton@enomsg.org>,
Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
Zhou Wang <wangzhou1@hisilicon.com>,
linux-crypto <linux-crypto@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/9] crypto: add zbufsize() interface
Date: Fri, 3 Dec 2021 12:49:26 -0800 [thread overview]
Message-ID: <YaqC1mkcyzO2WrI/@google.com> (raw)
In-Reply-To: <20211203022821.GA16082@gondor.apana.org.au>
On Fri, Dec 03, 2021 at 01:28:21PM +1100, Herbert Xu wrote:
> On Thu, Dec 02, 2021 at 12:10:13AM -0800, Kees Cook wrote:
> >
> > I'd rather just have a simple API that hid all the async (or sync) details
> > and would work with whatever was the "best" implementation. Neither pstore
> > nor the module loader has anything else to do while decompression happens.
>
> Well that's exactly what the acomp interface is supposed to be.
> It supports any algorithm, whether sync or async. However, for
> obvious reasons this interface has to be async.
>
> > > Typically this would only make sense if you process a very small
> > > amount of data, but this seems counter-intuitive with compression
> > > (it does make sense with hashing where we often hash just 16 bytes).
> >
> > pstore works on usually a handful of small buffers. (One of the largest
> > I've seen is used by Chrome OS: 6 128K buffers.) Speed is not important
> > (done at most 6 times at boot, and 1 time on panic), and, in fact,
> > offload is probably a bad idea just to keep the machinery needed to
> > store a panic log as small as possible.
>
> In that case creating an scomp user interface is probably the best
> course of action.
>
> > Why can't crypto_comp_*() be refactored to wrap crypto_acomp_*() (and
> > crypto_scomp_*())? I can see so many other places that would benefit from
> > this. Here are just some of the places that appear to be hand-rolling
> > compression/decompression routines that might benefit from this kind of
> > code re-use and compression alg agnosticism:
>
> We cannot provide async hardware through a sync-only interface
> because that may lead to dead-lock. For your use-cases you should
> avoid using any async implementations.
>
> The scomp interface is meant to be pretty much identical to the
> legacy comp interface except that it supports integration with
> acomp.
>
> Because nobody has had a need for scomp we have not added an
> interface for it so it only exists as part of the low-level API.
> You're most welcome to expose it if you don't need the async
> support part of acomp.
I must be getting lost in terminology, and it feels to me that what is
discussed here is most likely of no interest to a lot of potential
users, especially ones that do compression/decompression. In majority of
cases they want to simply compress or decompress data, and they just
want to do it quickly and with minimal amount of memory consumed. They
do not particularly care if the task is being offloaded or executed on
the main CPU, either on separate thread or on the same thread, so the
discussion about scomp/acomp/etc is of no interest to them. From their
perspective they'd be totally fine with a wrapper that would do:
int decompress(...) {
prepare_request()
send_request()
wait_for_request()
}
and from their perspective this would be a synchronous API they are
happy with.
So from POV of such users what is actually missing is streaming mode of
compressing/decompressing where core would allow supplying additonal
data on demand and allow consuming output as it is being produced, and I
do not see anything like that in either scomp or acomp.
Thanks.
--
Dmitry
next prev parent reply other threads:[~2021-12-03 20:49 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-02 21:51 [PATCH 0/9] crypto: add zbufsize() interface Kees Cook
2018-08-02 21:51 ` [PATCH 1/9] " Kees Cook
2018-08-07 9:45 ` Herbert Xu
2018-08-07 18:10 ` Kees Cook
2018-08-08 2:53 ` Herbert Xu
2021-12-01 23:39 ` Kees Cook
2021-12-02 1:58 ` Herbert Xu
2021-12-02 3:51 ` Kees Cook
2021-12-02 3:57 ` Herbert Xu
2021-12-02 8:10 ` Kees Cook
2021-12-03 2:28 ` Herbert Xu
2021-12-03 20:49 ` Dmitry Torokhov [this message]
2021-12-07 5:20 ` Herbert Xu
2021-12-07 6:24 ` Dmitry Torokhov
2021-12-07 6:27 ` Herbert Xu
2018-08-02 21:51 ` [PATCH 2/9] crypto, 842: implement zbufsize() Kees Cook
2018-08-02 21:51 ` [PATCH 3/9] crypto, null: Implement zbufsize() Kees Cook
2018-08-02 21:51 ` [PATCH 4/9] crypto, lzo: " Kees Cook
2018-08-02 21:51 ` [PATCH 5/9] crypto, deflate: " Kees Cook
2018-08-02 21:51 ` [PATCH 6/9] crypto, zstd: " Kees Cook
2018-08-02 21:51 ` [PATCH 7/9] crypto, lz4: " Kees Cook
2018-08-02 21:51 ` [PATCH 8/9] crypto, lz4hc: " Kees Cook
2018-08-02 21:51 ` [PATCH 9/9] pstore: Use crypto_comp_zbufsize() Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YaqC1mkcyzO2WrI/@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=anton@enomsg.org \
--cc=arnd@arndb.de \
--cc=ccross@android.com \
--cc=geliangtang@gmail.com \
--cc=haren@us.ibm.com \
--cc=herbert@gondor.apana.org.au \
--cc=keescook@chromium.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tony.luck@intel.com \
--cc=wangzhou1@hisilicon.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox