From patchwork Tue Mar 22 21:39:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12789058 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 5EA78C433FE for ; Tue, 22 Mar 2022 21:39:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8F776B0089; Tue, 22 Mar 2022 17:39:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E15C26B008A; Tue, 22 Mar 2022 17:39:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB7C56B008C; Tue, 22 Mar 2022 17:39:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0203.hostedemail.com [216.40.44.203]) by kanga.kvack.org (Postfix) with ESMTP id BD5CC6B0089 for ; Tue, 22 Mar 2022 17:39:27 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 873031822F66F for ; Tue, 22 Mar 2022 21:39:27 +0000 (UTC) X-FDA: 79273338774.26.273B196 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf19.hostedemail.com (Postfix) with ESMTP id 2A4F41A0030 for ; Tue, 22 Mar 2022 21:39:27 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A2F9D6174F; Tue, 22 Mar 2022 21:39:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67512C340EE; Tue, 22 Mar 2022 21:39:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647985166; bh=xC2cZqPNFzyjybznmsAmzD/7GWHjCHD+MjNDI4Fd8cE=; h=Date:To:From:In-Reply-To:Subject:From; b=g9SB1ZKKafzmjd4WG2tsKL9guNHYWxfWhn6RLlRFzmYeJ5+jnqZJENe/6LnbCYhLE 1Ruzkr9m3mLSFR3PXIt736hGVGUcjQEeVQwVZA3jyCANUhqSQJNfMLfzcoQApSbE2V sW9OvG6EYdVAluL4N4jckJfiqzZi2cJ80yVwNQmA= Date: Tue, 22 Mar 2022 14:39:25 -0700 To: songmuchun@bytedance.com,linmiaohe@huawei.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220322143803.04a5e59a07e48284f196a2f9@linux-foundation.org> Subject: [patch 018/227] mm/memremap: avoid calling kasan_remove_zero_shadow() for device private memory Message-Id: <20220322213926.67512C340EE@smtp.kernel.org> X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=g9SB1ZKK; spf=pass (imf19.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2A4F41A0030 X-Stat-Signature: o7jky8u7awnpfwt91tcopcaotmugf4of X-HE-Tag: 1647985167-406077 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: From: Miaohe Lin Subject: mm/memremap: avoid calling kasan_remove_zero_shadow() for device private memory For device private memory, we do not create a linear mapping for the memory because the device memory is un-accessible. Thus we do not add kasan zero shadow for it. So it's unnecessary to do kasan_remove_zero_shadow() for it. Link: https://lkml.kernel.org/r/20220126092602.1425-1-linmiaohe@huawei.com Signed-off-by: Miaohe Lin Reviewed-by: Muchun Song Signed-off-by: Andrew Morton --- mm/memremap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/mm/memremap.c~mm-memremap-avoid-calling-kasan_remove_zero_shadow-for-device-private-memory +++ a/mm/memremap.c @@ -282,7 +282,8 @@ static int pagemap_range(struct dev_page return 0; err_add_memory: - kasan_remove_zero_shadow(__va(range->start), range_len(range)); + if (!is_private) + kasan_remove_zero_shadow(__va(range->start), range_len(range)); err_kasan: untrack_pfn(NULL, PHYS_PFN(range->start), range_len(range)); err_pfn_remap: