From patchwork Fri Feb 2 08:07:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13542350 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 AAD33C4828E for ; Fri, 2 Feb 2024 08:09:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EDE46B00A0; Fri, 2 Feb 2024 03:09:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3C4B66B00A1; Fri, 2 Feb 2024 03:09:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 28D736B00A2; Fri, 2 Feb 2024 03:09:16 -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 16DD46B00A0 for ; Fri, 2 Feb 2024 03:09:16 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E848CA0B89 for ; Fri, 2 Feb 2024 08:09:15 +0000 (UTC) X-FDA: 81746138670.04.D0F827F Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 404EB18001B for ; Fri, 2 Feb 2024 08:09:14 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706861354; a=rsa-sha256; cv=none; b=JT0GEKmGTSpJgkWxQQClr98f9sYi1iFUSQ93cPF1Txcml2j9G4ThkpP0tPzEQsJvmbpvtM NKENz4pYd1mMlPbLrNMXm2+tk/fvvD+KnT+RqwDy8fcfo+3svLPwUof4wusrybCuGkfFHK ilZ6V6h4jOPsMggR5+oeS63u4zJa+AU= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; spf=pass (imf24.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706861354; 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=n5ldPMFAPklGXLjzR2u+4xIeNMfWz8XyKASMmqWuzUc=; b=buG6etnvXAa++GpjKH6Xg6biyR4U76MmpPmNO5fhDe1w06Dm9rMIg+jcUFwSpnwRmx94Xi yRJGD+3bQtWFAf1fLQXgBrUJQrD0Tp/FShFzXRNeQZGFvXw5h6FnrOqcIFknhFDcknwsWz MNpx3EsPe1epOruI7c7lQWmyBkgWLKU= 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 DB9861AED; Fri, 2 Feb 2024 00:09:55 -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 EFF383F5A1; Fri, 2 Feb 2024 00:09:09 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 15/25] arm64/mm: ptep_set_wrprotect(): New layer to manage contig bit Date: Fri, 2 Feb 2024 08:07:46 +0000 Message-Id: <20240202080756.1453939-16-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240202080756.1453939-1-ryan.roberts@arm.com> References: <20240202080756.1453939-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 404EB18001B X-Stat-Signature: g858udrazrbfu4a43ijmtbm17wf18h88 X-HE-Tag: 1706861354-445143 X-HE-Meta: U2FsdGVkX1+fhEG8POSpm2qLJADV5cJIXWhOhf5slnWZm5gWkIqN0vyr1vWEgzPZTLiKSofOkHR7H802d6WiBq4uBmv21IyMiDiiEw9vdhSjCg9gQQm/pMUPQ+BmEb5KYK3k6E0NVIVTwzCZ3q0p8UdzwJh+JCn0SAHCuJOaTKN+mOcMcbQVFStMkvbPXNV9CE6RSNVnEcf3AmzcNLC0qY5XUWvbBGPtw43ddO4BSsWWTXe3etgnQP1cqRfOJ5TABD1bM4hhASMheHn5jf2bJBGImvrM1KNBZMf676VIntoS2djGO2ZxrTcVTrlr1ZqtkgD1buyNM14apc7DbaOHGLJO1+TWPd8KLrXBqQdKl5+9Xacqtjn9++rVaVqwZkavHLdw4TbUECssDq4RutqrSbmJI4UvKC0VP1oYj/tm6QgLPlCisMKMdIrJDGZvZZtXKNCAq5UO+IMzur5iJRWJrTn6+MDfA5vdngYf++bbOObmk+dbMFexR0nb32c/qNCtPnmGcNgvEtEtXXV3nA0JgfXBpMQpWtXHVaGPhgXaa+D69+yAmWHKyvApFtD+qntZF32J1zvfP1XZnDYHDCPQ7b3I+IDny2ISaa4PcZz5txargdJpC57AtZFnNDVQ9OXWaIjBO+4AccjMPB45s8EV4VDgp5GuVokZ3oYpX+bYoOlAeO89gUJUw3C85yw0xko3Vy67nEyvwbeGsTapSKKCeLjJEv2Suodxr/wQcyiwtZ67srW5I3OWAPT+ht9a9pMo+oyu3cRF005xbc/gzF45yvMTPTvKg3n1T9d6Ur89maPS9snztcObzOAaqaISu0lUfTZepBDDNUvdruj6aBlN0f6ejPDdoKVVaNa5bOJLq2H5uT7M9Pxkke5GFBAQM67whdOOKOyRlNM+W4dnBWl9OWsgxmFt1PvsIDw54tYSyOrO6mjFIX/RbaqSmHvSDf3YCRAjbsEafLdUSQe0qtC 3g3dxe4X nQcfDtm/uzlFiGrjh4eTPdCyWXnTytmivuSwlbcHXtw5+NXhNW7CoycsywJnTcRsRxKqmcA9+1VOPL1XgEjXG4dItAbi5nufunABXmm0jOwMOxi2thhvMcTX+xNGsUG0hqjhV55Wy1VL8/rojHao3OYiB//8Hhs8xTgMkOIFkqnab09TsIBSFcR6m2y6RkJd9ftcjc0SfJFsHOF5hVdBFwV6WDVOTq/HzdzIpBeTHoWLN296AlQBe6K9tpUcP/PTkz8QOhoKVaJlgH7x4tWjWbkS6fupiOKK49dNjC2N88iAShdc= 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 2870bc12f288..4c2d6c483390 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -970,11 +970,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; @@ -992,7 +992,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 @@ -1139,6 +1139,8 @@ void vmemmap_update_pte(unsigned long addr, pte_t *ptep, pte_t pte); #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 7e74e7b67107..f6612f3e1c07 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; }