From patchwork Thu Jun 22 14:41:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13289252 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 BBB67EB64D8 for ; Thu, 22 Jun 2023 14:42:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5671C8D0008; Thu, 22 Jun 2023 10:42:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F16D8D0001; Thu, 22 Jun 2023 10:42:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3902F8D0008; Thu, 22 Jun 2023 10:42:42 -0400 (EDT) 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 28A318D0001 for ; Thu, 22 Jun 2023 10:42:42 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 05D281C785A for ; Thu, 22 Jun 2023 14:42:41 +0000 (UTC) X-FDA: 80930650164.23.713D757 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf14.hostedemail.com (Postfix) with ESMTP id 22437100017 for ; Thu, 22 Jun 2023 14:42:39 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.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=1687444960; 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=AS1XtnxRscbzxA0kaRz9FvWsJTVqgcu/WVonKiamoVo=; b=PjpItEAcPAMEgRhJqDN79tYlRmf0T3d3gGa4gzsAq4KwHSVFoN2A44ZyfZDodQNb3ILsiu W7TdrOWcfIIB7trQRDJAnqowEcZJyTLBJ7l1xQhk9qv69pz08T1cCMH0OFUzb/dMJ9WGAd tkWLN4IKu3rV14R8FgIeJuHjI/BzHVs= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687444960; a=rsa-sha256; cv=none; b=dyILnZ/oUXMRfrVPU+IqInCCDMDkRy3vede2x5Exing9fZofF/gh8q4gHq8HDNoypZfkrW uC49+8hKa4L9pC9SwuHiCH2P2N+YgUg+xwGN3F37QXNwyKSp2LhAkBYIyz9sA35fnzRHkU cYoUwB5H3FbbyBxdrtwPIkm0udiRURs= 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 200F6C14; Thu, 22 Jun 2023 07:43:23 -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 8FFBD3F663; Thu, 22 Jun 2023 07:42:36 -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 04/14] arm64/mm: ptep_get_and_clear(): New layer to manage contig bit Date: Thu, 22 Jun 2023 15:41:59 +0100 Message-Id: <20230622144210.2623299-5-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: 22437100017 X-Rspam-User: X-Stat-Signature: hjhpqymhzoycipgkd3ijkkkumd5fcnt9 X-Rspamd-Server: rspam01 X-HE-Tag: 1687444959-957302 X-HE-Meta: U2FsdGVkX1+Zhr75MKx+baeBOdOywKXK4oJpE+FUujAbPEDLPYiqvr3N4lLruQ0M0GT3WMC/I0ppXA3BdEv/2/dsbDNNl5QWnQ7/+VF4HKBDrIageuUCLQB0mK3cTvt+GRNcSPhVULx/m2DBvAJu5wl0SwNZvxbmPKVPI5XKi6DF7njEcjJLW2BU56XtKHlfziGqLMZg01L+kZ0qJf24dAbkBvbU1MLzbzObWT4dSFkXAoUhcrDUKQ4CwH4QcbtOUBhVkrUQ7Juv9au/f6MYIpZkjrksSuk6PGzAmgoCjfE2p/AQR+8pdPvhej4UJvuFNl2RkL9MD4R3t6t28OoFTx7WX62taXx5bdJgeYPu5VhVclV/UW/U+8D+2qsX5bgSUeJdn8pIaUUk+n5zjCFLKbtDwf/y9/oEivXxxERrNgD25BJ2JeYw0PVcKmVKC3qtfCF2yM8nQQWL5HQygjSwZ7/aHNGL88QE04TIAKGLxTD2dxUQ3WZ6I0YYMTi1bYr7fBZ0RHx1LOdfB0bzhjvX1b6helHxzdxkeR92cDBvTAwKdRWwT/wUB+AuSlluLYtBHL9g4lQAW3GNXx9fWz+kR6TinaM6x0qfaAlC0cqSyGer0KXUvfRezFP6rVhlv0PZp0fgCCPIpqc/7bFVPoNO8LgnIvhr0xMvQFL/suBD9V+WZRoNmEl+tTv9xBTnUqPBhs4mALnGorEl/pZEmuz6KTYlmTmUS30a/4QHUkOFp9uG2WiY9nAlCDEOZRYP2EXNLebQbGfehMbibdMIBWOKjvHpZbCZkf8lkg7LADXpBpYuDXw02z3SAGGBrKEme9SwdJEd0WwsdyuAqJigqVj/84MRpviX1odrSifX56HWADw2LaO6XYaeusbWcT86iYxgG81HWN/wLDyMv4ALVbIlFxZ/FwEse7qbZdbBGUOEVbjONZUoI0MiZwAGVaZQvgwwfrnYwh57q7NrNP4OI8M YprG6WFA /IWAozMeD04Itm2eCv/mJWKDLfSvyWW37x6UJbSQfnjr55ehmD/Gxf1eXUhxwhcroxOzRtEf+NP7T84Jlw3iy1EX31JMfv5CUx1KjllY6/gRF5bmFT/UIOONYx6eAEmQnmeOHWEefkFCPjOSpU3tdlafKTIra7KrXl77J5O0Fc0XLMvgt9Do3WG70JWuBpcJ4z7ZXJO9P8FjyCBSNsiza4p1Sc6J4Xxtfw720affbIAFXqOwMK60HJE4s1N/OJFNWYZgHAr+LqNhxalCaq9P+XaOyiw== 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 | 10 ++++++++-- arch/arm64/mm/hugetlbpage.c | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 06b5dca469f5..2a525e72537d 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -941,8 +941,7 @@ static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma, } #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ -#define __HAVE_ARCH_PTEP_GET_AND_CLEAR -static inline pte_t ptep_get_and_clear(struct mm_struct *mm, +static inline pte_t __ptep_get_and_clear(struct mm_struct *mm, unsigned long address, pte_t *ptep) { pte_t pte = __pte(xchg_relaxed(&pte_val(*ptep), 0)); @@ -1146,6 +1145,13 @@ static inline void pte_clear(struct mm_struct *mm, __pte_clear(mm, addr, ptep); } +#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +static inline pte_t ptep_get_and_clear(struct mm_struct *mm, + unsigned long addr, pte_t *ptep) +{ + return __ptep_get_and_clear(mm, addr, ptep); +} + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PGTABLE_H */ diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index eebd3107c7d2..931a17f3c3fb 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -188,7 +188,7 @@ static pte_t get_clear_contig(struct mm_struct *mm, unsigned long i; for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) { - pte_t pte = ptep_get_and_clear(mm, addr, ptep); + pte_t pte = __ptep_get_and_clear(mm, addr, ptep); /* * If HW_AFDBM is enabled, then the HW could turn on @@ -429,7 +429,7 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm, pte_t orig_pte = ptep_get(ptep); if (!pte_cont(orig_pte)) - return ptep_get_and_clear(mm, addr, ptep); + return __ptep_get_and_clear(mm, addr, ptep); ncontig = find_num_contig(mm, addr, ptep, &pgsize);