Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3175926rdh; Mon, 27 Nov 2023 08:01:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIFhrvIqu9WmSxNG+S96R/jKPYqr5scX9cc+gZHyPscjZbNdiTI5X5yv2B4eizr++0IZYX X-Received: by 2002:a81:ae26:0:b0:5ce:16cb:b709 with SMTP id m38-20020a81ae26000000b005ce16cbb709mr7365331ywh.25.1701100873243; Mon, 27 Nov 2023 08:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701100873; cv=none; d=google.com; s=arc-20160816; b=K3o+JuDASXFb9AxaxKhPxKs5JzbmAeuDb8VfleWj+r+xIaQRg5qYolWoJmJyC4g8BG usakFhctnEXv6S5NxNLMCDnNlYwAoPmoI6RXcH07CAEeWi/Xaw/BHnuFftBe+QEARxDZ +XzzsnG4tndNg/jyeknaocBP/wu/Bgv2tNuW6EMKR/IygzDZ7UoavBN+zYFJm4Wf+afO c18sAUlzsmWW/fkkLNgwXBGmAtxgpvLyOUcBgwGLRKFIQdkzZwa/U6E6l3YyZVmePUtn i1rck9ac0AIrFv85g4QQhbSUs/RO+NjO4pDdMJDwOM5KzJUw8QNNATopf56MlO3xsR0g GAvw== 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=3z/HhipTL8gIH6MpgtOBFieGOa/xU0CATrDv3uXEc/I=; fh=342k5xQd6NMXzVuZeE8Aice/zaM43j4HlZ8GnCekkZE=; b=fh7gozF5yrmnrztEregvLnkWUoK3VJNIm9MyKZqTK6nPTR9wVn14p6ZZTThM7SxKPb jj+WaALOue1hxUMifju9MPJUPQocpBg3sOjNs/DVxDr2nQb3VzDwxuxViR+k1ErJ0HJq PCXQTKw20hOVJn9C+C5spwtIZ4rcOwrFIaRqKgY+dBCHafQlnp65H7UWg0S6hTz/Olc0 NJkSnQZbeF/9ZU4eL2JII+J2Iye6OBbVVkN39xDbBNmKNJFEu6wLGGyii6bVDXZo8/vc uYz12P9JBJGPU53BqZQ1mP1tq5om2SP6uRGz+8jC6F0u2HF170KCoEPA/ZHcRMPV1EWx c/DA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SHJEez3d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id u80-20020a817953000000b005caef6b57ffsi5801600ywc.71.2023.11.27.08.01.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 08:01:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SHJEez3d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id CE015814554C; Mon, 27 Nov 2023 08:01:09 -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 S234270AbjK0QAr (ORCPT + 99 others); Mon, 27 Nov 2023 11:00:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234303AbjK0QAo (ORCPT ); Mon, 27 Nov 2023 11:00:44 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 466E3BC for ; Mon, 27 Nov 2023 08:00:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701100851; x=1732636851; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=c2cu0vMGg8Ol2YSa4yfd/4bw6RpgEUsUJKa+9vCAoF0=; b=SHJEez3dgl0oKTdlJvt/sfTxpkux513qVnFcLcTzXEUys8tAgfmwuOkd 82T4gwW+X8qWapY4MUoJ+vZuTiOu7BRbOfE1cbO8GZu79krQAjHwR3Ii6 Ex/uT3Eo+MYQrkbkC3Rvie7zPRfgq0AK5YGkiLtxJMPZLYEgdsoIhRJyK /tgkYavcXFtitx4YhC6OocCN62q6ilyuoiyP3Wicx35yEs+Vt+POgV++H F7IQ1xCM5C3gYJR9xH/lpZemMR+n2NeErU55Bgq+s7yi2qw3I2m2irLSW UqcUs34FHZiLbUgqPAIAhki3rDKHPElFInwhSQepoQfUsaU/O/2dhILZl Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="372901008" X-IronPort-AV: E=Sophos;i="6.04,231,1695711600"; d="scan'208";a="372901008" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 08:00:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="1015611212" X-IronPort-AV: E=Sophos;i="6.04,231,1695711600"; d="scan'208";a="1015611212" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.localnet) ([10.213.15.40]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 08:00:48 -0800 From: "Fabio M. De Francesco" To: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Ira Weiny Subject: Re: [PATCH 1007/1007] mm/zswap: Replace kmap_atomic() with kmap_local_page() Date: Mon, 27 Nov 2023 17:00:46 +0100 Message-ID: <4529535.LvFx2qVVIh@fdefranc-mobl3> Organization: intel In-Reply-To: <20231127154636.585898-1-fabio.maria.de.francesco@linux.intel.com> References: <20231127154636.585898-1-fabio.maria.de.francesco@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 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]); Mon, 27 Nov 2023 08:01:10 -0800 (PST) Please discard this patch for a mistake in the subject. Fabio On Monday, 27 November 2023 16:46:22 CET 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. > > In mm/zswap.c, the blocks of code between the mappings and un-mappings > do not depend on the above-mentioned side effects of kmap_aatomic(), so > that the mere replacements of the old API with the new one is all that is > required (i.e., there is no need to explicitly call pagefault_disable() > and/or preempt_disable()). > > Cc: Ira Weiny > Signed-off-by: Fabio M. De Francesco > --- > mm/zswap.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/mm/zswap.c b/mm/zswap.c > index 74411dfdad92..699c6ee11222 100644 > --- a/mm/zswap.c > +++ b/mm/zswap.c > @@ -1267,16 +1267,16 @@ bool zswap_store(struct folio *folio) > } > > if (zswap_same_filled_pages_enabled) { > - src = kmap_atomic(page); > + src = kmap_local_page(page); > if (zswap_is_page_same_filled(src, &value)) { > - kunmap_atomic(src); > + kunmap_local(src); > entry->swpentry = swp_entry(type, offset); > entry->length = 0; > entry->value = value; > atomic_inc(&zswap_same_filled_pages); > goto insert_entry; > } > - kunmap_atomic(src); > + kunmap_local(src); > } > > if (!zswap_non_same_filled_pages_enabled) > @@ -1422,9 +1422,9 @@ bool zswap_load(struct folio *folio) > spin_unlock(&tree->lock); > > if (!entry->length) { > - dst = kmap_atomic(page); > + dst = kmap_local_page(page); > zswap_fill_page(dst, entry->value); > - kunmap_atomic(dst); > + kunmap_local(dst); > ret = true; > goto stats; > }