Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2256350rdb; Mon, 20 Nov 2023 06:28:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IHaeD5NbMEGOfgJsvU8SMxfIL2fJZaMdBvcj2QXOc1y23TxdPQz25EPMdq9H9+qeep5XEpS X-Received: by 2002:a17:90a:62c2:b0:280:fcba:bedd with SMTP id k2-20020a17090a62c200b00280fcbabeddmr4581608pjs.48.1700490537038; Mon, 20 Nov 2023 06:28:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700490537; cv=none; d=google.com; s=arc-20160816; b=qk/hLfGtlhujV7fihqYeUydB6TtR7NNrK6FpolSYHOH8yQv8KuCKek5AywrpwRsnrL Xcb1iixq+gvEClPwu7hf7IUTP1I2U7pTNTFnqsTVbnPgMSajMNagY5mxYWfn5DcFT7ze KspbDKYK6ZjE4WBFYx7K6QIPkdxgJrAX34f9qrFPqF7oqpFN3WYKdeII6z87jietjQm9 iBw3PmwIUYmGr4mV3ApR0w75+6R1FXnziUPLpV/314Ww8VKwEWlfeFBZwmXCclqO+ebU AVr52otrvD6q3bRtIBe36Tp4SmTaFhMTNNa+qLkf7cC1kfQgif8ErrBoZXVcUVeLACem UmMw== 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:dkim-signature; bh=g8SfughDL+yX2k7623D64oHQ3Oew/7Ftmso+UKuqnjA=; fh=XH3pxpKr7AUB4GM0Y3GdAQEzWmNMu4SdIEH1hms+9D0=; b=JJKThTLBMnVs10BaGZh4GpFef6sRw8IhP52U4cNsAaR1bOPxJXAV8InhxneZkEAVR2 Uvb1b+6DFRkzylJ1X6x0AyA1EF1mQ/QK9O6aQaWD0OmwvK31Pk4xT+B8wva6mhrgukHH liiuezfhgkNx+M4R+8cAu6XuY176lZXzfk4rsy3x0QkF3+Xtd8dgx01lmS/MOVr4wKZq xHA4w06k4c+SeLddt8G/BOA5AYpBltNwv96UDBG5z60bNPALUebD7bI9DnRchQxMqEay U5MEaV8J+ktMdHU7vqIw7vjjbXqmvPE0dQrcEPQ1s2bpxuufczQXHsKUgF/aLYDhsq4E eWJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NpEmC0Bp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h23-20020a17090adb9700b00283bc49ad11si5619685pjv.183.2023.11.20.06.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 06:28:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NpEmC0Bp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 82A778039F75; Mon, 20 Nov 2023 06:28:54 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233522AbjKTO2s (ORCPT + 99 others); Mon, 20 Nov 2023 09:28:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233487AbjKTO2r (ORCPT ); Mon, 20 Nov 2023 09:28:47 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C95EAA0 for ; Mon, 20 Nov 2023 06:28:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1700490523; x=1732026523; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=wXfYH9PEJHi5SE6jMxUu9uOPBnqBdEjEY0c0DJLAYZY=; b=NpEmC0BpHwAGvVNTwP2NVDIotU9nTHdQUxMUZ+QEaV73LOVL8OYomuHS DTJXKiaMR12Rk9JjevjZYtQo+eqtjObHGpnThnIh5HAA6AOiw8Om7KVo3 3cFhe2fbxLTO3L0/lM35ZmmEjLydY052gkNfPo7i2JtkQSKMpkPKtjkw8 AOO+KFQSwxTiC99pEeSg9C5Ygyyoh3nkBS3HMjgT3YKtUu3yfY+dtvEnx ncm5VXE9xGU1ORi1qNZxHDSPiXMGRKRHRPwEOqGctC6EuT3KssCwASEmf oFocns88ZPxJvnN5dHpUejInjXso7fRwkIsxoBzKP9MStsbnhOd0CI7Q2 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="390485710" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="390485710" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 06:28:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10900"; a="1097758447" X-IronPort-AV: E=Sophos;i="6.04,214,1695711600"; d="scan'208";a="1097758447" Received: from fdefranc-mobl3.ger.corp.intel.com (HELO fdefranc-mobl3.Hitronhub.home) ([10.213.12.244]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Nov 2023 06:28:41 -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/page_poison: Replace kmap_atomic() with kmap_local_page() Date: Mon, 20 Nov 2023 15:28:23 +0100 Message-ID: <20231120142836.7219-1-fabio.maria.de.francesco@linux.intel.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 06:28:54 -0800 (PST) kmap_atomic() has been deprecated in favor of kmap_local_page(). Therefore, replace kmap_atomic() with kmap_local_page(). 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. The code blocks between the mappings and un-mappings do not rely on the above-mentioned side effects of kmap_atomic(), so that mere replacements of the old API with the new one is all that they require (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/page_poison.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mm/page_poison.c b/mm/page_poison.c index b4f456437b7e..3e9037363cf9 100644 --- a/mm/page_poison.c +++ b/mm/page_poison.c @@ -21,13 +21,13 @@ early_param("page_poison", early_page_poison_param); static void poison_page(struct page *page) { - void *addr = kmap_atomic(page); + void *addr = kmap_local_page(page); /* KASAN still think the page is in-use, so skip it. */ kasan_disable_current(); memset(kasan_reset_tag(addr), PAGE_POISON, PAGE_SIZE); kasan_enable_current(); - kunmap_atomic(addr); + kunmap_local(addr); } void __kernel_poison_pages(struct page *page, int n) @@ -77,7 +77,7 @@ static void unpoison_page(struct page *page) { void *addr; - addr = kmap_atomic(page); + addr = kmap_local_page(page); kasan_disable_current(); /* * Page poisoning when enabled poisons each and every page @@ -86,7 +86,7 @@ static void unpoison_page(struct page *page) */ check_poison_mem(page, kasan_reset_tag(addr), PAGE_SIZE); kasan_enable_current(); - kunmap_atomic(addr); + kunmap_local(addr); } void __kernel_unpoison_pages(struct page *page, int n) -- 2.42.0