From patchwork Mon Dec 4 10:54:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13478191 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 41E5FC4167B for ; Mon, 4 Dec 2023 10:55:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CFB5B6B02A7; Mon, 4 Dec 2023 05:55:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CABE36B02A9; Mon, 4 Dec 2023 05:55:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B9B1C6B02AB; Mon, 4 Dec 2023 05:55:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id AB9D06B02A7 for ; Mon, 4 Dec 2023 05:55:24 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8F8134018D for ; Mon, 4 Dec 2023 10:55:24 +0000 (UTC) X-FDA: 81528829368.07.58A5B2E Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP id B8B0BC0020 for ; Mon, 4 Dec 2023 10:55:22 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.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=1701687322; 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=7HLmuONLy6ZIo4dQJJwCcrnlM0IJqDA8GI9dYJgQkWgSGgLkEbRLCZF+IJjvjdJNrGhwhZ qa53AQZuYTz0XsZSjPwhXID+IoTAE3LJceWChQ8ZfciPhcex4DdeqA2mxwR0k7Ol2ywDwX 97MEXLsIyaZQBWR6xhwok3a+eI67Cg0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.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=1701687322; a=rsa-sha256; cv=none; b=VbC/b+tbnneXVd+f0XN1v62F+k82NFEhoo+9QeCiw3zDYDYcfL6jl5FYv7IilIB1FJZ91u I7x+OUmwPu/5Otu2cql8NwmtEIUb7INFd9D8VFSUyHGkm6c4UjJavVaocxA4okqb492o8Z Ev+mCO0nXtALYFxMKQlfYdTu1XFs6mw= 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 49E5D1684; Mon, 4 Dec 2023 02:56:09 -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 964FA3F6C4; Mon, 4 Dec 2023 02:55:18 -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 v3 07/15] arm64/mm: ptep_test_and_clear_young(): New layer to manage contig bit Date: Mon, 4 Dec 2023 10:54:32 +0000 Message-Id: <20231204105440.61448-8-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231204105440.61448-1-ryan.roberts@arm.com> References: <20231204105440.61448-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: B8B0BC0020 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: twt1xg5i95wpq87udfa9nr5dz5t9issc X-HE-Tag: 1701687322-121201 X-HE-Meta: U2FsdGVkX1+zy33vha86i55yrDDSFPGES+mhuWexTniGyMN7/h4ILcItzpYlT7iiEq+hERACGiD33GHHQVzuD4Guk0uvZqWq+wMPjR4a5o3XVlh6zk37ceq+6u1xCIMF6nSfSYBCsQdXfG5764UNvBGoBw+rtb60Q0djEMFBDV4ssj7iJ88oz4teocI76Aado7+4Z/HTUgQig3xtkRSA5NFfLk25dWhVUMpJEFkY2QCNEtO22NDt92Kpli050//mJmowGQ5/QUc170NelvKV2kCy596lSB3eXzmvMWuozIe5Kcz8OucVC0u/NLdScYhtfQs8AsdSNAld7Bdoo4h7FWKq5qADaV/A+nOUTxXIvJCDQ+O38xZGzfwrnfiWgqKGhZiql/OQWsJSzQ/bj1WK2I9fziEibwi46yUNb0m9UWpNGmBKlfEEGRU/bVkwNKXO9neVX3RdkfRLwxZ8HhbxoxQ6stciAVAj4c3KrYa1+2PAtpERPY97poz4P49ns3dZg0c0KPZ0wTjjIvFLtjS1AP3FjdOqDZfN7C/ySwBStlwhiqGbu9m6yuq/oM/ef8Lz+hZFSEl1yVy+sbM8cVIiA/CFYp6/6R805vK4zdjVHPHbrQ343zDfmFnwsM8dQfBKALb7LF7tzHjco8FMhYGXPjhFNUvmVEuorKkPFnVbgokfVOmK4/pG477yZX7zbgzbgRTBD88f7Ho4k9BAoFQBEX5y7BAVaL3I8hgeXlL2mhNTYS7gqRb6ucStuqDpI+527XlcPykr0VSUz5725Dn1iACWj7NYBxNIRoodhKFDe2Vb8mv3NQLD/ya3vqRXcTfFB2fMAsIyVM8TiLaER2E2tVL5aNypRSaUkcAnJkKVn9r84g+29322P3w7/J27CWijIITxvs1si4o+WpeOhSaZ1mvb7TdyRtfG2RxBjbtAtOs11l4bEYy1WdgDmdO5AC3hTCptdiQBQ5OwWK4cu5s ONPLNG7r RiCM1Ond+Nk+n2w2UgWZofjQ4bK9MTmKxfdTp4/paHZEk1fvTEt4wAmTNnRf2cP8UDXBgKz2YHoYNAXGRgOfkrHQBAeVMJSXGVKA8gJ6RQyMQ/BAw5G3yxoUd+zBqjPD5Glps6YelBAYQf64INknri8hZEWpHo+6xtMXOOf2HBpkTbEOzBPRXCfKdewZkrXpgj09KRz/vIoabb7PSaVs6NLq5SoXEKQ6cP1w91EAL1dxIelylXpnLqQE++Ok7I3zvodoGq2pbgpds8vS1XojJvgxSrQ== 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__ */