Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3365647rdh; Mon, 27 Nov 2023 12:17:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNE0hnl+4GW5YwLuUa27i2MmpRS/nsaqljPiIpVBWYuUlkfE9DcDY0ZLawRIIoOjxokhIs X-Received: by 2002:a05:6a21:789a:b0:18c:3260:e20f with SMTP id bf26-20020a056a21789a00b0018c3260e20fmr9166426pzc.33.1701116238981; Mon, 27 Nov 2023 12:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701116238; cv=none; d=google.com; s=arc-20160816; b=A08Zw5RWGwUcDehBGISw06yPdGGl04fNjbr7BQeV+jRZQ2FhEDLzrGw3ieoVtOJyVc ZPMXdjfVgjhjcyazsbftyAf/eWZOR/EwfHGU0ZH9sMR3WGjo2KXTZ3LN+vsuK6nonAOP x3QQXzuMH48JcmPnnkieRJ8VaW4ujzJydBVpB4XAwZTMeICQCkZCjSwVT2SDqS1oa6dS GPsma+eBhL7aMZusVta/ASnvIoaRkrKetUdGeC/WtGyIA1ProwIvUtzcETlWHl5Dc9pm 0zSI5IhqJ2gGEG/ByxIMm+4N6dQaLHj4uMe/I89RHuBbpvFo/fyzJoLYNFGqX+rhZfHx ojeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=3JKQQUdan0FkT20cWx371kSeAeDQCY7C4IXeMtF58vc=; fh=WWa38wgVBTDa0lgfjVVVcHMNH1f46fi1lNjfrCsGTEc=; b=VsSJyr38dwhMiI70JMXCXbrm+Rc/plssAH0Nyx/X0nLWFazColGwywHyPNiY729KH4 D7AjxEG/F1zLEfCWu0XesXGc2E3OgLf3O8X5vi2Rsu+sGIU/ur4F4mfEpwTJUMgKVJKi JyEfoLBKSLmMAuMH9MJ34174/oO0b5c5D/udfygvjSjkMSpJXPR9vm06l0kLDkn8QzOR GORX17CaR7jy4AntoGFELhX1NBgtciSuh0U0/XOifTqk3kAULDSRy0mXGu+eT4JL/KLr 9r2gb2ieVvBMKW3UI05VX64SfYjagDqILD+6RL6cuH7jYCu5yf5/8uycpOuxmHA1l7Cx /Gfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=muUw2Pon; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id z9-20020a056a00240900b00690c23d353asi10654847pfh.217.2023.11.27.12.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 12:17:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=muUw2Pon; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B39A580EFC4B; Mon, 27 Nov 2023 12:17:16 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231818AbjK0URD (ORCPT + 99 others); Mon, 27 Nov 2023 15:17:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229527AbjK0URC (ORCPT ); Mon, 27 Nov 2023 15:17:02 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19EAA1B6 for ; Mon, 27 Nov 2023 12:17:09 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AADBFC433CC for ; Mon, 27 Nov 2023 20:17:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701116228; bh=iFIXHwvfTSTEDZaoApsKmxK/L88uaLZE4LGuvxU3ZOc=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=muUw2Pon+VtCXUdO83+eYrfdpX3kRweY/McLQhNKLS/2FLHuA1zmb7gRxJN35dVlu 5nqFXFf1lv+FLOu7Mw20tRFQH47UV/NjnoYb6RZSU3rJjkwbdlwsFbbBzUThFTn3Mo KApySerna9K4S39NFiq0368e1GlhaSal0zwoAdZ30I7/ezf3lQmD7wTXzqU8n23Pb0 gC+jU2t6J+8JHl05Ta3vaFyp6oH9q8DA4aapdjmeyK6XLM2c0OdcCTxw25OpRzTHxK 3ychkGV82EWjhXzJ5tVIj/eprj3+d+ltatHw7btRSjbY64olVh8F0b5RPsAnyVVF/7 QStv6AO3f5NcA== Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1cfc2d03b3aso12218165ad.1 for ; Mon, 27 Nov 2023 12:17:08 -0800 (PST) X-Gm-Message-State: AOJu0Yycbr9/QhiYwg/SlSuZSnD/z3ScKZ8z2HEkmm78e0h59lZK7yi3 VUk4F2H6GdBan18dDZqpqgW3yxE7VGnRVZOZy2vpyw== X-Received: by 2002:a17:90b:4b0e:b0:285:b940:b51d with SMTP id lx14-20020a17090b4b0e00b00285b940b51dmr5274686pjb.20.1701116228069; Mon, 27 Nov 2023 12:17:08 -0800 (PST) MIME-Version: 1.0 References: <20231127160058.586446-1-fabio.maria.de.francesco@linux.intel.com> In-Reply-To: <20231127160058.586446-1-fabio.maria.de.francesco@linux.intel.com> From: Chris Li Date: Mon, 27 Nov 2023 12:16:56 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm/zswap: Replace kmap_atomic() with kmap_local_page() To: "Fabio M. De Francesco" Cc: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Ira Weiny , Nhat Pham Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 morse.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 (morse.vger.email [0.0.0.0]); Mon, 27 Nov 2023 12:17:16 -0800 (PST) Hi Fabio, On Mon, Nov 27, 2023 at 8:01=E2=80=AFAM 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. I am tempted to Ack on it. Let me sleep on it a before more. BTW, thanks for the patch. Chris