lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 9 Jul 2020 09:09:02 +0000
From:   "Song Bao Hua (Barry Song)" <song.bao.hua@...ilicon.com>
To:     Sebastian Andrzej Siewior <bigeasy@...utronix.de>
CC:     "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
        "herbert@...dor.apana.org.au" <herbert@...dor.apana.org.au>,
        "davem@...emloft.net" <davem@...emloft.net>,
        "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Linuxarm <linuxarm@...wei.com>,
        "Luis Claudio R . Goncalves" <lgoncalv@...hat.com>,
        Mahipal Challa <mahipalreddy2006@...il.com>,
        Seth Jennings <sjenning@...hat.com>,
        Dan Streetman <ddstreet@...e.org>,
        Vitaly Wool <vitaly.wool@...sulko.com>,
        "Wangzhou (B)" <wangzhou1@...ilicon.com>,
        "Colin Ian King" <colin.king@...onical.com>
Subject: RE: [PATCH v4] mm/zswap: move to use crypto_acomp API for hardware
 acceleration



> -----Original Message-----
> From: owner-linux-mm@...ck.org [mailto:owner-linux-mm@...ck.org] On
> Behalf Of Sebastian Andrzej Siewior
> Sent: Thursday, July 9, 2020 8:41 PM
> To: Song Bao Hua (Barry Song) <song.bao.hua@...ilicon.com>
> Cc: akpm@...ux-foundation.org; herbert@...dor.apana.org.au;
> davem@...emloft.net; linux-crypto@...r.kernel.org; linux-mm@...ck.org;
> linux-kernel@...r.kernel.org; Linuxarm <linuxarm@...wei.com>; Luis Claudio
> R . Goncalves <lgoncalv@...hat.com>; Mahipal Challa
> <mahipalreddy2006@...il.com>; Seth Jennings <sjenning@...hat.com>;
> Dan Streetman <ddstreet@...e.org>; Vitaly Wool
> <vitaly.wool@...sulko.com>; Wangzhou (B) <wangzhou1@...ilicon.com>;
> Colin Ian King <colin.king@...onical.com>
> Subject: Re: [PATCH v4] mm/zswap: move to use crypto_acomp API for
> hardware acceleration
> 
> On 2020-07-09 07:55:22 [+0000], Song Bao Hua (Barry Song) wrote:
> > Hello Sebastian, thanks for your reply and careful review.
> Hi,
> 
> > I don't think we can simply "forward the result to the caller and let him
> decide".
> > Would you like to present some pseudo code?
> 
> I provided just some pseudo code to illustrate an example how the async
> interface should look like (more or less). The essential part is where
> you allow to feed multiple requests without blocking.

Sebastian, Do you mean the below code?

@@ -252,12 +252,15 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
                unlock_page(page);
                goto out;
        }
-       if (frontswap_store(page) == 0) {
+       ret = frontswap_store(page);
+       if (ret == 0) {
                set_page_writeback(page);
                unlock_page(page);
                end_page_writeback(page);
                goto out;
        }
+       if (ret = -EINPROGRESS)
+               goto out;
        ret = __swap_writepage(page, wbc, end_swap_bio_write);
 out:
        return ret;

I think this won' work. -EINPROGRESS won't be able to decide if we should goto out. We can only goto out if the compression
has done without any error. The error might be because of HW like EIO or because the data is not suitable to compress. We can
only know the result after the compression is really done and the completion callback is called by ZIP drivers.

If the compression is still INPROGRESS, we don't know what will happen.

> I went up the call-chain and found one potential user which seem to have
> a list of pages which are processed. This looked like a nice example. I
> haven't looked at the details.
> 
> I have no opinion whether or not it makes sense to switch to the async
> interface in a sync way.

I always appreciate your comment and your opinion.

The real problem here is that all of those new zip drivers are adapted to async interface. There is no old interface support
for those new drivers mainlined these years. zswap doesn’t work on those new drivers as they totally don't support
crypto_comp_compress()
crypto_comp_decompress()
...

So the initial goal of this patch is fixing the disconnected bridge between new zip drivers and zswap.

Making frontswap async can probably happen if we see performance improvement. But it seems it is a big project, not
that simple. On the other hand, it seems hisi_zip in drivers/crypto is the only async driver till now. Sorry if I am missing
any one. other drivers are adapted to acomp APIs by scomp APIs. For example:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/crypto/lz4.c?id=8cd9330e0a
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/crypto/lzo.c?id=ac9d2c4b3

So even we make frontswap totally async, most zip drivers are still sync and we don't get the benefit. From my prospective,
I am glad to try the possibility of making frontswap async to leverage the power of ZIP hardware. This would probably and
only happen after we have a base to support acomp APIs.

Thanks
Barry

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ