From patchwork Mon Dec 18 10:50:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13496574 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 ED5BFC35274 for ; Mon, 18 Dec 2023 10:51:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8B6B56B006E; Mon, 18 Dec 2023 05:51:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 88DA56B0075; Mon, 18 Dec 2023 05:51:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 755656B00A5; Mon, 18 Dec 2023 05:51:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 660846B006E for ; Mon, 18 Dec 2023 05:51:57 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4732D120CDF for ; Mon, 18 Dec 2023 10:51:57 +0000 (UTC) X-FDA: 81579623874.28.6379982 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 8663B2001A for ; Mon, 18 Dec 2023 10:51:55 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf03.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702896715; 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:in-reply-to:references:references; bh=L96YjzXNEj/7992DdZl7vC+6Lpqmu+YvM9dQCrXn2YQ=; b=Ln+1wSrKG3RmmoJfWeH22pnTFd7tFMipgCTW4Vd4pAAd2AQ/KXQn6VJfoMh7iFrQYj7WkS /Xlf9NnmL8nI4b8oHSll3viBhDiGUQwXTB1by9X5QgmV3W4Wz/Quk8fslL59PiXY4C5LuM MYNcPgyen2DEp0bd6NBBUNTfr8uTvb0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf03.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702896715; a=rsa-sha256; cv=none; b=qPyVVhHlsz+wJTDcH7RcrHL6LA+3Y47A+Q9LN7IbAe7T8US0aHVYrOSz8R9fmG7wUaa+X0 G7B4zlG7xH8/MkcGI67X9i/VraTn/AEZz4Vt43KT4Od1EETEQy6ado1E/JnC5ZNGjVHWqG jqQtr+LkC3IlA/XmvAopFxB+nP505lU= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 267FD13D5; Mon, 18 Dec 2023 02:52:39 -0800 (PST) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.26]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4C8F23F738; Mon, 18 Dec 2023 02:51:51 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , Andrew Morton , Anshuman Khandual , Matthew Wilcox , Yu Zhao , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 10/16] arm64/mm: ptep_set_wrprotect(): New layer to manage contig bit Date: Mon, 18 Dec 2023 10:50:54 +0000 Message-Id: <20231218105100.172635-11-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231218105100.172635-1-ryan.roberts@arm.com> References: <20231218105100.172635-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8663B2001A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: rgkcjwsm9jqj3j1t7xeaziqessr39p49 X-HE-Tag: 1702896715-464740 X-HE-Meta: U2FsdGVkX1/Qa+uF61pchvBS0VsdOIp8jilhy7mo8XeYTYGe//0UD8/gVyUcbj2a+aLhZX2SQ1/Yl7waLqzWoyI64x7dJA9HZTBOG2lL1IASAt7ZrSQrXYyVf5uYsuYmdUQFxmQwZn0kbdodHjPJNI1mR/VTXTLMeC8XmVPaYmDDwTBISCIIt9v6I1m0YkZYIkjpbvz6kMjIjhPXuzH3Uikmw8KBXLjCAmKFB92h861CUL6ZMZoMBV+bh+X8/ZxQnlmCZyNzOZ/bnM+0NPShT43tkIYDylIAnWZ5DCSKdPFx+aqhh0O4t2qYVoxGjQDIO9sK210UuDuyEhMFCKYTSsEmtFd2tYc3QK61vzoxDb1lR59W+/PVjdNKk23E2nFTVQCmPPpkY+mgFnp+ZNbt3Nym+9X7vRR7N7juJNMy8lalPUqgYOmvEEtYS7UBhZAb5NUaK+0i9Mp6BAhASvrH2yjcB0KBlJ4wpm03BHqiMldFGSmaZzVgFyqVr4uz/7Mn8IYb6Xf176CpnfFwR1gRBgGDszgIz6pDt6h7+NvnjDThrl8EHGmtOAepae/8Jjy7HaITjJ4luyKMWDOqbwLAresqbe66auJSNTI/WyCJsG3w8e8GwcfBz05X369m2w/FmybICjZE+ubsNvtyk1tNxYTQ/+nz0CUXSAP9q2n8yOlHwJ+WoF49QilIUL1ylHlf/Pg3zgoU4j5a6RBdjhfTqM28oXEFWKccdqMH2u30n8pjVlrAUQimwdGNQiEzZ7cG1Tms8Kc4wLjk1uZ08K3WDTYbrsMfXPbbMbynFc1/av3oxn+uOJg0z1IagcIh7bfWz+Wna7q3KyJD1+k81fZwCtDl44qsbscUtnQ47X4pTEtgIryQ03FY8PZw3lVkdPiMbeMYSs/9DgcicXq7OtFe6NJEcTu1cCEarpvFgGDMDe5uTGRmVWbjKtgVHdvXKIUwSX4QizK9bqvzj1lHKeV kwZNsMaG gmqlcn2y3XxFR7bvZ5v0lDbsjTUKmFZviWY4KiCJ3ic57r1qKzmrDdlP6wvWnZbRlUwiR+EBnXkuaiy7BF0+5b8yWYq5sFTUBBVoh/S0hAsF/epX+GEgijmlzfMQqYPnrTEmVIFhU0frP1nodpJ/KaXgXaiMG9nCU/DuCq9t5HO+W7jeitCDAyKqQpxJ8x47z48fCf9qRqUFVT37eycLyBlTvTXWcUs4AuI5+NpFoFUtOJtsNjBo9WJThnHFzJ7PIfivWkDga8xqV+gexYpuLRmvx3zssqyweWlFDMX+MfE6jro8= 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: Create a new layer for the in-table PTE manipulation APIs. For now, The existing API is prefixed with double underscore to become the arch-private API and the public API is just a simple wrapper that calls the private API. The public API implementation will subsequently be used to transparently manipulate the contiguous bit where appropriate. But since there are already some contig-aware users (e.g. hugetlb, kernel mapper), we must first ensure those users use the private API directly so that the future contig-bit manipulations in the public API do not interfere with those existing uses. Tested-by: John Hubbard Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 10 ++++++---- arch/arm64/mm/hugetlbpage.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index fc1005222ee4..423cc32b2777 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -958,11 +958,11 @@ static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ /* - * ptep_set_wrprotect - mark read-only while trasferring potential hardware + * __ptep_set_wrprotect - mark read-only while trasferring potential hardware * dirty status (PTE_DBM && !PTE_RDONLY) to the software PTE_DIRTY bit. */ -#define __HAVE_ARCH_PTEP_SET_WRPROTECT -static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long address, pte_t *ptep) +static inline void __ptep_set_wrprotect(struct mm_struct *mm, + unsigned long address, pte_t *ptep) { pte_t old_pte, pte; @@ -980,7 +980,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long address, pmd_t *pmdp) { - ptep_set_wrprotect(mm, address, (pte_t *)pmdp); + __ptep_set_wrprotect(mm, address, (pte_t *)pmdp); } #define pmdp_establish pmdp_establish @@ -1120,6 +1120,8 @@ extern void ptep_modify_prot_commit(struct vm_area_struct *vma, #define ptep_test_and_clear_young __ptep_test_and_clear_young #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH #define ptep_clear_flush_young __ptep_clear_flush_young +#define __HAVE_ARCH_PTEP_SET_WRPROTECT +#define ptep_set_wrprotect __ptep_set_wrprotect #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index c2a753541d13..952462820d9d 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -493,7 +493,7 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm, pte_t pte; if (!pte_cont(READ_ONCE(*ptep))) { - ptep_set_wrprotect(mm, addr, ptep); + __ptep_set_wrprotect(mm, addr, ptep); return; }