Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp4803967rdh; Wed, 29 Nov 2023 11:04:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIghuuvoSPLWHmHD4zyQAtMTzAEqHwIubR+RclVZa4MEu4It94QDsyrY2JSYkldB/H3unx X-Received: by 2002:a05:6808:1824:b0:3b8:5bfe:7e36 with SMTP id bh36-20020a056808182400b003b85bfe7e36mr21699255oib.43.1701284673027; Wed, 29 Nov 2023 11:04:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701284672; cv=none; d=google.com; s=arc-20160816; b=GSodJuyI5V8xG/EmxMArXFouc13WJZb0SyXHmq3c+dNch7j/UlCmxDUa9Z/0/2LMSU TGeooO2yo+9oibFkMn+BAdCgvbqZTJPRGVNn5CyYumAMRIoNHutnbsPcM8qczYaq+K+o kWmGRkZvV2/hitKzjWd7cT16yBZPC6gPo6U7ZDdOKa9OGyQXs8XGuWABOIjWEFsMBWeR hYIBlCTQnX6zDUSn7qVY0BA7MXT1mQC0LLlZd47cg2k9yBxw3awSObxp7xdkpzHIFC52 Wp/A54sKJgenw5mppMQFwfnckyBjr2xq4gDF4NPR28AnJjkEgX6f/gTjQl29xHAr7CqX 8doQ== 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; bh=WKifcaBMoY0uxoxekaEoGeopOPK1oliQ4qG/FzFfpg8=; fh=Nyb0iJ2DgH160SUjQl8YuRNkQ6W185o0kKTFCx5lu+A=; b=isM7yFUjuN5j7E3KT8en1IcMuwhPM1iIhc0TcEYY8Td0t1dQy/v54nlaPYCuLHvoH5 SLKVlvbqywENQvjgB3HajZnd9GRq1m8jdhk4K0bdF4o7GDX+57j65JRpTPilQtUV1i1d e2GZPCKhc50VmD6CjVuY0bxpT8k47GKCWfMfRC8eUkf4ln/4OJE8vxX2hh1yKEji1kGl seyh7MQ6Szq1SzZgBNWKZMCXDPvFBU/Oj/cM7DgyhebauwXDShOjPuL4qrHR1PlSAFoX wXrqpVNPG4kOz4sokDDNNPjC4ALl6j/I58tGznSeWDmq0qxJxfAnDlhia5O+IfcJ4hsV Jtlg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id d11-20020a63d64b000000b005c200b11b96si14721361pgj.190.2023.11.29.11.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 11:04:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id A334180284C3; Wed, 29 Nov 2023 11:04:30 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233543AbjK2TEC convert rfc822-to-8bit (ORCPT + 99 others); Wed, 29 Nov 2023 14:04:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233130AbjK2TEB (ORCPT ); Wed, 29 Nov 2023 14:04:01 -0500 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E67EF4 for ; Wed, 29 Nov 2023 11:04:07 -0800 (PST) Received: by mail-lj1-f175.google.com with SMTP id 38308e7fff4ca-2c9c39b7923so2048551fa.0 for ; Wed, 29 Nov 2023 11:04:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701284645; x=1701889445; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=b6e/iPHotyGLxRcZFDNDxbxKjcI1VVeudET2V0CiNRw=; b=nWvOINyxBDPWWPGPzf5xuL9JLLtU/DYVvXlD547xbdforIlglbix1pLxGYLk+lTOrU D1r51Ks8n1chNDopVxr5WlSpphKeGT+/6U6T8bWUQA2KxzHZjOzQfzeBo+ACVl8Jytht 1PhIZmRJGvJ9mkt5A+zu21WFMSfChHxjO1rH9xLIL4R0WwDXXjqDzdu1btTo4y/P4JYg CdbiUSdEQmKfeEs7XOwsu8Gh6DDa31V2y50nzbZGp3xnszhBVg+1EsWQi9/5u15MbjcL BxuKVUumPExm4xeCqrG3SIkH8qdFymGcu3MJhd6KaBXboavz0sIgNklqRhoUlqe6XlfE nU3w== X-Gm-Message-State: AOJu0Yz5dVFf8xpGKHXMhv3So9omAE8lWxgzU4NKyST6uQC5PGwdnGDv qdnNdfwnJeyg9eWMoa9EeGOEt0xQbQ8dW8fxhA== X-Received: by 2002:a2e:7203:0:b0:2c9:bf97:81d1 with SMTP id n3-20020a2e7203000000b002c9bf9781d1mr1818071ljc.27.1701284645142; Wed, 29 Nov 2023 11:04:05 -0800 (PST) MIME-Version: 1.0 References: <20231127160058.586446-1-fabio.maria.de.francesco@linux.intel.com> <2166103.irdbgypaU6@fdefranc-mobl3> In-Reply-To: <2166103.irdbgypaU6@fdefranc-mobl3> From: Christopher Li Date: Wed, 29 Nov 2023 11:03:52 -0800 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 , Matthew Wilcox Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=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 pete.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 (pete.vger.email [0.0.0.0]); Wed, 29 Nov 2023 11:04:30 -0800 (PST) Hi Fabio, On Wed, Nov 29, 2023 at 3:41 AM Fabio M. De Francesco wrote: > > > 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(); > > > > This is what I tried to explain with that sentence. I think you overlooked it > :) I did read your description. It is not that I don't trust your description. I want to see how the code does what you describe at the source code level. In this case the related code is fairly easy to isolate. > > BTW, please have a look at the Highmem documentation. It has initially been > written by Peter Z. and I reworked and largely extended it authoring the > patches with my gmail address (6 - 7 different patches, if I remember > correctly). > > You will find there everything you may want to know about these API and how to > do conversions from the older to the newer. Will do, thanks for the pointer. Chris