From patchwork Wed Nov 15 16:30:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13457063 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 99E83C072A2 for ; Wed, 15 Nov 2023 16:31:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29DA06B0392; Wed, 15 Nov 2023 11:31:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 225C86B0394; Wed, 15 Nov 2023 11:31:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0EDDB6B0395; Wed, 15 Nov 2023 11:31:03 -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 F21896B0392 for ; Wed, 15 Nov 2023 11:31:02 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 454E0802E4 for ; Wed, 15 Nov 2023 16:31:02 +0000 (UTC) X-FDA: 81460727964.04.1219DBF Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf16.hostedemail.com (Postfix) with ESMTP id 0750218003E for ; Wed, 15 Nov 2023 16:30:59 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf16.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=1700065860; a=rsa-sha256; cv=none; b=IUyCzDwOFD5wiiyCRIgJBbIh3yMkRKwpk0/qHXS+ZBkJn/u4Oa20PFV7fIVBEJ6P0QiICP i2fWe6Udc5fVNyy9paaOKbfF+lKP3PBI6P8/hxRv0KQuASuAXRU2pMgjKgcSiHODOSBXnN hr9Mz6KNr+DulXY7SVmafrCOT1caOiw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf16.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=1700065860; 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=2IQirIHWGTN0C5ucPumITjyI4YT5MYNWep5+T8WG/E4=; b=2Tzn3xvdRhGNI60tZMwq29UclYUgY40F+5cuW6IUzg923aW1nuMOceL1Uza6AqLedvMEtu cix6omvwvZ6dMAmhv7Kv5sZvIrIPYNsDyK7qYRJju4YJQbC+0lZyUBpJzLWwfjjAVEIXk7 Ew9J/wCDb8/n6OEKm6ZZTHVngpnRL8s= 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 B3D151595; Wed, 15 Nov 2023 08:31:44 -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 05EED3F641; Wed, 15 Nov 2023 08:30:55 -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 08/14] arm64/mm: ptep_set_wrprotect(): New layer to manage contig bit Date: Wed, 15 Nov 2023 16:30:12 +0000 Message-Id: <20231115163018.1303287-9-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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 0750218003E X-Stat-Signature: igi73qysohttbdrkaxipzrp51j7oxx4z X-Rspam-User: X-HE-Tag: 1700065859-316935 X-HE-Meta: U2FsdGVkX1+3tDErhbyuzWa5eoJfhp8+6rCpMYZy4HndxS8QR8uoLPN9+HYnwIQs3pdRgilS71u4+XUsQklyzvwwkSZrvmkWYmDsg8QRrq0jGsTEVeKiuhWQiX/tiDQPbb3mfXoj72BvVWpMLG8ZWbqX2m+ZvqrMXYqxpWFe0OXpw9QMBYe+7QA9vjrHs1+1qaKqXIqaUSnGLt6eu8DuRaS/7qr31F8xsw5Nwhy+Hv3z4ZAUptaHMNnfCpzUMKOw1FGiZ+VNnaUYmC2w0fHtnlBUFAUkjgmy8Byj+5IqtSCAWUHMxqk4XbNrh4Sk7u4Z5NGhfhGNWIfRamhStSz8sPCxdc8sazyXLJrEbJnXfY7cBupDh2KAq91B9HZOqpuYHeMrcrIVVFEHmnAaRDig5SWHM+ERQK5Kr7Wtn/Te4QXE+qU39coyucIZaLdfCb4D5mEHWvG42F73NV0bi7nxppPSRgiQ6JOGhT3cUMiVDTGIjfLwO8TDDNDC0pA4dCW5+CLczhvZ4C6P/xGTauFtJ429OB59HGEYSQ5e7zT9t/fKFOW6VWxXkz7CgHJtsFh7OZ0QiaRLieYzTuSyb0fGqYaprihtGJQmkJwT+UlNvw6wnlfyvzIX+cePm0wQkj8DhhCI0IgAi21MzOGJnvidAhqkrHrjxeQcpkEWkTSKbUq+VAwb1lUiVef+bW/YFXGNomTCY+KbCAbgIh8KrsMTulzq7R9WzdDpLspJgwQKhwZUbUHMyEEe4+QvEnVq8qSIaKFbXY6we4Kag1n01fTf3kHxsvc8TNGSrihvlqqB4OZPEm8kPMB5nwTVxYlKwixspjSjeKB+GLtrrB0esuJ4lLdU5iX/+YJmm/j/Dj0z/e6HAfsz3451O+ZePvu8BM1p2V04tIqwtpYKygPfKEb/UFqXHcK3XxiJ1qdaHCThazfFuzmfMVQg+Sp+uB7YYUVnCNEtRaBQHWGPntNmMqC otrKRnC0 NsRBK7dltlOC48mG/LS3kC0chLLud0KA6xGo+2Nlkj2CMMqpHRy9H5cIAIJ55RwQUXYwK+iDn/LbKsioJ0Mppbt4np0VB4h39sKoF+/WwFnASNyBnp16p1LYuGCo0/M5Xa1gFvHTUmsdT33RC/Pxn0dsZNieulgUAONyYGVQx9d5BpTy+yeYnp6z+QgvYwsDqZF/Q3VoPzuO4SGtMhmSS4d0+yCUZ+gGTFl5dOQEsV63gtrKO5HykCDciZpTswvx9yDad7vG+Ld0uQkgfQdW7i17XsA== 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/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; }