From patchwork Thu Jun 22 14:42:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13289257 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 A7B44EB64DB for ; Thu, 22 Jun 2023 14:43:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2D298D000D; Thu, 22 Jun 2023 10:42:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DCAB18D000C; Thu, 22 Jun 2023 10:42:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF4AD8D000D; Thu, 22 Jun 2023 10:42:57 -0400 (EDT) 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 A9E328D000C for ; Thu, 22 Jun 2023 10:42:57 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C7DEFA0BC7 for ; Thu, 22 Jun 2023 14:42:47 +0000 (UTC) X-FDA: 80930650374.01.C731AE4 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf10.hostedemail.com (Postfix) with ESMTP id BDBC6C0009 for ; Thu, 22 Jun 2023 14:42:45 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=none; spf=pass (imf10.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=1687444965; 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=RSoTM1LsxTuhuluqju/tIeLVsAKwQnd+CnuMIDbAx3Q=; b=b6j/3tivsoYsuFkpUDn1kRuCuY2LvJ3vzlvKKA+e/k9135zg+sNDxGvM1hSFuf9REPGiYt B63SLd9hnFKHmgj9CDtdXdnzDliLOa5DKnDHTS8aZEIgxHXL3Qb2dqGhzDmH6GhxuppYBm lcHwSB7JYM1APzkWXhzykk2GXv+e8a0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687444965; a=rsa-sha256; cv=none; b=tIJEehYxtHIbQsLUsnYG++uuBmVG46T6gdvoOch5JqgeNJ4QAXimRJreyCsgMktza3H0bo 3AgMOiaCVbGK9k4AaGad0gi5KkPAq0wbfEOI+DRGeteiE7QNTkwFcAVw9wYA6Clbd9stXw h1Tmu0I8NhgRWKM9DgGvIqSHUbKZWjA= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=none; spf=pass (imf10.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 C707A113E; Thu, 22 Jun 2023 07:43:28 -0700 (PDT) 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 431FC3F663; Thu, 22 Jun 2023 07:42:42 -0700 (PDT) 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 Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v1 06/14] arm64/mm: ptep_clear_flush_young(): New layer to manage contig bit Date: Thu, 22 Jun 2023 15:42:01 +0100 Message-Id: <20230622144210.2623299-7-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230622144210.2623299-1-ryan.roberts@arm.com> References: <20230622144210.2623299-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: BDBC6C0009 X-Rspam-User: X-Stat-Signature: r5qnmydx8apofgindt9w3cgumsgo4q7r X-Rspamd-Server: rspam03 X-HE-Tag: 1687444965-697583 X-HE-Meta: U2FsdGVkX1+OkSsuD1c2ussIjJii7D0qs3sDbjUsmHeiJ13cCSlVNXDZ0+QQN2IIC4NFo795nyKZ3qM8nlweHZ/fir9b6lhs71wGzWhaTgNwzpmrYJPzsRCcLwGB8TVflgDC+DXVZ7UKTOESx5bIqTwoUxGMbuXOYCgmPiH8mMYNtEACJy9KWh6jGJNf6cLsRlij0vNVNVvyVIcbPOhoXqvCDXjiVATWcsj2qOW7DpJCnbemTodpHyljGnfIBYGp0gWdh76rNCc5zbsldoaGm1rzlvwpd7Qbs7qfC/leVEEW5AcPuCchu7Wr1NNvbL8D7n3+MmiUxKcxm+KIO1/vM7jE5bKrcqJO8R3w/6SpaMEtFnUfZE32p3wngDeaNBuqPOc1VcD+4n5Jr7vuBiqNXzPujkoAKyTpgYybeI0F/AUEtrvdNtHWN6ZFa4TKPI1vWz83x/+Bw4K41ia79Saj3R15FTLYGFY1Vx3af/7EIw9sbZanPNLagBYMJfcLZY1sD3/t9sPEqN2t0EwGt4U5D3GaZ8tKVBhdSyWAiDimxfpppVorO5AdQccUafBbxoGBwL4iSCRhtxr6E9edTsPqlf30jv02GxCqg7Kx87tzvV6qyHh/fs57kBeyU9lmoXoZKtYmagyXK6wW3Wy4ET1nWzKbpQYfcvviKSHFtq6MS6JEqK0+2nWZt6aWFtnMRhj6DoVrHaYDvHAarnWHLos/sePkifRUmgbLfxkYwNoHsKdaxJPYRvcOgHbcHLAy796gM5Xq0SdsrUtBIBhyBjN0OAERRN+Q8HNw/NjzbNOD6Pe8yjfFBgggxJsCCtGzCi4DVj8PvwwC05bvD8MCMbPzGHxX9gzVqY2BwHQskBRuzAGgiPY+uDMbdtBJfyXb+RSFIBFghJfHLxROD9JSqBlKYkAQF0fTdVIDziuk1V8LLyJhF1YHWEk6ORzerU5zHiD80D0HUjONwjlPYlK04yN s3d/KxTy aihde49ubXowjC6az23IgA/dIqKvirnWrVfBqxjGDyXL7AgTJvKV6YxT1lwQVweOqBIBXSeztjmZMdluxKN0Aduooadgrty/oFU4ZQWUYipjPWnN+oDQL44SzhfVBp0eT/ZTNkUV9usYs7lPSjzpHkjWMTsAg3JdBTeZxH5HF/ZmzWRPbnIIkXTWTmH5cHOPJl46yIyZSgObBp8XD2k4mlSee3rmuDXZhmak5oLQge7znsh4Yupw2CbNCXk4r1yKvIXc615ikt8G1GdS5W8U9jYlOSQ== 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: 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. No behavioural changes intended. Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 1f4efa17cc39..450428b11c49 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -137,7 +137,7 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) * so that we don't erroneously return false for pages that have been * remapped as PROT_NONE but are yet to be flushed from the TLB. * Note that we can't make any assumptions based on the state of the access - * flag, since ptep_clear_flush_young() elides a DSB when invalidating the + * flag, since __ptep_clear_flush_young() elides a DSB when invalidating the * TLB. */ #define pte_accessible(mm, pte) \ @@ -904,8 +904,7 @@ static inline int __ptep_test_and_clear_young(struct vm_area_struct *vma, return pte_young(pte); } -#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH -static inline int ptep_clear_flush_young(struct vm_area_struct *vma, +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); @@ -1153,6 +1152,13 @@ static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, return __ptep_test_and_clear_young(vma, addr, ptep); } +#define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH +static inline int ptep_clear_flush_young(struct vm_area_struct *vma, + unsigned long addr, pte_t *ptep) +{ + return __ptep_clear_flush_young(vma, addr, ptep); +} + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PGTABLE_H */