From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D335FC47256 for ; Sat, 2 May 2020 02:05:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5D044208C3 for ; Sat, 2 May 2020 02:05:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D044208C3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=hisilicon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 944788E0005; Fri, 1 May 2020 22:05:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F55B8E0001; Fri, 1 May 2020 22:05:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80B238E0005; Fri, 1 May 2020 22:05:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id 68E5A8E0001 for ; Fri, 1 May 2020 22:05:11 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 186E4181AEF0B for ; Sat, 2 May 2020 02:05:11 +0000 (UTC) X-FDA: 76770136422.15.hill39_101309ecf5724 X-HE-Tag: hill39_101309ecf5724 X-Filterd-Recvd-Size: 3209 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Sat, 2 May 2020 02:05:10 +0000 (UTC) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id BDCA7CF23728FDA7E433; Sat, 2 May 2020 10:05:06 +0800 (CST) Received: from SWX921481.china.huawei.com (10.126.201.216) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Sat, 2 May 2020 10:04:59 +0800 From: Barry Song To: , , , CC: , , , , Barry Song Subject: [PATCH 0/1] mm/zswap: move to use crypto_acomp APIs Date: Sat, 2 May 2020 14:04:18 +1200 Message-ID: <20200502020419.11616-1-song.bao.hua@hisilicon.com> X-Mailer: git-send-email 2.21.0.windows.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.201.216] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Seth, Dan, Vitaly, Herbert, 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 aco= mp_req and queue those requests to acrytp drivers, and finally use the callback to n= otify the completion of compression/decompression. but this will require dynami= c memory allocation and various synchronizations in zswap, and it is too complex. Alternatively, this patch pre-allocates the acomp_req with the same numbe= r of CPUs. For each acomp_req, one mutex and one wait are bound with it. The mutex i= s 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, thr= eads 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=3Dlinux-crypto-vger&m=3D158822346227760&w=3D2 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(-) --=20 2.23.0