From patchwork Mon Dec 18 10:50:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13496575 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 9AB0DC46CA2 for ; Mon, 18 Dec 2023 10:52:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EA246B00A6; Mon, 18 Dec 2023 05:52:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 272F06B00A7; Mon, 18 Dec 2023 05:52:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13C266B00A8; Mon, 18 Dec 2023 05:52:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id F0D0B6B00A6 for ; Mon, 18 Dec 2023 05:52:00 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CCF11A0C4E for ; Mon, 18 Dec 2023 10:52:00 +0000 (UTC) X-FDA: 81579624000.16.FC240F6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 0F1651C0021 for ; Mon, 18 Dec 2023 10:51:58 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.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=1702896719; 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=ELvSMVT6SA8FQM2Gr1fpFkyswAIlVTQIG3RtOI3VLw0=; b=56Sjd4rBc3VBgDA8tmasPfSI41254oSOIeYPadiVou2dfD6jdVYepmG7dxSYiSQfnCsuD8 NkE6XbvOC/BaT5KJyBybLN16qQaAK2y2FIdbGN4s5X6qkE6ILM0Pv6xD5naL2YZ58ElbnH Lc9f2QMUy6QyeH/H7ILJXkfTcXQ9zNk= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf21.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=1702896719; a=rsa-sha256; cv=none; b=HCf4/Eg07QMwPOlB77PFG59JpGV0oz0LWfWrMMIKJpfBQXcZlALe/CyfnyAf6UvtLqGXZu TkG9Yn+2h3g7lDLdC8FMJBIgyjVd4LXTg4NruuP1B83uV8ga08S/J620zp6VEZQuTd/3FK 6Qkz+IFvMrhofsAJ+RKKgiNqKrWMpFM= 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 BD2611FB; Mon, 18 Dec 2023 02:52:42 -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 E2DB33F738; Mon, 18 Dec 2023 02:51:54 -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 11/16] arm64/mm: ptep_set_access_flags(): New layer to manage contig bit Date: Mon, 18 Dec 2023 10:50:55 +0000 Message-Id: <20231218105100.172635-12-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: 0F1651C0021 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: kuhb4sxfhuijjqeh69ri984oc85a1x88 X-HE-Tag: 1702896718-363257 X-HE-Meta: U2FsdGVkX1/lEWNmztWhfHgoTnzKOgSsndzb1XcYAPwYVEkBiTVXINGKnviB8oI93X31HkzWyb7UIzfBepvb0z5U44nFH0AcrLGK3v5fwTiXUd3uGiOk7Ll7SqTsnhaAo4IFkK6gqFJn2LBlrm7NhD8CyYrZ0Yvb1mfxvnFZuEPOXD4FkarASWD8dSbyq5PhSqtPfdn6q6IuwGSk4GPKoSvuQobcfKmuWhxyfTQh3KvAynLQ/eZNycViKLzEkZYsV7GvKZLxdoAbMrsUJY3gGp1JIgTGRwuViywhKrVtWplKKStgZIKA+AXiJ1837IQoCQA2bQFUtNkLNrhHOjRorTpLbF8yWeonlFWzWdwt4Jls5hjG2x0r2i41eASaex9KTXt3TerF78t5lm0u7XPnZDJA7YwRcUWJPBrybRFz+fB9/gOveCVY+JHfrsYagNWhv8J+IzinhOQpyCx8IzrYfp9OOd12DAXuoytkXTIHqfTgplTxiVUd3yYeMCX7vIzCtBGl6/WBG9dKUtBzPbzCzRRSOhuELLgQ+C9YzMa1IQaJxZdDj0Ns8bQR7PVqQPLQArPzhjn2Oi/KJlSSICL9dIyGw6a3cYrlatrpEjP9HwLGTCdlYdlIPn0Vm9WZIdjh7jSmcLtPIkND+0kr2DLEHQa4iPs8Blzdd7jK0IhjS5nQglSVo6AfyowTD6hir2C1x71a+J6m7adVH9cyzXvf33A2hrT0vc3eh2l9uOB+CGi0Ejy3xJtVBgfl4/YG2KRKN2/09QTrl1r5TuVxCV+uSqp3o2o7J4N2wceJL0hFbhR0Jp7VeKA1eK2u9sRNQB+4X/NDC5Gwe5+jmAv7/FfoY7z3Dvs295q8w7CT86+3tMwNkGuEBAH5Cac4hB3EzkOTGSfc11r7o3tYPwcxzZ72ETQx1pdNbe601GdKFfAggebiTEmun3zFeK2pjONqzxDe8Zjr2D7oPZVWdL4qHMS BsoEF044 op9IV39Uq1mzRix0wSNPawdATZy9Cz20j6eDmxrCE0L5Bdr4Pvq7/5++8OmFcTyJZWN+wI2yNpEsvIE6b4gD5C+vwlymh3Xe6fP/HLi3hID3ITlJ4hR5qs4dZCSKt22auIttXZ7KdoPfBxtMeJn2njrjA5vfU2x79wjHV6b5R1+7r0+fOfwPTwro9cQ3iaFatXWRhgEqb6s0skpjXnUqJt6BR++erxF2BQVU4SriFGsFa9FUXJJ2d3eFJ+68iWeg7iWX/piP8kU+mq22aLBj2zeLDRSvXLoEE/yibLbYhs7DTe1s= 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 423cc32b2777..85010c2d4dfa 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), @@ -842,8 +842,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); @@ -853,7 +852,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) @@ -1122,6 +1122,8 @@ extern void ptep_modify_prot_commit(struct vm_area_struct *vma, #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 a287c1dea871..7cebd9847aae 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 952462820d9d..627a9717e98c 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;