Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4511429rdh; Wed, 29 Nov 2023 03:41:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFNzvyqTH+6xO6U92aivplssokwyzj/hcrYlfcDxlIFK5j9wmElaSEBT0UXml3O5T5UQ6q/ X-Received: by 2002:a05:6a00:35ce:b0:6cb:8c91:682 with SMTP id dc14-20020a056a0035ce00b006cb8c910682mr21162650pfb.29.1701258097114; Wed, 29 Nov 2023 03:41:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701258097; cv=none; d=google.com; s=arc-20160816; b=W5bY1SInzpfy7NvsEtOtH27x/dqh3m9Kggz35b1Ks+Lcc7PzGDM/zDhmJaHlFm1K9E nKJK5pZj3a6oXVuoj8ootYIjz3T9PD9HsN5GYerDSFJNdxK8d1+yICbJsusJlD20DDm6 PV7VNoO7c7DdWFPV5kGHGhu/fjFrkPFBABa29DVIUkwMAB9txPv1wtV+8QUfOHZfyDqX YkFtv453i8DChYhPoaUHYqIPTUYw2uwmqu1D6t3TIqwH/na7mlEfq661iqh5sTxW3NXZ /m7KZWOnC771NcIx5FbV1grqcvgK45cCxFYQtptrWgSWVkMpriTiZJoeysL8123cs67j jI/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:organization:message-id:date:subject:cc:to :from:dkim-signature; bh=kiJTXTz4UDFclWho9xeBx/36rju71QIU4DUd59UcG+I=; fh=Yno0BELBnTmQLikFM9eijSV533bHwJ0MCJ3qjLIMLhc=; b=vQsWQLv6E/Qx5JzaMqP1oFi34VDAr2lF6rVimUJHYz10tRWPAj6uQoofYUyl6YjTbm OeGKcFgylj3Tr7SpV5VbFvnNoe2u88iWXjFWB8tHuAqitta8RFhezDFPP2zRfTo5Ezm3 cDhWsBDG6BqvpLtEVaSrgNpHJBDv8s4getbwzLWOgJroaulsgu1sImGm8aHqY1WmyyLN aqIiFtpurPZGDHXRyOCS/bCIBcVVrapQMHleHMMd+vAY+hqfegpyf3ym65xPXQMEVU3g DXpmIE3t6fyXqX1NTUzCrb6/i1+7l4dze+bauCJSKRkwR/2vA61jXYwRZ+CFuAGR8wCz lBfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W5TGZaCI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id c13-20020aa7952d000000b006c4d5ca7fe7si13697204pfp.366.2023.11.29.03.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 03:41:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=W5TGZaCI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9965780B12F9; Wed, 29 Nov 2023 03:41:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231623AbjK2LlR (ORCPT + 99 others); Wed, 29 Nov 2023 06:41:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230219AbjK2LlQ (ORCPT ); Wed, 29 Nov 2023 06:41:16 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE484B5 for ; Wed, 29 Nov 2023 03:41:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701258083; x=1732794083; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=531Qy67F7OZYH+kBShiz0InOyHCpXmDL2JT+KJogS2E=; b=W5TGZaCI0sXXImG7b3B1izJPngDcCFI9wDIq6h9mGJrRKisr2iZW9u+M L00bw/LrA1yeyGyU9uNCu/+5zRvsCIHGQXeD3vgfXZndR+NpDLb0wL7bY 73Gj6F+bn5jt/Cos3rowxDNM7oEJOXOvw4Ua0zDxucHmmvCWnOOtpr/ND gvssBnEV/xx2OXklQoxzgXiitUtGo+Rq95Ahw5ZhNXjgd5Moeh0w950kg bOBbr25fxRhoJkwh4o0fs3iTAGtQz7QqqHeSS7uX3hR0w3FcGPh3VLqaE +MVGNviBrda/RMnCl0Su1nxjPOX4MD3Wuh5snMVgrzHGfOPAbjqpG3tN+ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="6414713" X-IronPort-AV: E=Sophos;i="6.04,235,1695711600"; d="scan'208";a="6414713" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 03:41:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10908"; a="839385780" X-IronPort-AV: E=Sophos;i="6.04,235,1695711600"; d="scan'208";a="839385780" Received: from ksandowi-mobl1.ger.corp.intel.com (HELO fdefranc-mobl3.localnet) ([10.213.31.19]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 03:41:16 -0800 From: "Fabio M. De Francesco" To: Chris Li Cc: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ira Weiny , Nhat Pham , Matthew Wilcox Subject: Re: [PATCH] mm/zswap: Replace kmap_atomic() with kmap_local_page() Date: Wed, 29 Nov 2023 12:41:13 +0100 Message-ID: <2166103.irdbgypaU6@fdefranc-mobl3> Organization: intel In-Reply-To: References: <20231127160058.586446-1-fabio.maria.de.francesco@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 29 Nov 2023 03:41:34 -0800 (PST) Hi Chris, On Monday, 27 November 2023 21:16:56 CET Chris Li wrote: > Hi Fabio, >=20 > On Mon, Nov 27, 2023 at 8:01=E2=80=AFAM Fabio M. De Francesco >=20 > wrote: > > kmap_atomic() has been deprecated in favor of kmap_local_page(). > >=20 > > Therefore, replace kmap_atomic() with kmap_local_page() in > > zswap.c. > >=20 > > kmap_atomic() is implemented like a kmap_local_page() which also > > disables page-faults and preemption (the latter only in !PREEMPT_RT > > kernels).=20 Please read again the sentence above. > > 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). > >=20 > > 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. >=20 > 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. >=20 > if (IS_ENABLED(CONFIG_PREEMPT_RT)) > migrate_disable(); > else > preempt_disable(); >=20 > pagefault_disable(); >=20 This is what I tried to explain with that sentence. I think you overlooked = it=20 :) BTW, please have a look at the Highmem documentation. It has initially been= =20 written by Peter Z. and I reworked and largely extended it authoring the=20 patches with my gmail address (6 - 7 different patches, if I remember=20 correctly). You will find there everything you may want to know about these API and how= to=20 do conversions from the older to the newer. Thanks for acking this :) > 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. Here, Matthew chimed in to clarify. Thanks Matthew. =20 > I am tempted to Ack on it. Let me sleep on it a before more. BTW, > thanks for the patch. >=20 > Chris