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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3460FC46CA0 for ; Tue, 28 Nov 2023 14:09:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0E616B0304; Tue, 28 Nov 2023 09:09:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 997126B0306; Tue, 28 Nov 2023 09:09:27 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 811496B0307; Tue, 28 Nov 2023 09:09:27 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 670416B0304 for ; Tue, 28 Nov 2023 09:09:27 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1D8DBC0269 for ; Tue, 28 Nov 2023 14:09:27 +0000 (UTC) X-FDA: 81507545574.24.D73917A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf28.hostedemail.com (Postfix) with ESMTP id BC4AAC0054 for ; Tue, 28 Nov 2023 14:09:23 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=uUVvi2np; dmarc=none; spf=none (imf28.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701180564; h=from:from:sender: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:dkim-signature; bh=A7y0NaJ5ptNfygrxlKgEvacGOGqd4/7FIdJrvhOt2fQ=; b=2JAS+gAO1HkQPjIU2jb/hZ3m65pX6R/gE6zgtiDUqRZZUMR+WqmyFHLSOeE73kXV5IDNQ8 f3rwN8zTWGfFIBJhrZRh64IguxdSMqvFUR3YBwBDpthOmDBSNAOYOZEqE4Kt5Om4oXWB+/ N/czm3d2VqSdgaGhnSFZy4s9XmFjcj0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=uUVvi2np; dmarc=none; spf=none (imf28.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701180564; a=rsa-sha256; cv=none; b=bkBZrIZhUv625b4uVSeM4ogzBU1PVqE8G8IIhKDUWpgX2f2JRySVkFYB4CDtxRLz/X9j9R P10/bbULixw+SNTJtscvT7OXALPxDfVCwSy8R0I6Fy8vga7vyCygHNDUKF/USnhQdzuuKb SSpXnt714b4ZK+jdjSr6kJXsSibWsFA= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Transfer-Encoding: Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Sender:Reply-To:Content-ID:Content-Description; bh=A7y0NaJ5ptNfygrxlKgEvacGOGqd4/7FIdJrvhOt2fQ=; b=uUVvi2npCvBXaVE6gIxQKBfIQv CTE+dhpfxOetIJE/TyjYvkaa02UjWwAMADAt6T2Ql/5IM2pVvPgkMzQDaNhUOXRIQnWEJ3KZU4IR1 UlswKcp3yz+7Gx/z9sUTpUis/wl7HWwlhF2hbZs6KqIa/wn2hXngJNfxtBAOfgrt6a1WFka1UfPtB Uj+jvalgspDkRSf8OfGuFYGdS/Ni/y2F5Q8bJ6zkGY73N8lWnnKbPVDwY1Obu3NgtFM9Nv3Vx2HFk DhNgixO40A5MK3IkrL2eHOD4moFyH4mWH0osEBYHBPYEOSbj84SRv0+Z4rvHd9eHTF2e7J4pckxUw ZZ2OmDcA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1r7ylz-00CQ5n-W8; Tue, 28 Nov 2023 14:09:12 +0000 Date: Tue, 28 Nov 2023 14:09:11 +0000 From: Matthew Wilcox To: Chris Li Cc: "Fabio M. De Francesco" , Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ira Weiny , Nhat Pham Subject: Re: [PATCH] mm/zswap: Replace kmap_atomic() with kmap_local_page() Message-ID: References: <20231127160058.586446-1-fabio.maria.de.francesco@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspamd-Queue-Id: BC4AAC0054 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: dg3wzx4yuwntrc7wtyggkxmaei8ixu1f X-HE-Tag: 1701180563-426804 X-HE-Meta: U2FsdGVkX1+u6ABeq3XNoRWuttxGWRrVpQoDChNkESIRzElgBOK00eMBqZdt0Sn7GIWyDUVT5/Eb0K/br2OjoLxoAdTZ7jhVvY5fzxBuH4+T9A7wnKYDoomNAKGn/XBk5WiSC77Rpnn4JhEXkknh7vmdMcmqUvN+JNpCEqO6v4kt3fOJhrmMsNwiv8E9aiE7SjcXy5uuTJuvhfrxrSl3nfnzXGsNs7GCiKl0UuqbNpx80wqjNp956aWrErLu+V2N86IcFtLLnQvmag7rjUaZkTeFNyIukGEu2FeUtmUOgR0So52sldzvWR3t40EPQ/CZ0f6DKSxKBX9JijGJZsKVVlM/XZElQOUamGr44FtRaTujIeU3T1BYep43KQ/OIUc9RXIg/y4A9ChMOr1ZDB5pFqtU0jmT2ZkGglK05N4XvmkrrLLKhPyb/06Xb9osBwgLbNaSceKz6U12uR7zXcxMy8zbOj29QVX5/7srIUaRpAintg+iCZ4e/H+SCKOjPMBqUboKobkMy+Hn16UTiwFqfH4xP2Xq2xX1LhDWe0+IbcUo9gYKE/CRnm2MmHlzb2i+WEhbsuifHhdKD8u+XAnaUSW0YNmcZ88d0fX5EWL+QxwThRtodsQ1gVtxxTCxIFxf7SMVGO+oC800VgOLRG5d7KXbUCDn5hkxPEeJDrTL2d2rzFs8PfEkiV/esFkTp8wy+Kb3OqwINkwFcnrIuTxlAlqGtCbeDrX3zK9c6hedSOStJTYassKXgyXG+QD4kd7DA9H31ybf9+gEM2yeIw3lCBzlytYU38fmzJVMe0Chd1JwmwxjLm1xRlwp2M+/M7GE2jOo+sYHmhn9042cx315821iWM3bkzTKf7hApHO+m/ZTHta2sh00Kycl0nyuAu7Y7FLckIqt7/+m0GIsSYqw2FTFEGPuEPKJ0sp2MZaR9dEh6QFGs2WJk095LxaNSqoVSIXzTWAg73KS3sn+ThI OWFfR+qp CRg9hMLvjEDn+B7rmu3dhXpzQfxeSvmIHjnQcoSvj/FOKD+WzEZDl24H96sQyV+yd6iK1SJJ35yfJXpCGFUin90Q1h0Mu6sbM2QzC0ilB8P0jYxoz0F5nCRF1ZZLK7zXch+XFlKYZKD46ikmh127nmS8xsoqR48RlA0cpKAmfrJ+N/kEp0i6T1kmOKue8Axdlv0MNS1DT+qM32ps= 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: List-Subscribe: List-Unsubscribe: On Mon, Nov 27, 2023 at 12:16:56PM -0800, Chris Li wrote: > Hi Fabio, > > On Mon, Nov 27, 2023 at 8:01 AM Fabio M. De Francesco > wrote: > > > > kmap_atomic() has been deprecated in favor of kmap_local_page(). > > > > Therefore, replace kmap_atomic() with kmap_local_page() in > > zswap.c. > > > > kmap_atomic() is implemented like a kmap_local_page() which also > > disables page-faults and preemption (the latter only in !PREEMPT_RT > > kernels). The kernel virtual addresses returned by these two API are > > only valid in the context of the callers (i.e., they cannot be handed to > > other threads). > > > > With kmap_local_page() the mappings are per thread and CPU local like > > in kmap_atomic(); however, they can handle page-faults and can be called > > from any context (including interrupts). The tasks that call > > kmap_local_page() can be preempted and, when they are scheduled to run > > again, the kernel virtual addresses are restored and are still valid. > > As far as I can tell, the kmap_atomic() is the same as > kmap_local_page() with the following additional code before calling to > "__kmap_local_page_prot(page, prot)", which is common between these > two functions. > > if (IS_ENABLED(CONFIG_PREEMPT_RT)) > migrate_disable(); > else > preempt_disable(); > > pagefault_disable(); > > >From the performance perspective, kmap_local_page() does less so it > has some performance gain. I am trying to think would it have another > unwanted side effect of enabling interrupt and page fault while zswap > decompressing a page. > The decompression should not generate page fault. The interrupt > enabling might introduce extra latency, but most of the page fault was > having interrupt enabled anyway. The time spent in decompression is > relatively small compared to the whole duration of the page fault. So > the interrupt enabling during those short windows should be fine. > "Should" is the famous last word. Interrupts are enabled with kmap_atomic() too. The difference is whether we can be preempted by a higher-priority process.