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=-0.8 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 30BFDC433DF for ; Wed, 20 May 2020 10:27:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EA85220671 for ; Wed, 20 May 2020 10:26:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA85220671 Authentication-Results: mail.kernel.org; dmarc=none (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 7A32B80007; Wed, 20 May 2020 06:26:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7483A900002; Wed, 20 May 2020 06:26:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65DAD80007; Wed, 20 May 2020 06:26:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0215.hostedemail.com [216.40.44.215]) by kanga.kvack.org (Postfix) with ESMTP id 4F866900002 for ; Wed, 20 May 2020 06:26:59 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id F4222181AEF09 for ; Wed, 20 May 2020 10:26:58 +0000 (UTC) X-FDA: 76836719358.03.burn09_3ceb12b6a7221 X-HE-Tag: burn09_3ceb12b6a7221 X-Filterd-Recvd-Size: 3301 Received: from Galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 May 2020 10:26:58 +0000 (UTC) Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1jbLvm-00053v-Dk; Wed, 20 May 2020 12:26:34 +0200 Date: Wed, 20 May 2020 12:26:34 +0200 From: Sebastian Andrzej Siewior To: Song Bao Hua Cc: "linux-kernel@vger.kernel.org" , Peter Zijlstra , Ingo Molnar , Steven Rostedt , Will Deacon , Thomas Gleixner , "Paul E . McKenney" , Linus Torvalds , "Luis Claudio R. Goncalves" , Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , "linux-mm@kvack.org" , Linuxarm Subject: Re: [PATCH 8/8] mm/zswap: Use local lock to protect per-CPU data Message-ID: <20200520102634.pin4mzyytmfqtuo2@linutronix.de> References: <20200519201912.1564477-1-bigeasy@linutronix.de> <20200519201912.1564477-9-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 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: On 2020-05-19 21:46:06 [+0000], Song Bao Hua wrote: > Hi Luis, > In the below patch, in order to use the acomp APIs to leverage the power of hardware compressors. I have moved to mutex: > https://marc.info/?l=linux-crypto-vger&m=158941285830302&w=2 > https://marc.info/?l=linux-crypto-vger&m=158941287930311&w=2 > > so once we get some progress on that one, I guess we don't need a special patch for RT any more. If you convert this way from the current concept then we could drop it from the series. The second patch shows the following hunk: |@@ -1075,11 +1124,20 @@ static int zswap_frontswap_store(unsigned type, pgoff_t offset, | | /* compress */ | dst = get_cpu_var(zswap_dstmem); | acomp_ctx = *this_cpu_ptr(entry->pool->acomp_ctx); | put_cpu_var(zswap_dstmem); So here you get per-CPU version of `dst' and `acomp_ctx' and then allow preemption again. | mutex_lock(&acomp_ctx->mutex); | | src = kmap(page); | 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); and here you use `dst' and `acomp_ctx' after the preempt_disable() has been dropped so I don't understand why you used get_cpu_var(). It is either protected by the mutex and doesn't require get_cpu_var() or it isn't (and should have additional protection). | acomp_request_set_params(acomp_ctx->req, &input, &output, PAGE_SIZE, dlen); | ret = crypto_wait_req(crypto_acomp_compress(acomp_ctx->req), &acomp_ctx->wait); | dlen = acomp_ctx->req->dlen; | kunmap(page); | | if (ret) { | ret = -EINVAL; | goto put_dstmem; | Sebastian