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 11BDAC07D5A for ; Mon, 27 Nov 2023 20:17:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 870EB6B02D2; Mon, 27 Nov 2023 15:17:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 820386B02DB; Mon, 27 Nov 2023 15:17:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E7CF6B02E5; Mon, 27 Nov 2023 15:17:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 59C2C6B02D2 for ; Mon, 27 Nov 2023 15:17:17 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 22A6B1207C0 for ; Mon, 27 Nov 2023 20:17:17 +0000 (UTC) X-FDA: 81504843714.18.79B2240 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf29.hostedemail.com (Postfix) with ESMTP id 82D6512001E for ; Mon, 27 Nov 2023 20:17:14 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=muUw2Pon; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701116235; 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=3JKQQUdan0FkT20cWx371kSeAeDQCY7C4IXeMtF58vc=; b=AqhOIPtku53YhR9oJthXx32QX8GzlnjEZHjEVdTe0FI/pn/5dSfRWi8/IxePTF0OuxUn/k GNHqyHeigJWvyyv5PRyOD6HKg/3jKg3RLpnLTT/88NzmYVI5epoPEqewYJxw4ia4MZzdCY rYxP5Och7RJQ/DASuCRzgskHU7DhohA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=muUw2Pon; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of chrisl@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=chrisl@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701116235; a=rsa-sha256; cv=none; b=tyOZOmUHyWtNznRnsH0MR+bb25tzxb35RDyqo+BssCxR83gdMNUSHe/btPTbIqOnIrDNTV C/7OnVnL/m8NzGH3+pLeSmzy544CX+GkfeE1Ii82wIen6xbV/gbIuGOgUvdS97YsR0JrSL sQWyWGHQCnXp4U08lkHCWPgXYkGgcxU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C2FB6CE1695 for ; Mon, 27 Nov 2023 20:17:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B642FC433CD 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-f181.google.com with SMTP id d9443c01a7336-1cfc1512df1so12857545ad.2 for ; Mon, 27 Nov 2023 12:17:08 -0800 (PST) X-Gm-Message-State: AOJu0YxBDpLg0bvaNRI+kRbtO++j+wVa7S8aLA8HVrqbRUN+mRBYepHj QT8WfXsMncY/GQoP7OqO/VmDZjhqqO3pPMHM+E0PiQ== X-Google-Smtp-Source: AGHT+IFHEnC7JReexqTgI2LSFW0v0eUVq4Y8pUZBBp92qbERuBc2GTKbwJNgS0fEesn5PN6e9hZM0ZWnCUsgmAuJ5u0= 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-Rspamd-Queue-Id: 82D6512001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: yiuod73m11x58uzg49cu9d77pntwueh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+t+M3LimY3BazUn9HRmWsAwvQSkAD4PoMMm5se258zlMto0RDPVmH5u/bQu5FOXIMbSOMsQsAQ30ZrGWmqrBHArpw533Rxp87T+LleiuKl9twadoFpMJIKeCfN0YJi2N1qCdu2+hZQozbW08Dx92SOMQJNZPCbBcqXGrgY2TugJMLBBLDUFFyC5EIaWuEoUkEByVcq8yw4V07E6ScMPux3KUJNvSHFP5x3U0K 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: 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