Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1284951ybz; Fri, 1 May 2020 19:05:53 -0700 (PDT) X-Google-Smtp-Source: APiQypIz9FhOzzwbkAq9Rj+Grad+9zQ8/xLlgUVDmMqNF0fVbUFOYVu317VGDkDMFJ7tfyarllSJ X-Received: by 2002:a17:906:680b:: with SMTP id k11mr6033709ejr.46.1588385153083; Fri, 01 May 2020 19:05:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588385153; cv=none; d=google.com; s=arc-20160816; b=iqs0W6sPusz92Ux3APrMxGEuEhM6om7aUtu41Z5iuYS/4MBlmpU+YMI5dkKF2F0myd 44f/aUvuCJifWkLCl1yck/euUMIDdxDEY9Zj0/Q7PDr8apf9WikcSD94fhgjfa+FhqNi 7byd8MKRzWMvGK9N4ew5WRjQwNrAu8NGVBeOgnA0719YNdfw9DLa2a+SAVO3Qo6MrdMB ma4Mh9/nnXCoa62GuNp1GC3f5iKFqsL4y5gTSI6Sms8JpBpCTDaYF51WyJiNthjIX46w mBBGUItZHreVRobSbKBiGJ6cH78PfRQOBSuMcMm1EM81qMQc04A8hHFcwd+1kirV0DZO BWHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Asuw2F8lAYFnDk9xgxowiJGr2swnb6wWIRSqkqLhJ4c=; b=BgOQyny7RnvNG8kB3wvreY2e8g19ZkqscMWRNHLnA8VbeSjV/QmzTpyMzo+FUNCiwN Z9B6HMAmLG8xy/NwC4mFLSWPUr0eqeOhU2XFWPtkUxY8OgN8TOyDgRvAQ7nncQ2fsh9n ExgX0hn8znk/aDht3u9sIkRgkkTiyQOqrE7+f1tt3G9ejek2T0hACrIKXZ8U8liWuCuw Hjxi/HZyW0QXoksW9sHrwE25tGCGjjCu8tGrujE0vpfBCGylp+0QVbt1aG9c7mrux4L1 ZULWnU9g9Zwy8kWyeRetmpc7I3Ic2Qd0RysASEKhd6uKANIy9ks9vCeNGgDQigK9IC9a dJ2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si3039409edn.445.2020.05.01.19.05.12; Fri, 01 May 2020 19:05:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726437AbgEBCFI (ORCPT + 99 others); Fri, 1 May 2020 22:05:08 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:41198 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726381AbgEBCFI (ORCPT ); Fri, 1 May 2020 22:05:08 -0400 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-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.126.201.216] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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(-) -- 2.23.0