From patchwork Fri Feb 2 08:07:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13542348 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 47DCAC4828E for ; Fri, 2 Feb 2024 08:09:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CC7AE6B009C; Fri, 2 Feb 2024 03:09:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C77116B009D; Fri, 2 Feb 2024 03:09:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B18BC6B009E; Fri, 2 Feb 2024 03:09:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A05CA6B009C for ; Fri, 2 Feb 2024 03:09:08 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 4A3F11C18E7 for ; Fri, 2 Feb 2024 08:09:08 +0000 (UTC) X-FDA: 81746138376.03.B3F0702 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf06.hostedemail.com (Postfix) with ESMTP id 95320180011 for ; Fri, 2 Feb 2024 08:09:06 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf06.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=1706861346; 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=0Nx3YcaR5GnneSzYgrn5cd9bIJsd379LdaU+eavGkDo=; b=werrBFqIzq56B5ns68cNDIjLUC6VDPL9gLjOdjjTSCrJHz6ao/zeSD/aVdOwQGyUhQXlh/ PE2nt/udQ48afinNlDBWgcd1SCbaDVdqFWFoeB0MO6EUmfRv2ko+QGHHdA2NmEmuGvr9NU TJmuj+Z5jEnlR8cp+LnWSoZ6uLSurog= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf06.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=1706861346; a=rsa-sha256; cv=none; b=i29NyGvYjEGKrIfwTJZidmvnLxwmfXcnBk1mZoYvXOIZkzy6bYWlfxPujCF68TdXankFgf sotoiAH2uXpKHpe22xKs6qHZ5MBR1Ib1ACDU5tD1sE+Y5GHxcmmNVqiI2Cd6XsVzRFqPVU L/VZ24VAHm4m1607WD1Au5EnQeaJD+g= 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 426DA1AC1; Fri, 2 Feb 2024 00:09: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 570433F5A1; Fri, 2 Feb 2024 00:09:02 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 13/25] arm64/mm: ptep_test_and_clear_young(): New layer to manage contig bit Date: Fri, 2 Feb 2024 08:07:44 +0000 Message-Id: <20240202080756.1453939-14-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240202080756.1453939-1-ryan.roberts@arm.com> References: <20240202080756.1453939-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 1iqpd9qdm1xde3gjrjkdxyn7fdod3cdg X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 95320180011 X-HE-Tag: 1706861346-64204 X-HE-Meta: U2FsdGVkX1/tfHjSCvkpFXEcTOpf2vhU35SOzo8FV/EpGL/j1ADSXyLJt2cwhk/QYOy0NRfWuWH/1m87lqVlXus7EaVOJRFUIBuAw8C4ggrDv6LZjv/kqD+oT93XOnXoY2Bi3vFNheYbuGmwGSy4PuvQHMwTadD0xn8z2b3hocACayFG4wcNSNDfQCJZ47mGxRc3iPqKdrTo0kbkq2fBO6yOrj60sn1VPg3FbxoiZqH5RUjFaCKJ+bNXbotx5cXaWdfQX5e1pCE28DOoOS7L3omou4b6kF5npFftzJ7eqIjOqteNx/blgEFIDz9M4aRhmoPrgAkMlRXNE3FUK/U+uTHBBtFdRoTGJleLuppAm93w27fFPnOP3Tm+r121Ak5EWPzpVaOX7993xzqptHdnx5CdgVqspc57h5CgRYDxt63crmlM1Q99RRreo2+XI5NKwmPLFy9bMTFYE7osp+ePeerjbqF9049+7wGHm88vwGQ33B6RbgVp+CipJm2geTioJGpUX4hrPLJYs3W/aNbXpHBx+Abc6Zh53kAAoPP4cwuq/hMLDxlFqlzU1SAOPhUEXeyEXWYEZl3HNvmfR/qU16TjxY1zmLgTiGhBUjnp1WgwedeG1KNHdW1fkcQGMgdJU46vgjJfby1yr8Le3cRQ27aCoYUuCtfF20pRsnFtFqS7cIfGOssYr//SnrwbhtrsGtrGxAr+rIfq6jH5Llg9xp+aMOqFl8+CaJfRgNeqvU98uhjf40TpruT7lTBgW/v3KMUXV4qpr1BBN7e9d54+LXll6TQbaI0iwE0EnWjypjQVGS9bSGC0XQyt1qiW8syhUT0JLDgVT18MwQc99Ql0Q8gQzqYWvQtxhE8Vaw153vSfxRMxEJCIo7LQJxTd4FCbe3R4Kkrqtg7XUxrEO/tqF07Tm7FfgzQ7tHOj99Hz6TqOBqDdZIkX4IKUeG6IGci9HJhs1dTa1dy3IuczSfl T0XF8KOR HmKiXr3QjLkMEhnq5yzMsUfZau5uNYEFXA/odaUyca/+iOnoAojOY2khoptDOCTCM/9+vg2IdxLBnKMaMAdqW2mAGfmJFsoKFehnW0xkTqxzkkorPD38QuiG3YcTzHwXFqFHG0GjplF+i2P/phGHcKnfq6lyyKJa794AX+18OFuBq1KeBwg7lgMY5qJ23gNk/M/aD3WRO2Qz/hyh9TQMlPSL10SoIzOkvczH5wXSKuZe6XbsdQW8rc9WlJDbG6xHAhOrj23dlWLWYuPiC3wkf5JB8XVP8sFV7u5a1ktBJcoBrW7s= 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 5f560326116e..77a8b100e1cd 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -899,8 +899,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; @@ -915,18 +916,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) { /* @@ -949,7 +943,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 */ @@ -1142,6 +1136,8 @@ void vmemmap_update_pte(unsigned long addr, pte_t *ptep, pte_t pte); #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__ */