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=-1.0 required=3.0 tests=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 25417C433E0 for ; Fri, 26 Jun 2020 08:22:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CA2A620775 for ; Fri, 26 Jun 2020 08:22:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CA2A620775 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 654F06B0003; Fri, 26 Jun 2020 04:22:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DC856B0005; Fri, 26 Jun 2020 04:22:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A4816B000A; Fri, 26 Jun 2020 04:22:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0027.hostedemail.com [216.40.44.27]) by kanga.kvack.org (Postfix) with ESMTP id 2B5AB6B0003 for ; Fri, 26 Jun 2020 04:22:24 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8D13F824556B for ; Fri, 26 Jun 2020 08:22:23 +0000 (UTC) X-FDA: 76970670966.15.stick33_3502fe326e53 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 635F31814B0C8 for ; Fri, 26 Jun 2020 08:22:23 +0000 (UTC) X-HE-Tag: stick33_3502fe326e53 X-Filterd-Recvd-Size: 5263 Received: from huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Fri, 26 Jun 2020 08:22:22 +0000 (UTC) Received: from dggemi406-hub.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id 930681BD52C6200B705D; Fri, 26 Jun 2020 16:22:09 +0800 (CST) Received: from DGGEMI525-MBS.china.huawei.com ([169.254.6.126]) by dggemi406-hub.china.huawei.com ([10.3.17.144]) with mapi id 14.03.0487.000; Fri, 26 Jun 2020 16:22:00 +0800 From: "Song Bao Hua (Barry Song)" To: Herbert Xu CC: "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , Linuxarm , "Luis Claudio R . Goncalves" , Sebastian Andrzej Siewior , "David S . Miller" , "Mahipal Challa" , Seth Jennings , "Dan Streetman" , Vitaly Wool , "Wangzhou (B)" , Colin Ian King Subject: RE: [PATCH v3] mm/zswap: move to use crypto_acomp API for hardware acceleration Thread-Topic: [PATCH v3] mm/zswap: move to use crypto_acomp API for hardware acceleration Thread-Index: AQHWS4ju6iURsG9yIk+EgvuPOVc69qjp91mAgACMbECAAAjt4A== Date: Fri, 26 Jun 2020 08:22:00 +0000 Message-ID: References: <20200626070903.27988-1-song.bao.hua@hisilicon.com> <20200626072027.GA6153@gondor.apana.org.au> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.126.200.84] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 635F31814B0C8 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 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: > > -----Original Message----- > > From: linux-kernel-owner@vger.kernel.org > > [mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of Herbert Xu > > Sent: Friday, June 26, 2020 7:20 PM > > To: Song Bao Hua (Barry Song) > > Cc: akpm@linux-foundation.org; linux-mm@kvack.org; > > linux-kernel@vger.kernel.org; Linuxarm ; Luis > > Claudio R . Goncalves ; Sebastian Andrzej Siewior > > ; David S . Miller ; > > Mahipal Challa ; Seth Jennings > > ; Dan Streetman ; Vitaly Wool > > ; Wangzhou (B) ; > > Colin Ian King > > Subject: Re: [PATCH v3] mm/zswap: move to use crypto_acomp API for > > hardware acceleration > > > > On Fri, Jun 26, 2020 at 07:09:03PM +1200, Barry Song wrote: > > > > > > + mutex_lock(&acomp_ctx->mutex); > > > + > > > + src =3D kmap(page); > > > + dst =3D acomp_ctx->dstmem; > > > + sg_init_one(&input, src, PAGE_SIZE); > > > + /* zswap_dstmem is of size (PAGE_SIZE * 2). Reflect same in sg_list= */ > > > + sg_init_one(&output, dst, PAGE_SIZE * 2); > > > + acomp_request_set_params(acomp_ctx->req, &input, &output, > > PAGE_SIZE, dlen); > > > + ret =3D crypto_wait_req(crypto_acomp_compress(acomp_ctx->req), > > &acomp_ctx->wait); > > > + dlen =3D acomp_ctx->req->dlen; > > > + kunmap(page); > > > > Waiting on an async request like this is just silly. This defeats the > > whole purpose of having a fallback. >=20 > For this zswap case and for this moment, it is probably not. > As for this case, there are no two parallel (de)compressions which can be= done > in parallel in a single (de)compressor instance. > The original zswap code is doing all compression/decompression in atomic > context. > Right now, to use acomp api, the patch has moved to sleep-able context. >=20 > However, compression/decompression can be done in parallel in different > instances of acomp, also different cpus. >=20 > If we want to do multiple (de)compressions simultaneously in one acomp > instance by callbacks, it will ask a large changes in zswap.c not only us= ing the > new APIs. I think we can only achieve the ideal goal step by step. On the other hand, I also don't think mm/frontswap.c supports async store. = It is pretty much a sync operation to call store callback of frontswap for every single page: int __frontswap_store(struct page *page) { ... /* Try to store in each implementation, until one succeeds. */ for_each_frontswap_ops(ops) { ret =3D ops->store(type, offset, page); if (!ret) /* successful store */ break; } ... if (frontswap_writethrough_enabled) /* report failure so swap also writes to swap device */ ret =3D -1; return ret; } If we don't want to execute a sync wait in zswap, a lot of things need chan= ges, not only zswap. >=20 > > > > Cheers, > > -- > > Email: Herbert Xu Home Page: > > http://gondor.apana.org.au/~herbert/ > > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt >=20 > -barry Thanks Barry