linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RESEND 0/1] mm/zswap: move to use crypto_acomp APIs
@ 2020-05-13 23:33 Barry Song
  2020-05-13 23:33 ` [PATCH RESEND 1/1] mm/zswap: move to use crypto_acomp API for hardware acceleration Barry Song
  0 siblings, 1 reply; 2+ messages in thread
From: Barry Song @ 2020-05-13 23:33 UTC (permalink / raw)
  To: herbert, sjenning, ddstreet, vitaly.wool, akpm
  Cc: mahipalreddy2006, linux-mm, linux-crypto, linuxarm, Barry Song

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-05-13 23:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-13 23:33 [PATCH RESEND 0/1] mm/zswap: move to use crypto_acomp APIs Barry Song
2020-05-13 23:33 ` [PATCH RESEND 1/1] mm/zswap: move to use crypto_acomp API for hardware acceleration Barry Song

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).