Message ID | 20231120141554.6612-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 i16csp2231025vqn; Mon, 20 Nov 2023 06:17:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHgCWI6L9N57hRdThxihiZbpxWbXl3n6EVZ3TP5oEebun0WXCaHZVS4Pq+iv5xxEKWO7uro X-Received: by 2002:a05:6808:114b:b0:3ae:170f:a39b with SMTP id u11-20020a056808114b00b003ae170fa39bmr10581978oiu.17.1700489827344; Mon, 20 Nov 2023 06:17:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700489827; cv=none; d=google.com; s=arc-20160816; b=vQFmH5arPYYZgx4nIPxa6VAQ2/p0Ci+XbIMKc7VQzOrKpDJgX2hGu7vyzs/f+5w1BK JL8l4oUlgbvJmr0kzdICis7JDsB0LfdQA3xcDB4c/G7DhtMqqs6MZKfY3dUEk52EBZ2G 1sCVrQ1J8iEK/cYJj0HFP2kxZ4xmJ8EJ1nwoxWbGq2zI7iZNYdp2DNJWvReWrmzMhgCY NJuZOHm/dO8glJa4BBtfDnT4GpsVpJ+ix6PTtCSe9cLJXaFFVi5oN0mYC6fK9cgUm3Dq rtVPtZKhdH6KpI+3Czkv5VIB0FNlWxmjdTGuJH323+UIdK581MmZDOETmsPo8u3hhxj1 nUfA== 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=UIc9lXGBkbRCx4/Ifx9Uj9cmtU955hA87zMW/YBUQ/M=; fh=xRHD3LD2iAhVj/gkfIf4WA9pZcAS3OKT4G3sAObzdU0=; b=R5ZhT2AP2Fu4AZMMhpZvS//Z1mR4X9JJngViiY/NMO78qJWJle88ysBTrqsYXp+6ey ZshKNscmS5t26yTUciWoMvxQRZY5SKuxyiRHai8yjUfHUXqidAKP7NzGdcqks9eAO6Ot CK5rJEywev0BHsbJ0f4TLNNRZC3/OARKreTb6OnaXkuh4a1ohxz/oS9ScwSPI5V36MzV 2diqPa4+aIQ5gAXzCJMU1Q/FcHIepMIS9BRDveIOsj05N8zzcMW1gfRjdKPLndMpw8OO tIJY8Lc35bDu+ptatAcMi+z6udEVyIAS6HKYCu7RJYFD73BQ/MnUy5AClKFQf93loyo3 QZGw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bq20-20020a056a02045400b0059beadab759si9371193pgb.652.2023.11.20.06.17.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 06:17:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id EF22980505C8; Mon, 20 Nov 2023 06:16:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232259AbjKTOQQ (ORCPT <rfc822;heyuhang3455@gmail.com> + 27 others); Mon, 20 Nov 2023 09:16:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232135AbjKTOQO (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 20 Nov 2023 09:16:14 -0500 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23AE8A0 for <linux-kernel@vger.kernel.org>; Mon, 20 Nov 2023 06:16:11 -0800 (PST) X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="458122911" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="458122911" 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:16:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="759795431" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="759795431" 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:16:05 -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 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/util: Use kmap_local_page() in memcmp_pages() Date: Mon, 20 Nov 2023 15:15:27 +0100 Message-ID: <20231120141554.6612-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=0.5 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, FORGED_GMAIL_RCVD,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Mon, 20 Nov 2023 06:16:57 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783092820895201134 X-GMAIL-MSGID: 1783092820895201134 |
Series |
mm/util: Use kmap_local_page() in memcmp_pages()
|
|
Commit Message
Fabio M. De Francesco
Nov. 20, 2023, 2:15 p.m. UTC
From: Fabio 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 memcmp_pages(). 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 memcmp_pages(), the block of code between the mapping and un-mapping does not depend on the above-mentioned side effects of kmap_aatomic(), so that 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/util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/mm/util.c b/mm/util.c index 744b4d7e3fae..5a6a9802583b 100644 --- a/mm/util.c +++ b/mm/util.c @@ -1047,11 +1047,11 @@ int __weak memcmp_pages(struct page *page1, struct page *page2) char *addr1, *addr2; int ret; - addr1 = kmap_atomic(page1); - addr2 = kmap_atomic(page2); + addr1 = kmap_local_page(page1); + addr2 = kmap_local_page(page2); ret = memcmp(addr1, addr2, PAGE_SIZE); - kunmap_atomic(addr2); - kunmap_atomic(addr1); + kunmap_local(addr2); + kunmap_local(addr1); return ret; }