Message ID | 20231120141855.6761-1-fmdefrancesco@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9910:0:b0:403:3b70:6f57 with SMTP id i16csp2233639vqn; Mon, 20 Nov 2023 06:20:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFnZn1hL6ADarZn1Aw7HkjncjbKQ8D311EmxW2O9TAqCZ9YvxB6S1ox8Daj6P9E/Qrn4wPf X-Received: by 2002:a17:903:2448:b0:1cc:42ec:9b96 with SMTP id l8-20020a170903244800b001cc42ec9b96mr7246997pls.45.1700490040401; Mon, 20 Nov 2023 06:20:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700490040; cv=none; d=google.com; s=arc-20160816; b=gRMMqENDTF12SHpdtHwlpClKO95xf3w0nVIrDmK8gH6wtI8GHTEyPPt3DuvqyaNRKF +PI8gFMu9/oSzTozdXTPxxDpbXku4sgE5HL+UwE6mgZoqwBYYV4x53BxsqtQP+SIPeul K5+o82hKtylB7YZ9tFfN1LLh3SgRl7fFp7SztunVFRHuxd2VbxgV9Dzn/ID6ObGzehuf y5189Q4lCqXxUp3W8buoxmoLedIYbC81e73p3d/camT148pdHiDqMdisy+SoDfB6CcVq i6YHWbvq+O4TMBKDge/5SoH19XjkYLvCziAIN36J0rHAjuiaFi3zuUMHSd66zzk8MTHi Z4JA== 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 :message-id:date:subject:cc:to:from; bh=NLQEP6kXTo6ts2tnk0a++rjXWR+UaxTnOS6ZAUn3QUE=; fh=qDXlVLl7br5m5Sn+oYnwTx/CBlJrf1pIUlN2uc2ZUlU=; b=GWiEVx89SXTKsbMB3j5WZTO4tsYf6CJnZAj00g9e5ZNnUGZ/A55MRwrxwREToyjPZC 1H82C9k4ocxNmoAQm2wtDKxgMVz//rLfQUVlxg8Ww3J6Jd6CtrYEbfLNiifsAx9WHz/d QgRzCr2aKXdBbW6uGZ+Ae3rzfcTgsJ2Cs74O3EqsL31tvRZqV+KEHfEpDa9tUM3b0I8s dTO4AW9THpEcIm5CjZq/L5zf0xwCwn/nS+dkOUXD5Y2UcXhrcTbCait0pihT6rfMX4bg uJJcfyi9r7E0RjBIxKqUlnVJqNbs/gPedldj+uhHRu60KWq7QFguup7wcI96ozOHvzk7 WNAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id l2-20020a170903244200b001cf63d5130csi1478977pls.160.2023.11.20.06.20.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 06:20:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 5615A80D6E4D; Mon, 20 Nov 2023 06:19:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233106AbjKTOTH (ORCPT <rfc822;heyuhang3455@gmail.com> + 27 others); Mon, 20 Nov 2023 09:19:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232200AbjKTOTG (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 20 Nov 2023 09:19:06 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48B75A0 for <linux-kernel@vger.kernel.org>; Mon, 20 Nov 2023 06:19:03 -0800 (PST) X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="458123492" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="458123492" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 06:19:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="759795920" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="759795920" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.Hitronhub.home) ([10.213.12.244]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 06:19:00 -0800 From: "Fabio M. De Francesco" <fmdefrancesco@gmail.com> To: Andrew Morton <akpm@linux-foundation.org>, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" <fabio.maria.de.francesco@intel.com>, Ira Weiny <ira.weiny@intel.com>, "Fabio M . De Francesco" <fabio.maria.de.francesco@linux.intel.com> Subject: [PATCH] mm/ksm: Use kmap_local_page() in calc_checksum() Date: Mon, 20 Nov 2023 15:18:44 +0100 Message-ID: <20231120141855.6761-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_SOFTFAIL,SPOOFED_FREEMAIL, SPOOF_GMAIL_MID,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 20 Nov 2023 06:19:11 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783093045039259466 X-GMAIL-MSGID: 1783093045039259466 |
Series |
mm/ksm: Use kmap_local_page() in calc_checksum()
|
|
Commit Message
Fabio M. De Francesco
Nov. 20, 2023, 2:18 p.m. UTC
From: "Fabio M. De Francesco" <fabio.maria.de.francesco@intel.com> kmap_atomic() has been deprecated in favor of kmap_local_page(). Therefore, replace kmap_atomic() with kmap_local_page() in calc_checksum(). 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 calc_checksum(), the block of code between the mapping and un-mapping does not depend on the above-mentioned side effects of kmap_aatomic(), so that a 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 <ira.weiny@intel.com> Signed-off-by: Fabio M. De Francesco <fabio.maria.de.francesco@linux.intel.com> --- mm/ksm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/ksm.c b/mm/ksm.c index 6a831009b4cb..5d60d5385de6 100644 --- a/mm/ksm.c +++ b/mm/ksm.c @@ -1099,9 +1099,9 @@ static int unmerge_and_remove_all_rmap_items(void) static u32 calc_checksum(struct page *page) { u32 checksum; - void *addr = kmap_atomic(page); + void *addr = kmap_local_page(page); checksum = xxhash(addr, PAGE_SIZE, 0); - kunmap_atomic(addr); + kunmap_local(addr); return checksum; }