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.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 6AA69C433E2 for ; Wed, 13 May 2020 23:34:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3025520693 for ; Wed, 13 May 2020 23:34:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3025520693 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 7C2F8900139; Wed, 13 May 2020 19:34:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 773FA900022; Wed, 13 May 2020 19:34:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AFE6900139; Wed, 13 May 2020 19:34:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 5066D900022 for ; Wed, 13 May 2020 19:34:18 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 18C272DFC for ; Wed, 13 May 2020 23:34:18 +0000 (UTC) X-FDA: 76813301796.26.scent17_7cc87becad953 X-HE-Tag: scent17_7cc87becad953 X-Filterd-Recvd-Size: 3281 Received: from huawei.com (szxga04-in.huawei.com [45.249.212.190]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Wed, 13 May 2020 23:34:17 +0000 (UTC) Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0D22CE1E6186BDFC7A6E; Thu, 14 May 2020 07:34:14 +0800 (CST) Received: from SWX921481.china.huawei.com (10.126.202.158) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.487.0; Thu, 14 May 2020 07:34:05 +0800 From: Barry Song To: , , , , CC: , , , , Barry Song Subject: [PATCH RESEND 0/1] mm/zswap: move to use crypto_acomp APIs Date: Thu, 14 May 2020 11:33:17 +1200 Message-ID: <20200513233318.10496-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.202.158] 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, 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 aco= mp_req and multiple requests can queue in acomp drivers, and finally acomp drivers c= an use the callback to notify the completion of compression/decompression. but this = will require dynamic memory allocation and various synchronizations in zswap, and it i= s 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