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 D7E71C433E0 for ; Wed, 20 May 2020 11:58:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A4584207D4 for ; Wed, 20 May 2020 11:58:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A4584207D4 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 21DA880007; Wed, 20 May 2020 07:58:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1CF5E900002; Wed, 20 May 2020 07:58:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0E45080007; Wed, 20 May 2020 07:58:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id E7715900002 for ; Wed, 20 May 2020 07:58:05 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A39B5181AC9CB for ; Wed, 20 May 2020 11:58:05 +0000 (UTC) X-FDA: 76836948930.05.flesh17_80cbde2876c4e X-HE-Tag: flesh17_80cbde2876c4e X-Filterd-Recvd-Size: 2706 Received: from Galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Wed, 20 May 2020 11:58:04 +0000 (UTC) Received: from bigeasy by Galois.linutronix.de with local (Exim 4.80) (envelope-from ) id 1jbNLx-00071O-Su; Wed, 20 May 2020 13:57:42 +0200 Date: Wed, 20 May 2020 13:57:41 +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: <20200520115741.wy2qnmauxmjtrrzj@linutronix.de> References: <20200519201912.1564477-1-bigeasy@linutronix.de> <20200519201912.1564477-9-bigeasy@linutronix.de> <20200520102634.pin4mzyytmfqtuo2@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-20 11:13:31 [+0000], Song Bao Hua wrote: > For example, on cpu1, once you begin to compress, you hold the percpu acomp-ctx and percpu destination buffer of CPU1, the below code makes sure you get the acomp and dstmem from the same core by disabling preemption with get_cpu_var and put_cpu_var: > dst = get_cpu_var(zswap_dstmem); > acomp_ctx = *this_cpu_ptr(entry->pool->acomp_ctx); > put_cpu_var(zswap_dstmem); > > then there are two cases: > > 1. after getting dst and acomp_ctx of cpu1, you might always work in cpu1, the mutex in per-cpu acomp-ctx will guarantee two compressions won't do at the same core in parallel, and it also makes certain compression and decompression won't do at the same core in parallel. Everything is like before. For readability I suggest not to mix per-CPU and per-CTX variables like that. If zswap_dstmem is protected by the mutex, please make it part of acomp_ctx. Sebastian