From patchwork Mon Nov 20 14:24:05 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: 13461410 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 46179C2BB3F for ; Mon, 20 Nov 2023 14:24:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C43AA6B0453; Mon, 20 Nov 2023 09:24:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BF3946B0459; Mon, 20 Nov 2023 09:24:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AE2196B045B; Mon, 20 Nov 2023 09:24:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9BC766B0453 for ; Mon, 20 Nov 2023 09:24:43 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5ED9F1408E9 for ; Mon, 20 Nov 2023 14:24:42 +0000 (UTC) X-FDA: 81478553604.13.8454EC5 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by imf02.hostedemail.com (Postfix) with ESMTP id BD0A180023 for ; Mon, 20 Nov 2023 14:24:27 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=none; spf=softfail (imf02.hostedemail.com: 192.55.52.151 is neither permitted nor denied by domain of fmdefrancesco@gmail.com) smtp.mailfrom=fmdefrancesco@gmail.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700490268; 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=XZd2/pAhx0u7RpLxfG/R0LaDKy4Tnv3LB64NX7QSQhk=; b=fbsSfjkNTxIhsywA1LqMbvrmNJ1qJ/W+Gfw2QXr0hloNxnv49w1ThzZ3+egrv6nRQkJ3Z9 VIS+aZu0M8OL+1flswUcOI6jSIaMoIKzm7VCZV6jzk/zz1CKPo0b4kiJfIFCdnj/x2bYiC pht+5BeblFscr2Sr7ifuWE4wuQthhiA= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=none; spf=softfail (imf02.hostedemail.com: 192.55.52.151 is neither permitted nor denied by domain of fmdefrancesco@gmail.com) smtp.mailfrom=fmdefrancesco@gmail.com; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700490268; a=rsa-sha256; cv=none; b=zzvYN0YtDvV4M6s5R8Btz4yziwo2Nsn/LBv2TBv+rYct7VN1BwFsmUP5j/7pOG0c/wokMf hAFw+vBp6Y1REeWSICBjwJwI79BzNLf1WbXoGPj0oJs1kJxBVoib2CXw/aBPa+JGebv/l7 X+0hSQ5THItzTw4tUh1bxiySBtqP2Yk= X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="371801208" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="371801208" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 06:24:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="742740746" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="742740746" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.Hitronhub.home) ([10.213.12.244]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 06:24:23 -0800 From: "Fabio M. De Francesco" To: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: "Fabio M. De Francesco" , Ira Weiny Subject: [PATCH] mm/memory: Use kmap_local_page() in __wp_page_copy_user() Date: Mon, 20 Nov 2023 15:24:05 +0100 Message-ID: <20231120142418.6977-1-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: BD0A180023 X-Rspam-User: X-Stat-Signature: yjtcm6zp9mb4y89xtw34d1y5zqwp8yrh X-Rspamd-Server: rspam01 X-HE-Tag: 1700490267-762930 X-HE-Meta: U2FsdGVkX1/Ow7IpUatvpn4VqGp3dq5LoD7IWFJ28pq3N9myd8ZoWUiMlTwrF8gMcsGMQWg6dONA7eSQxF00yqK2yMJN8Mk+75EtQZD4G7G7SnK6ID7pu2zTVMOZ5vnUbvObnwk+jGKsSBOZH3d72DFMhsnkJ1FatBzI738nxcGuTESnAFqz98Ma/36FL1D6sVTt8x22eyDfY/+A4tEx1Q7IhGbgGqwXBt2qB7NfF3A8lJjSCo1MwymvmFYdQa2JqdPhkB7WoPO19HVoosIl2Q3zojsUuvv4n1TRCXjst5ANNnBCylpoYzgD2MYzBo+Xp88XMIVmUGUAYicOfuxPtRPUlIBj6JZ3X5ZCsMvT1d5m6y9zO9EhJW4XaQgdfZzWy41oK0/OH83Np+q4Ym/J6EN9ECMePxI2agUowOJ2GuAYb03qjfNC3t6AHuHdnqBGdLCJ0QnkBNNmWBL79WvznWz6H9dpip3rEl6KkJQJ0Ec0+r0wBEcQ1wrBLIvdt2xlJ0ynXNommF/D1ZCF5VHZxoLtpXAKQZWkJb1IWa37UDGN4wVq3/jKPru7Kbn6ov7IhikUiCBytkMpzW91dilyewybOEHw4eeuYm3PPwZaO0X99bYweMIOLlSGl4xXgAx3l6ouMBpcZ6A5QBPpAENfMpQlefvW3Vpnl0HqCMFtfV/asboaZiVOID7V9XLUQmeNcoZuI9WXajI7eJa/sJ2MqHPPLHdFA4QDPvt6WhA5jp9il33aiQgSZ4ICjExjYB4LRj6fkTyGPSfuKd+f7kajhxtcntlE85u+jLBRTyUsmmN/k30jtDKMENzY12I0jyauiupdUvPYl/AJ6Ln3dee7LEo71zypSGz13xru3ZuEiwHXZHjOYZKeNaGvz7SYa8RgKQfgPmQ+iZgcJnFBP5Z5I4Gmvn9P+0o3fgaqURHDlsrZZj5cY86ykWSDwE4F+XxqzKlWwQvA87jka53O2IC Zag/waL8 3cNxxVMrUUt3YToN8ghcm5Pb/Vif+InA5RUm0nmqOyYqUrRCF9Vz1v2xagI0z7iWUUMq8KB7dytqX3Cy6CUIifZvwFD3ousJTFM8KI3Z+pgixHARRE7FJrfSpH196zsjxMsN69l1gGtTVcdwd9TwmNexKsxMosO5s3Bhw1kK5Xamudg5NzqgQ9gACWXfNM+umC+qeGgjEc747AMJeOvo6y6AC162/sQbKngo1rQWrEY3skLU1o2+4wZCBUWduL1e97N8M3LqDQg7Duy8Uog8bf0oWlHB515LA4/95CYaWwoP5/0e4tkCK2DI0an1z2/CEzXr9 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 M. De Francesco" kmap_atomic() has been deprecated in favor of kmap_local_{folio,page}. Therefore, replace kmap_atomic() with kmap_local_page in __wp_page_copy_user(). kmap_atomic() disables preemption in !PREEMPT_RT kernels and unconditionally disables also page-faults. My limited knowledge of the implementation of __wp_page_copy_user() makes me think that the latter side effect is still needed here, but kmap_local_page() is implemented not to disable page-faults. So, in addition to the conversion to local mapping, add explicit pagefault_disable() / pagefault_enable() between mapping and un-mapping. Cc: Ira Weiny Signed-off-by: Fabio M. De Francesco --- mm/memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 1f18ed4a5497..0ba63007c580 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2835,7 +2835,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src, * just copying from the original user address. If that * fails, we just zero-fill it. Live with it. */ - kaddr = kmap_atomic(dst); + kaddr = kmap_local_page(dst); + pagefault_disable(); uaddr = (void __user *)(addr & PAGE_MASK); /* @@ -2903,7 +2904,8 @@ static inline int __wp_page_copy_user(struct page *dst, struct page *src, pte_unlock: if (vmf->pte) pte_unmap_unlock(vmf->pte, vmf->ptl); - kunmap_atomic(kaddr); + pagefault_enable(); + kunmap_local(kaddr); flush_dcache_page(dst); return ret;