From patchwork Wed May 13 23:33:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Song Bao Hua (Barry Song)" X-Patchwork-Id: 11547461 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E29CC14EB 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 9E0EF206F5 for ; Wed, 13 May 2020 23:34:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E0EF206F5 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 773FA900022; Wed, 13 May 2020 19:34:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org 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-Original-To: linux-mm@kvack.org 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-Spam-Summary: 2,0,0,cf8940dbcbe0d8f3,d41d8cd98f00b204,song.bao.hua@hisilicon.com,,RULES_HIT:41:69:196:355:379:541:582:967:968:973:988:989:1152:1260:1261:1277:1311:1313:1314:1345:1437:1515:1516:1518:1534:1542:1622:1711:1730:1747:1777:1792:2393:2525:2559:2564:2682:2685:2693:2859:2897:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:5007:6117:6119:6261:6671:7875:7903:9025:10004:10400:11026:11658:11914:12043:12048:12050:12291:12295:12296:12297:12555:12663:12679:12683:12895:12986:13007:13071:13161:13229:13894:14095:14180:14181:14394:14721:21060:21080:21324:21433:21451:21627:21740:21966:30017:30034:30054,0,RBL:45.249.212.190:@hisilicon.com:.lbl8.mailshell.net-64.201.201.201 62.14.2.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:29,LUA_SUMMARY:none 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 X-Originating-IP: [10.126.202.158] X-CFilter-Loop: Reflected 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 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(-)