From patchwork Wed Nov 15 16:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13457061 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 2826DC54FB9 for ; Wed, 15 Nov 2023 16:30:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9EFCB6B0391; Wed, 15 Nov 2023 11:30:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 952DF6B0390; Wed, 15 Nov 2023 11:30:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F29E6B0391; Wed, 15 Nov 2023 11:30:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 6DE966B038E for ; Wed, 15 Nov 2023 11:30:55 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 40D05120256 for ; Wed, 15 Nov 2023 16:30:55 +0000 (UTC) X-FDA: 81460727670.18.41E30B9 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf21.hostedemail.com (Postfix) with ESMTP id 5C5171C0017 for ; Wed, 15 Nov 2023 16:30:53 +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=1700065853; 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=ah49fTPYg1kjKkibdjx5mHLTxVRVE+SlIK3JQIq5PE4=; b=NxZLeYFymZ72E4Q363b7bMcmq7wdDZQW58CB1yX3MMMGlT4klMpniUhgITeFzyVKTlS5Ah W1j/itvIK4jf4x2Lw0YDU8TkLM4Ob0orI9QtwbC/RUq+L9P6wIrMtpHJip3h5vYNx4kUxO popcw9yy1VaA4254InZlYhlZGE8w12k= 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=1700065853; a=rsa-sha256; cv=none; b=mB5/MtT/smPgqoJWzArUa/je5WaLkTOEolYTieSJf1ChTAZ54LB0A/zsez1gdD6VvOf0hE IUM9or9GOys0lkEDUuPcbTb6IxLtVCQuCCWLmL/8pP65cRAkznpnWQTfpR8O5Jsq5SMZlT k1IWRPAL98j2or8/BPPcxkTLI4LR0qs= 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 2D04FDA7; Wed, 15 Nov 2023 08:31:38 -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 72D2D3F641; Wed, 15 Nov 2023 08:30:49 -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 06/14] arm64/mm: ptep_test_and_clear_young(): New layer to manage contig bit Date: Wed, 15 Nov 2023 16:30:10 +0000 Message-Id: <20231115163018.1303287-7-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-Queue-Id: 5C5171C0017 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 1r54m8t4xwexqinutxapwyicmr8fzpxg X-HE-Tag: 1700065853-341283 X-HE-Meta: U2FsdGVkX1+RNP3dteQ2ihJSYWEMaJK0xnNFkHN0SWtnYdBE2TGQ7DxWIxUpgyZyIzKZ6pCutxM81ePLrrCdpGK603Y4EA76tiYbYGpIAkE8cRHwqXH4tUAIjH9sy7G/rb9+Di3wlaj9cRPPVXC2o4+B+aHxChc5hknJDiDfOVnvwYFDn4bNzZe/wRm1m9k3QjCl+BfB0nvzFAynhX5J39MdSBaevzuYiuNWiccq4ALndY5U5mf3GHTAQjg/sJRGAHqXj5QZu2sG5SpshJ864rFd8dR9xEe9JjDlc0Vzo/cb4LOjHPLMPStNUBNTdfDoGmcUJ47ef7wToS2yyR7qN/iLPMkPKNIz354RGoJ0g5Aq//MgmD77sV/JDIHqL1lS9jFTRkhTgbp27AHHUwAAvn36s4EDjBFiQ6IPmUrR/3X2t3FMU61mmSTHB3KcKa3jCVUa8l2kVi2GwIwGSQxHhYgCcCpAIvVI03GCvAC5Dc16ARou6pCHewXGbg7L7IELi5w0H8ag3rE02e+aCE+Eps2YQmN4+wav+mn4exD/gfSNa3MwzZVfwRE0ewE0BpXz0cfpaRKjksllNqULYxlP7iD4iiPvEN72Ov2DOY5Ie7wiTWUt6lu85WuKtTzqOCCA9X3JL+YQ/CncXCe17wIV+quVHHQETSnHx9n4ykAuV1+L33big+rXhF32IdjGfNIcuEENmNcActM7mqcxKesQK5tS5YVeIGYNautege9SLRCzcC/9Y+zzshgfTSzYveXuG5JhmZ4iX8tczdxJf63xEfwSpHjNr8SgprqppM7jKiqtSwfGjB2XOlMonQKH+AgymBh3ukCQHAboJxHB2M5Ui1pz7mmG+1BuLWGnDej9GJCf7BNwR7xQw856SBNuHcIP+uzLKh+ARiS6Ei/7nzlmegxqDKnNq7Vvysnk+4Q5RuVTF7dmeUpDGbkpQrchXMdbiWMzoTsSSEFptMV0Nes hmCqch9i 6UdTsyWiBu6wgMbNW34BC+5UqdOIEO9kp1CmU49jdgUJKnb2iLKTNnkZR6L/ZEz7s3+maLsWULNzM+CPh6fP4ZL2aE5IaKBB+xitfNvYzuFZAKhTrs7zVKcupLuCWGsX3L6w3dyJYbJkkE2Iwl5QRtKp9MtcAIZRGppixjL2O57uEd4jsrtyCTHQhVFVtNd5iAEp+syOnqUhs7hCa9N8laMYxBlurbrMGwWdjeIrNt7UgOaBd1+YB9Atb2UCHBy0gTFzp0XNI2r/433eiw++YBXQVRw== 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 | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 994597a0bb0f..9b4a9909fd5b 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -887,8 +887,9 @@ static inline bool pud_user_accessible_page(pud_t pud) /* * Atomic pte/pmd modifications. */ -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -static inline int __ptep_test_and_clear_young(pte_t *ptep) +static inline int __ptep_test_and_clear_young(struct vm_area_struct *vma, + unsigned long address, + pte_t *ptep) { pte_t old_pte, pte; @@ -903,18 +904,11 @@ static inline int __ptep_test_and_clear_young(pte_t *ptep) return pte_young(pte); } -static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, - unsigned long address, - pte_t *ptep) -{ - return __ptep_test_and_clear_young(ptep); -} - #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH static inline int ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { - int young = ptep_test_and_clear_young(vma, address, ptep); + int young = __ptep_test_and_clear_young(vma, address, ptep); if (young) { /* @@ -937,7 +931,7 @@ static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { - return ptep_test_and_clear_young(vma, address, (pte_t *)pmdp); + return __ptep_test_and_clear_young(vma, address, (pte_t *)pmdp); } #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ @@ -1123,6 +1117,8 @@ extern void ptep_modify_prot_commit(struct vm_area_struct *vma, #define pte_clear __pte_clear #define __HAVE_ARCH_PTEP_GET_AND_CLEAR #define ptep_get_and_clear __ptep_get_and_clear +#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG +#define ptep_test_and_clear_young __ptep_test_and_clear_young #endif /* !__ASSEMBLY__ */