linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <song.bao.hua@hisilicon.com>
To: <herbert@gondor.apana.org.au>, <sjenning@redhat.com>,
	<ddstreet@ieee.org>, <vitaly.wool@konsulko.com>,
	<akpm@linux-foundation.org>
Cc: <mahipalreddy2006@gmail.com>, <linux-mm@kvack.org>,
	<linux-crypto@vger.kernel.org>, <linuxarm@huawei.com>,
	Barry Song <song.bao.hua@hisilicon.com>
Subject: [PATCH RESEND 0/1] mm/zswap: move to use crypto_acomp APIs
Date: Thu, 14 May 2020 11:33:17 +1200	[thread overview]
Message-ID: <20200513233318.10496-1-song.bao.hua@hisilicon.com> (raw)

Hi Seth, Dan, Vitaly, Herbert, Andrew,

Using crypto_comp APIs, zswap is not able to use the hardware accelators which
are only ported to cryto_acomp nowadays. So Mahipal Challa tried to solve this
problem by the below patch a long time ago:
mm: zswap - Add crypto acomp/scomp framework support [1]

At that time, the test was based on acomp with scomp backend. It was not a real
async platform. On a platform with real acomp support like hisilicon-zip, the
patch will lead to serious "sleep on atomic" issues.

To leverage the power of hardware accelerator, right now, I am sending a new patch
which will remove the atomic context and permit crypto to sleep in zswap.

Literally, using an async compressor, people can dynamically allocate acomp_req and
multiple requests can queue in acomp drivers, and finally acomp drivers can use the
callback to notify the completion of compression/decompression. but this will require
dynamic memory allocation and various synchronizations in zswap, and it is too
complex.

Alternatively, this patch pre-allocates the acomp_req with the same number of CPUs.
For each acomp_req, one mutex and one wait are bound with it. The mutex is used
for the race protection of the acomp_req and other percpu resources. Even though
the preempt-disabled atomic context is replaced by sleepable context, threads
might migrate, but the mutex can still protect the race between CPUs for same
resources.

Tested on hisilicon zip driver on a SMP enviorment and on lz4 scomp-based acomp
as well. To use scomp-based acomp, another patch I sent before is needed:
crypto: acomp - search acomp with scomp backend in crypto_has_acomp [2]

[1] https://www.spinics.net/lists/linux-mm/msg122455.html
[2] https://marc.info/?l=linux-crypto-vger&m=158822346227760&w=2

Barry Song (1):
  mm/zswap: move to use crypto_acomp API for hardware acceleration

 mm/zswap.c | 150 ++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 108 insertions(+), 42 deletions(-)

-- 
2.23.0



             reply	other threads:[~2020-05-13 23:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13 23:33 Barry Song [this message]
2020-05-13 23:33 ` [PATCH RESEND 1/1] mm/zswap: move to use crypto_acomp API for hardware acceleration Barry Song

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=20200513233318.10496-1-song.bao.hua@hisilicon.com \
    --to=song.bao.hua@hisilicon.com \
    --cc=akpm@linux-foundation.org \
    --cc=ddstreet@ieee.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linuxarm@huawei.com \
    --cc=mahipalreddy2006@gmail.com \
    --cc=sjenning@redhat.com \
    --cc=vitaly.wool@konsulko.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;
as well as URLs for NNTP newsgroup(s).