From patchwork Mon Dec 18 10:50:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13496572 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 8290FC35274 for ; Mon, 18 Dec 2023 10:51:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 226F16B00A1; Mon, 18 Dec 2023 05:51:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D64A6B00A2; Mon, 18 Dec 2023 05:51:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C6F46B00A3; Mon, 18 Dec 2023 05:51:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F0A506B00A1 for ; Mon, 18 Dec 2023 05:51:49 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D275D4107B for ; Mon, 18 Dec 2023 10:51:49 +0000 (UTC) X-FDA: 81579623538.28.D87BCB3 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf11.hostedemail.com (Postfix) with ESMTP id 24AC540005 for ; Mon, 18 Dec 2023 10:51:47 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1702896708; 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=OjvLCzI/KlO/iQQJYXpNOpyg2OgTuVIw6IDag87PmTA=; b=uRDgGihvKGWx5fSY+s24U81CdVg3PSXGePtn3qVR5a6FbiCmGWaIwqDwNLRYi0vXu+QoW8 Q7msaCHwjyowjSpsRLw67QFYSLhEcxhCFmPdOHxkwBGTb3rKsB+gfDjIGt4M6DlJmPTYgU tY/y+ndS2lYeJpY/ijNOj4RpXAhYYaM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1702896708; a=rsa-sha256; cv=none; b=tYLa/S5iBVrx+QBL3CUPEk4IvLyqawrGOCq+rNbJBGnvpIP4Jl1u12oJBs0lsFqxNEjLk7 ydxTHiit8LhFXTI449eRDt4FQ7twdUKegTCv4puvNxtxpPc3KKGFhID7Vnrg3+8XHyNtz9 THXfH6EOTp6hiSfVL7/OnhpUiD4gtts= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com 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 E02011FB; Mon, 18 Dec 2023 02:52:31 -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 12C8F3F738; Mon, 18 Dec 2023 02:51:43 -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 08/16] arm64/mm: ptep_test_and_clear_young(): New layer to manage contig bit Date: Mon, 18 Dec 2023 10:50:52 +0000 Message-Id: <20231218105100.172635-9-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: 24AC540005 X-Rspam-User: X-Stat-Signature: qq3gqqdbufirjt1hinqqn3mbdqo8nwo7 X-Rspamd-Server: rspam03 X-HE-Tag: 1702896707-942529 X-HE-Meta: U2FsdGVkX1/Fyf4AZKpasAtgRpsXpvJ0TdlwcNPoD9J+vZuRPoLnhsUTcEP+RNBTgNzVI2jojHwjG5kXNQ5ounSE2uTpakvxGsyzDSh00MFQKY3uqh6lDiJOMXR/Uct0mPkBRnB8Tgl0tVF+AezWeyfHjTjU+iF6NcGjD4JSkFgQn2gmNCAzwxY9804toC9WK0CwNfQuw6Knef3B+C+uBov/IBnfpEoK52uKknuNPGpFcmQSi/gGZ+ONDMcJgNYpzgnGQf7zp9Q0X7ZhBZnTuaGTzwIDuBHHn1yJOxM5PWOBIQiIzM+UqXJy9daEUQNw59ot7IS0E1SquXx1bqWwjKsocfa1tqK67wxOfByFBFSvg5vQkz2IqAhedNuF/2qvxyPxZc/p3V01BqVEXFclMp3eia0CddL1c9b+DQ4brpuBYQel0d/yh/sxNyl8mm496+pPiMacZhoalfB1w57U7CrIRC6cLrYBzFif1FgWy32fgllV1z2Lq03ohLuDu8kG//F8YHGLMNf47PvEYjDjE5dPSz7plMHD1mgyKZx+hRt4jMY1OARsZDRJ9zxx97QyDd/VhQeiWOX1CUyOGk3pr5DfxvSTGtx9xtqVZLQJMI7yfUeNt/7bIRLu6MJVRJH6y8X0C81FIil3pPEaNzoc2bf85f+ZTvLLqQk+k0zocE1M5zs4aamFdfiVeRlmaed5Qr0JZY8AVDO+KcO9kpGxmPWVaWSoAhvphhYqFGMXBJeSVZIIkUqT+leH//3jSA5RlMxUpzl8pFa/sRkOgKFB4uYJqqe7zzIkiKhppmCLz/Ex36p3gtcRF6dC0h64gHBhK2zyfGV2kP0ofViR5nMWhIYjiyhv3xeWFZmRcYa13CXdu8RbddtJnkhddis1ABFH2NqcyHLrA5hkHy93pZoq4Fsp6YYl2+6FGFG/G6gn/++BO6wwWez978ofvC/AZMjNQDA6K5imNasPdnapJam ecCb0OMK 7FiFT99L3h/cDtZqEHTnDNWkqpRL5tvy2aGCR04APnNj3DGdwwPjvme/0UjqBkkgQcy0Tz2Yz13RYVV4NJeD0ZZnys8qgWhSodXfDOZPlZI5huucSBD8AXFLxrHB3kLwWbs/e1pi2vPzgOZWFjCbl1X5upbw9h6oX+U54U6QfwR0yNuLHrlGn8xh+WaU+UoiWAXhLd1027UvJfFTcj9/66BqHY5DUtAUg7a+dcPbNasfP4ahbJ622S6NfqTIrgote+UpYeiDdbY6WxJl4AxehWdsmnB0+sCOvZelEMjbKI3SXcQw= 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 | 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__ */