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.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS 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 35770C4741F for ; Mon, 9 Nov 2020 10:29:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 88D2020897 for ; Mon, 9 Nov 2020 10:29:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="DkqJWn72"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kBMeCola" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 88D2020897 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linutronix.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9C6666B0036; Mon, 9 Nov 2020 05:29:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9512E6B005D; Mon, 9 Nov 2020 05:29:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 819356B0068; Mon, 9 Nov 2020 05:29:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 566076B0036 for ; Mon, 9 Nov 2020 05:29:14 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id F0B251EE6 for ; Mon, 9 Nov 2020 10:29:13 +0000 (UTC) X-FDA: 77464507386.17.flesh32_2106d30272eb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id D1819180D0184 for ; Mon, 9 Nov 2020 10:29:13 +0000 (UTC) X-HE-Tag: flesh32_2106d30272eb X-Filterd-Recvd-Size: 4116 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Mon, 9 Nov 2020 10:29:13 +0000 (UTC) Date: Mon, 9 Nov 2020 11:29:09 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1604917750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nXSfGPHblcxD6fRoSPhPSSHFsJUTblx0RZ8tFRLfhus=; b=DkqJWn72jRCdyw9uxzDjB+Lsv1iGa/AL0tJGQT51XDOa5/yv0Yo0PSxn+RprFoHPXenYs4 7tEF4j+WmF92KO/7HTNbU3GnE/EhopTRrvoUYqZAmdY4pTMrG1JFoB/Q8vKTZN6ECiqzRL L0cuipHHmQQl/cu9Cn9bMGO8MvzzCxdCx1hfzMdH+/dwYmZN4aKgPynNFgcAJVaSPxa8VX TsNl8rniTpK0Fuoj94OjtxaxpNv/A0WNqIamWtanr1dVKJ6cX2e3DFTpJip73BpEz4TkoB Qt1x7N/ImlN/ZlK1QVSZTZ9aqaN+j2Jp2sXMULM9PzGaKIk1BfkVtj8R7EwtpA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1604917750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nXSfGPHblcxD6fRoSPhPSSHFsJUTblx0RZ8tFRLfhus=; b=kBMeColad+U3332dzsE7I9XTLjw2q7CtyaCiVgwtRZW/gmgaf4NNwhDqeGpOvZEl4sVt5L oqT22564Yk3ngPDA== From: Sebastian Andrzej Siewior To: Barry Song Cc: linux-mm@kvack.org, linux-crypto@vger.kernel.org, akpm@linux-foundation.org, linuxarm@huawei.com, fanghao11@huawei.com, linux-kernel@vger.kernel.org, Vitaly Wool , "Luis Claudio R . Goncalves" , Herbert Xu , "David S . Miller" , Mahipal Challa , Seth Jennings , Dan Streetman , Zhou Wang , Colin Ian King Subject: Re: [PATCH v7] mm/zswap: move to use crypto_acomp API for hardware acceleration Message-ID: <20201109102909.u34zzudqqng6nhg6@linutronix.de> References: <20201107065332.26992-1-song.bao.hua@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20201107065332.26992-1-song.bao.hua@hisilicon.com> 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: I've been looking at the patch and it looks like it should work. Having numbers to backup the performance in the pure-software version and with HW acceleration would _very_ nice to have. On 2020-11-07 19:53:32 [+1300], Barry Song wrote: > index fbb7829..73f04de 100644 > --- a/mm/zswap.c > +++ b/mm/zswap.c > @@ -415,30 +445,54 @@ static int zswap_dstmem_dead(unsigned int cpu) =E2=80=A6 > + acomp_ctx->req =3D req; > + > + crypto_init_wait(&acomp_ctx->wait); > + /* > + * if the backend of acomp is async zip, crypto_req_done() will wakeup > + * crypto_wait_req(); if the backend of acomp is scomp, the callback > + * won't be called, crypto_wait_req() will return without blocking. > + */ > + acomp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, > + crypto_req_done, &acomp_ctx->wait); > + > + acomp_ctx->mutex =3D per_cpu(zswap_mutex, cpu); > + acomp_ctx->dstmem =3D per_cpu(zswap_dstmem, cpu); You added a comment here and there you never mentioned that this single per-CPU mutex protects the per-CPU context (which you can have more than one on a single CPU) and the scratch/dstmem which is one per-CPU. Of course if you read the code you figure it out. I still think that you should have a pool of memory and crypto contexts which you can use instead of having them strictly per-CPU. The code is fully preemptible and you may have multiple requests on the same CPU. Yes, locking works but at the same you block processing while waiting on a lock and the "reserved memory" on other CPUs remains unused. Sebastian