From patchwork Mon Nov 20 14:15:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fabio M. De Francesco" X-Patchwork-Id: 13461388 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 8B0C6C2BB3F for ; Mon, 20 Nov 2023 14:16:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F0F96B02D4; Mon, 20 Nov 2023 09:16:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A21B6B035F; Mon, 20 Nov 2023 09:16:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED32C6B0440; Mon, 20 Nov 2023 09:16:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DE0356B02D4 for ; Mon, 20 Nov 2023 09:16:17 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B0E43120608 for ; Mon, 20 Nov 2023 14:16:17 +0000 (UTC) X-FDA: 81478532394.03.DA58443 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.100]) by imf08.hostedemail.com (Postfix) with ESMTP id 4BE8B160023 for ; Mon, 20 Nov 2023 14:16:13 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (imf08.hostedemail.com: 134.134.136.100 is neither permitted nor denied by domain of fmdefrancesco@gmail.com) smtp.mailfrom=fmdefrancesco@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700489773; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references; bh=UIc9lXGBkbRCx4/Ifx9Uj9cmtU955hA87zMW/YBUQ/M=; b=L5svQKzlfo4fgsOkqUbb7WpMFgfZfJ412FG8qzV/GAorT8ohD49/f+1lG0Qwo/llacEWYC cB7BuOSlC/4Pxck94APp34iKMutK0PC9U5awcLRgUMG1SHOSLaazoakLlb3JljH8bmyUxR dJnjN4JNr4glYTmwNtuJXrac0htSpIc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (imf08.hostedemail.com: 134.134.136.100 is neither permitted nor denied by domain of fmdefrancesco@gmail.com) smtp.mailfrom=fmdefrancesco@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700489773; a=rsa-sha256; cv=none; b=U3N288ymCSWw5EXDT2AgRQC/yWiz1RXVmZLZc61z/rKyI1rIPlewpUvXLtw5mfX1yOGilj ErtD7XBgfh7yRSKYN1N752cO+/6SzwFuHQ/3qQUdlZ9Qrnns92ilgp/18knYXny4z2rO0F ui7LdQgpz8f3q3PAooLoD4tBESpF4ps= X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="458122913" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="458122913" 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" To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Fabio De Francesco , Ira Weiny , "Fabio M . De Francesco" 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 X-Rspamd-Queue-Id: 4BE8B160023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: pbm9k7cbaigmumma18z1nqt4g9gsjjoz X-HE-Tag: 1700489773-59565 X-HE-Meta: U2FsdGVkX1+hCbsXE6qhZFWe/WnxJMzltjxQdFN5yhlpbqLFWrCoE0lZ05j+MZy8AERC+FB5h08cc0Ffu2P8JVxkUXoB56pLpglUpVkRkeeClh2MB/e9Kcpcr4zbr8VCPMtMnNFyH8TUOkpIf3Hh0KGCMCUOcZFbMLr0LEkbH6F72iya0hAa+WvT0sPegQ3P0tp8iisEGY0gG14ZKslheEYBtfkxlfv/23ptp+qfj1LHEOBeheZwb1SWGPBOKrQeTHLH5KNZW/v4AKeM0uDVO1HeMaGNMO663TLV2QmNmioxX+YWALfa51oFb0kvzUQZmZbOSoB6QXQdbWER+7VTM+qcEn3C0HSzK7ZuD1FqfA+Q4S0DTdOEZbZfz8Ig8q17z7iP902EpXCJR7AlCMgo/7ZLbnZBf1d7lKMLe3LoJnfcUpIsS/wqY57CPp3pFpVEEY+pkD6SrpBbmExlylD9QyqSBZ13WmoWyU2Rz8Se/Bu9W7nb3ty//UJc4Srnm6PDcit1sj5jfsdnxp6vrB6i95zBIE6iEDeAlik4uWzFrfvql0WqdqRihFupbFGO1FHk3v9tJQZ/pZWteS/wllJxBeFcLhWZ7XNLM2dr0eZhNYwcgLZdQT31ddtwLOUYNXDW4ZLq2q+p5oAjzr27PKHa9NP6v0wBpcauLNqwoGA4v45uulIt9NdlvJ/thDeu4Obnl0TqfoHNQ/ns5S+vSAJn3n2sW+P6p89gKQyqXgcN4jHRpoiCEieJQ8WTQ6vwRUrnAbk1i8YkkRRd+N7FScp7LpUIE2emF4GMZewkTUVCEzXAxal7Nj1StmWcL6ps+Kx8U/4Pf7Vawx8q4oXskL96CTaneS/gXSdKwKs8ZUvdf8j8s/AQrCI3gcUXn4Oj1zkXhmxJhkB2vedsmC/x/ToL20U+pDzto2plE1CpAF6U8lso1Xg6DkdlnBTrncEp3l0nJ72IZVSjEhU1LIZmbF0 zpMN+Be8 G3WQopfKq5Nr5iGHojgUXkGME4QTcPlNS0pfWfRSW+ypXRvUhENqtsBg/T3Fy6aVh1ayUn2qcdb4ayyg/9ZiwgN44s8jHjLaXS9qCnkk3ByeCvyY4LzhoxkXoK+bq/eAoiVw3M2qXx/zVjwEDmxSc92xSdOH6uYov5F61Ipg2N3++m/TRhrFWVekv74LChxj62uI6qs6m+IPQJ5fruUxnlLKzNUBb+XQEct5cvNAIzufiI6ASaQPRs/gt/Cda8TtLJEVsTDcBFNi4u6Sg7W8VFgFMUQNHOVFEpRUcvRsjhZw8emGQByvIPKgg7IxUWZlrZ/Xk 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: From: Fabio De Francesco 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 Signed-off-by: Fabio M. De Francesco --- 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; }