From patchwork Wed Nov 15 16:30:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13457064 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 35037C072A2 for ; Wed, 15 Nov 2023 16:31:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B9DB86B0394; Wed, 15 Nov 2023 11:31:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B4DF26B0396; Wed, 15 Nov 2023 11:31:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A15E16B0397; Wed, 15 Nov 2023 11:31:06 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 8E6746B0394 for ; Wed, 15 Nov 2023 11:31:06 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 6F4B1403D3 for ; Wed, 15 Nov 2023 16:31:06 +0000 (UTC) X-FDA: 81460728132.13.759BB14 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf08.hostedemail.com (Postfix) with ESMTP id 301EB160009 for ; Wed, 15 Nov 2023 16:31:03 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf08.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=1700065864; 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=H0BwGCXMY0Jm/jIsiVmBBtVJvXghyud81fHEkKj7GCo=; b=DxOCqZK7+gyqTetJIzuUG2WS2jrWWfbKKtk/hJxWyG1/oH+vGKpbK+L5ymnpR2Kutl5tzV lxtaPKijpD4T5O/CIIPGSb6KNOOMmdwrkhLVOAwma5PLYz3coe8ZL4J2kqiRHm34PPwV5s 6/kGtloSwlpiQfNVc023WOWri+VoOvY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf08.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=1700065864; a=rsa-sha256; cv=none; b=Wgn13JH/mjkDv+q0D0FE6u20EuAA4ITtOs1Heig6CidVPbhuQzR7jBPfxiVPdVq9jA3ghz 086CQ4PVVpBYgOKOndhhTO9BvP6xZVMT8CUdmJt1Jz9dlylKs4L2f7Mma8mhWDM9Gx+hH2 a9eAxvI41wy+YwMYWm30f6ujyNXO2+c= 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 02C4DDA7; Wed, 15 Nov 2023 08:31:48 -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 48AB23F641; Wed, 15 Nov 2023 08:30:59 -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 Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 09/14] arm64/mm: ptep_set_access_flags(): New layer to manage contig bit Date: Wed, 15 Nov 2023 16:30:13 +0000 Message-Id: <20231115163018.1303287-10-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231115163018.1303287-1-ryan.roberts@arm.com> References: <20231115163018.1303287-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 301EB160009 X-Stat-Signature: 6hwazba49g6jmm8ntfw3rq4rx1h3fdxd X-HE-Tag: 1700065863-61635 X-HE-Meta: U2FsdGVkX1/VeRYkuMYZh2U1rmRJW9qQmsF52RabDqbG/f2scZE8pPEGC5pnFmx8ywJRmZYDvHwNCa+vq4CJq076PR+gx2cSkEtuy6QodK6+uxEvOUahL02Y8kQk8lsyoyjZgHAdEqBeAM9YJhnc3ASSZXVulAJLpGF3sd4W0EMRE7H3Md3W/LobSXJX2eqHrX63kz66w42UejpUaPP9gR3EXlwBk2FvowWSzyLfcF8PVlyQO27Hb3Vii+jn1NifcStVAG5rqxZ6d8Z4VAgPlLZUPooNSmw7cFqQNH0sBLojjp19bpTYmuWeD8ox/RmQRAC+DAoSe72bhXBHQANVPfS7X3jfE+qWn6blF87t4cftM+UE4X3cAXByXba9P3DKWUpJjNl8vL/dFtWVIZQ/HntUlmp8zQD3KhH2TaLGPaNJ452hh1R7KD0TMzsskwFM+dzbSyuTIsKZKlBSLlQq9c2YEsK9Nc2spTLRcvlyI8cubJZrg+VGdf6LrZphG2si7NJsnG7hErJztDTwjaKv4pMLmW/+Je3hAdkR4ScC8IIzs0GWqpcKZyRgxqMtSoataWtQJ7GBc7NLNx2EJEK88d+E70tz+63erwIt0gkISGideMaJLQMhm3CnTgAB2Sn9rIhzCu36F2pln1TnZlwYgHpIGHVXZOiXK5yWC4kvJ2y+XxQO/2TAV5up79/Km/8atoK2Zg1GHpEocC5FYGMRqdqVxXX/1o1lFx5/IqkNNEqD/wwuCoutXeR02C3NUkGa0mbs1pqyMMcKERI+ynh5AdTz/TrUaefjNFzi48WdhQXkZXucC4ltH3WeF61oG0HMTzVUXRnNAkMjQA8P9Yncja51xxEsjJeoef34OE1wBehctzu6vmOI6EAsJEQHq+Rsk1I/2AE4nr4dbtQwc9K4uCtrONenHWriBetu3y/wwWeifv4ezFzKzbE5rlmhfQsyJLoPxnpjnJkc8Dq03Dj hxDnK5gb fp0fo5WNTGNQeuiNfDT1+Bup+pyPLep+PFrKZI6WVc3ZgFgob1T1hx5LCRquiJwJvJsSaIjHcwS0Q4EM6eMH9h/+SvhyEzVUbAg+wW9MSdZT0hEJGzLChKtyr/EJ83dbpGGC5yBZwa+BhD+z9+SMeuAtpMHGBenQt8EIJStW5jEsexPEFeIIaPlf1o4iaJpGdn2ZIcWQXmfac1GXkIOiar8tf7HlDvo/PnK9cG+vHipqX2Q8dfcUSoH5WcnXQUmtrCRW6LQ9V/IkIPGFhrKsqiUjX1Q== 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. 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;