• Barry Song's avatar
    mm/zswap: move to use crypto_acomp API for hardware acceleration · 1ec3b5fe
    Barry Song authored
    Right now, all new ZIP drivers are adapted to crypto_acomp APIs rather
    than legacy crypto_comp APIs.  Tradiontal ZIP drivers like lz4,lzo etc
    have been also wrapped into acomp via scomp backend.  But zswap.c is still
    using the old APIs.  That means zswap won't be able to work on any new ZIP
    drivers in kernel.
    
    This patch moves to use cryto_acomp APIs to fix the disconnected bridge
    between new ZIP drivers and zswap.  It is probably the first real user to
    use acomp but perhaps not a good example to demonstrate how multiple acomp
    requests can be executed in parallel in one acomp instance.  frontswap is
    doing page load and store page by page synchronously.  swap_writepage()
    depends on the completion of frontswap_store() to decide if it should call
    __swap_writepage() to swap to disk.
    
    However this patch creates multiple acomp instances, so multiple threads
    running on multiple different cpus can actually do (de)compression
    parallelly, leveraging the power of multiple ZIP hardware queues.  This is
    also consistent with frontswap's page management model.
    
    The old zswap code uses atomic context and avoids the race conditions
    while shared resources like zswap_dstmem are accessed.  Here since acomp
    can sleep, per-cpu mutex is used to replace preemption-disable.
    
    While it is possible to make mm/page_io.c and mm/frontswap.c support async
    (de)compression in some way, the entire design requires careful thinking
    and performance evaluation.  For the first step, the base with fixed
    connection between ZIP drivers and zswap should be built.
    
    Link: https://lkml.kernel.org/r/20201107065332.26992-1-song.bao.hua@hisilicon.comSigned-off-by: default avatarBarry Song <song.bao.hua@hisilicon.com>
    Acked-by: default avatarVitaly Wool <vitalywool@gmail.com>
    Cc: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Herbert Xu <herbert@gondor.apana.org.au>
    Cc: David S. Miller <davem@davemloft.net>
    Cc: Mahipal Challa <mahipalreddy2006@gmail.com>
    Cc: Seth Jennings <sjenning@redhat.com>
    Cc: Dan Streetman <ddstreet@ieee.org>
    Cc: Zhou Wang <wangzhou1@hisilicon.com>
    Cc: Colin Ian King <colin.king@canonical.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
    1ec3b5fe
zswap.c 38.3 KB