From patchwork Fri Feb 2 08:07:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13542351 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 8853FC47258 for ; Fri, 2 Feb 2024 08:09:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12E956B00A2; Fri, 2 Feb 2024 03:09:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DF396B00A3; Fri, 2 Feb 2024 03:09:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE9146B00A4; Fri, 2 Feb 2024 03:09:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DF83F6B00A2 for ; Fri, 2 Feb 2024 03:09:19 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id BBDFF40E9B for ; Fri, 2 Feb 2024 08:09:19 +0000 (UTC) X-FDA: 81746138838.03.A9FB70E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf17.hostedemail.com (Postfix) with ESMTP id 1E39140011 for ; Fri, 2 Feb 2024 08:09:17 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=none; spf=pass (imf17.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=1706861358; a=rsa-sha256; cv=none; b=yTDG+UsEoWJ8MRaIG4to02va+2bInmq3nGsnYYLDZ8hrKrvMnIMEvs1spnReHfz0kHIaU7 O/iFEvjyyNcpDV6O82nOo8suAhgTq7KElLf51vljtgpjrudI1ptUMg397Rh09eFqHB2tfO PsxOXV0NWsQFtCMspk0OiBAe7DZW5oY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=none; spf=pass (imf17.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=1706861358; 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=WEDowJeJyddXsBri0afqLyUh9g9Stb132m/wGVNOl8Y=; b=yB94f23enf6ei9uztv8nVbOWA6kV0YN+TMX/FCPMzs+o2HnpYvETOz7wmr3pGGqGNB/vFr DWGtI3WtTyxz9zcWHrapFRfWarsBLbfI8DJ/7zlAJgk5418d39aRgrPwDzTdeccPD0IFHF Jef7v4V76e+VAtwl64ZnJy1GQXEhmbU= 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 AD2351BA8; Fri, 2 Feb 2024 00:09:59 -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 C16503F5A1; Fri, 2 Feb 2024 00:09:13 -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 16/25] arm64/mm: ptep_set_access_flags(): New layer to manage contig bit Date: Fri, 2 Feb 2024 08:07:47 +0000 Message-Id: <20240202080756.1453939-17-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: 1E39140011 X-Stat-Signature: dikppewtk6ouptjyjoeomeepauyuyq5m X-HE-Tag: 1706861357-364672 X-HE-Meta: U2FsdGVkX19M6hQJf1b8Tol5UV5XUp/VdJgZiEEsK6lcluGbCfesQj58ToC8ApfLVVIP/6VQP/u9Op4Oxp2K1SlAaqMlUDYNvSBrYKccH6qIMg+HEvzTy41a59RvHV5gBnaV2SH3npGj+MpxTAFMUMoT0haaUBbPUMYJlsEgqvR3Rd2oNINVLVpvrl/dD7AaWoC6tY2UU0Y5a3JLSbklrtrX4bA3zKx0VncJOqY315XmTw+DIQd4u6qq9+iM16KpHVsJAdstZ+0qgwJ/nIeg7UY9/VlGyadQy98eaeP6rRzZZ6SU2ZW6COO9pt8MWa8YGNbsWRFL3c+vzFxvwEelL1rqL9GDhdouRUZpcCU5oqmRvKEVKxA+Bogv3cL07s79O+Y8kVU7nHcuzbSjKYaju9cWbaVAaF31halT9H0yKUP4YMjQzyEVKQKisnFRNRdB3Q+yqbBtiwRLTCNX9jUQJuMmlQGO5Y90f1ny3N1EsBfPDnrmw7TnlxVcqNiF7tKMZ3LGu6TFLIJsJlz43FpqXlBJvk1z6MC5pKEZX3wpyT8tEnQSKVf3nCcsrGrTohPEPS5Wtsbyq1LHpw37x2oFn09fDJN6Hf/VU0qhkablHqdFv6X7C3Bgohw7FF7PXlL9+rbpz3FRDkaLvDQBOYJN05uO/koHiQlaHprFuElhtFU5+WIn2cEHqut36aRUbAJytMsJhuhN/vOZWL+ERmJ0X9ZHtcsI1SYIhTluGpclYJM7BiQflm6LQaZ4o3WOeodfv7Y4h/Uhn1MyMJe2Vo87O1jWKDnm7Ngd3fO3mbUjLfCsAR154EEtv8X2G4eRba0B41X+IeqGgMVl6yRgn7o0flgTYhLLXtLt4EoLhC3cIdDMePqh8B4Mf6KqycyyulTwtnicQF+tii2CveIwiXSCDdhNjzyErd8y2yr+aOc3VLfXazMJLKcD9nMAZXGVZQsxqA1dZzMkmnMpNtZdqfs DG3iYOwf CnP3qWcd6FjiWdKeHZzVE8iNwZq7KZnMoQmjunQKX3UcDSrzXPMVI4FXSi2SjzhsL1Ll/EU74kQ2rgBwswm97Rt5KK3a4Ah61xCojr9rZeboNRLYV0vunk+o2L+d0YB+6EFNI5vHno0SIG3l69QXJxMh0keqUKwSwgo8n+D6QnroBLAER0BRasFnHBIvJE/6PWIkqsh0d0JUiWuwPdmdZlQX+zmuFfWsGPueZ322P29O5TMGcieNITUDZO4WgkKhQBW2xWx6sZI7upm471FrRrAAZ4iNhcfKbwSenPOyp3ViAVGs= 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/fault.c | 6 +++--- arch/arm64/mm/hugetlbpage.c | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 4c2d6c483390..fe27a3175618 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -312,7 +312,7 @@ static inline void __check_safe_pte_update(struct mm_struct *mm, pte_t *ptep, /* * Check for potential race with hardware updates of the pte - * (ptep_set_access_flags safely changes valid ptes without going + * (__ptep_set_access_flags safely changes valid ptes without going * through an invalid entry). */ VM_WARN_ONCE(!pte_young(pte), @@ -854,8 +854,7 @@ static inline pmd_t pmd_modify(pmd_t pmd, pgprot_t newprot) return pte_pmd(pte_modify(pmd_pte(pmd), newprot)); } -#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS -extern int ptep_set_access_flags(struct vm_area_struct *vma, +extern int __ptep_set_access_flags(struct vm_area_struct *vma, unsigned long address, pte_t *ptep, pte_t entry, int dirty); @@ -865,7 +864,8 @@ static inline int pmdp_set_access_flags(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp, pmd_t entry, int dirty) { - return ptep_set_access_flags(vma, address, (pte_t *)pmdp, pmd_pte(entry), dirty); + return __ptep_set_access_flags(vma, address, (pte_t *)pmdp, + pmd_pte(entry), dirty); } static inline int pud_devmap(pud_t pud) @@ -1141,6 +1141,8 @@ void vmemmap_update_pte(unsigned long addr, pte_t *ptep, pte_t pte); #define ptep_clear_flush_young __ptep_clear_flush_young #define __HAVE_ARCH_PTEP_SET_WRPROTECT #define ptep_set_wrprotect __ptep_set_wrprotect +#define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS +#define ptep_set_access_flags __ptep_set_access_flags #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index 23d0dfc16686..dbbc06cfb848 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -209,9 +209,9 @@ static void show_pte(unsigned long addr) * * Returns whether or not the PTE actually changed. */ -int ptep_set_access_flags(struct vm_area_struct *vma, - unsigned long address, pte_t *ptep, - pte_t entry, int dirty) +int __ptep_set_access_flags(struct vm_area_struct *vma, + unsigned long address, pte_t *ptep, + pte_t entry, int dirty) { pteval_t old_pteval, pteval; pte_t pte = READ_ONCE(*ptep); diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index f6612f3e1c07..9949b80baac8 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -459,7 +459,7 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma, pte_t orig_pte; if (!pte_cont(pte)) - return ptep_set_access_flags(vma, addr, ptep, pte, dirty); + return __ptep_set_access_flags(vma, addr, ptep, pte, dirty); ncontig = find_num_contig(mm, addr, ptep, &pgsize); dpfn = pgsize >> PAGE_SHIFT;