From patchwork Sat May 2 02:04:18 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: 11523557 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 CC5B113B2 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 9E49C2184D for ; Sat, 2 May 2020 02:05:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E49C2184D 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) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 8F55B8E0001; Fri, 1 May 2020 22:05:11 -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 80B238E0005; Fri, 1 May 2020 22:05:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org 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-Spam-Summary: 50,0,0,7b004144eb79a5e3,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:2560: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.32:@hisilicon.com:.lbl8.mailshell.net-62.2.2.100 64.100.201.201,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:24,LUA_SUMMARY:none 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 X-Originating-IP: [10.126.201.216] 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, 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 queue those requests to acrytp drivers, and finally 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(-)