From patchwork Mon Dec 18 10:50:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13496571 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 1382CC35274 for ; Mon, 18 Dec 2023 10:51:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB24B6B009E; Mon, 18 Dec 2023 05:51:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A61C36B00A0; Mon, 18 Dec 2023 05:51:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92ACE6B00A1; Mon, 18 Dec 2023 05:51:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7FB586B009E for ; Mon, 18 Dec 2023 05:51:46 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 5429AA25FF for ; Mon, 18 Dec 2023 10:51:46 +0000 (UTC) X-FDA: 81579623412.11.DA2E178 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 8CD1F18001D for ; Mon, 18 Dec 2023 10:51:44 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.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=1702896704; 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=p8TO3jSXlQIO2M/vTLXz8jOzA91p4UDOv06l4gwoTwE=; b=1mBXTKrwOnLr9oeqU1X+THwxCc3BljS810Eeza/mCP5Ag1AQavUwkUru8r3ufealpevROJ /w0J/IGQrNR8oh6EFNy8oNksbIO0KqI/6qX/2RnjxMF6QjJWWyrF9psL9tMm8168FQU9Dx u0SpAlivcXECKtb94NdFFEcMloBmpMk= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf24.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=1702896704; a=rsa-sha256; cv=none; b=2gZHQeyfIY3qPQ/AbQ0+jvifWcEIeV9nWuRlLALLAcQ/LhwaHt69E58rubl8tz/QhbaYNq TNaN7bO230m+C1pnxehQJ14dGJqp2o8svSgCbmTuR4qlsxJbWqts4UpErOGW2MfX5DQbXJ wr1m24rRkIm27pEVK/jvmEoI6cxB6co= 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 4AD001FB; Mon, 18 Dec 2023 02:52:28 -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 7132F3F738; Mon, 18 Dec 2023 02:51:40 -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 07/16] arm64/mm: ptep_get_and_clear(): New layer to manage contig bit Date: Mon, 18 Dec 2023 10:50:51 +0000 Message-Id: <20231218105100.172635-8-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-Server: rspam09 X-Rspamd-Queue-Id: 8CD1F18001D X-Stat-Signature: ieczexd7trju8rboui1k9p46d97n6c31 X-Rspam-User: X-HE-Tag: 1702896704-859837 X-HE-Meta: U2FsdGVkX1/IuFmhqg9+nO5D78FGmq2g0gG8f1vv06Wgg2b7comNOmgnGiiPosWORG//XK6b7rvBtwCghbExoxoqmixt0rEFb28+X3+n6/X9IjEBUX4X/oVklODD6BEOpYufJaL3S1eFFpkHVpeY+LM9QAQK1O8krZNbeThGkArmYr1ZcSb8EvSM0yESDl4UEgMzxsMGuUMcMjRMlXXrbiRw1QL9mCRgoYLhxiTkffDoq2GWau9hBGIraVW2genITc7TNyD49++KKQeLVsQPWbUdLDOGwki02TB2paikcOZ6c40wuDhrQaQw0VA/FC2VPsS7Fu8EB8MnJU09cnfWgqWxP9z3InOG2g2VQpjXH82LfVHQiaMDMjEYWWoEkgqjMM5h9NiRTzYjiYJ2QwoZqYAfXiXAR2NyNHT896dGOHukhacdzjwKgq7w3NqjKjLlo8k487xDVuCjiFbKwXoZhRsEwE9LTmxTV/1xqWRjIpWyadkiQxDU8O+TX+Oqe8sj2g4SbUbCAFV0vWpTLVqDItTHkJRJ1yYKJrj6l9rZzSgJ8IAghrn1xzcB+6v4U9tHECUZDRQqzt8md2ZtJojTS3wePi4NAlqHj4udRDMezfC0Hu8DZ5Z8AjEkRCY/dgQZNJ75BdrCCVRvtDvOxD1m17k0PRClvGh6EJWA3rRj5MiIdc9n3rgbnfizTsM35S2U6eNzJ0i4BGQK3xCknFghiAFIX+KngDDrEsYNHXKLiNzpSdKomBbmq4hC49WsT2qFz4QkMXy1bcvfPqMBof7B4BUP7GRkzOOYrmq0vXHTKtkPrv7BbWfHrsXMuKLbHvhkSWIurWGd9iiL8uLJSNiq8OVLbJM2BJiuBg4t7TgHXc0mCGFZubL4zGvlP5opxIztGQ54LBL33tmTY6knaE4p2Nr1A0K+SiylIt5kb3irW2kDgT60w0SlWaUPYkZanEL/01MJQ1n6+7TJgeKBJzn KlJuX9BY cAje383hdkwm1Xtu2Bhnc1goc7F79TOW4v1r44/+4Ns9tM7cyo7q08ZXWlODD2SUshLudpmQFCKRxBu0lhhS5xrfXBEy6EYV4k8aZI4D+4Udm4hJD9JP/bvP1fZuQ1zbx9d7ZSO5cEVEuGPD6nNwBAhQeC3rsxVB6tgXxAU/xRvEnGJOb1O3l2qDiN6ZAJ6UmJTZ5KNKvlrGDsuElKWDwX82X+56YofsOe6zHgJNWXeEMyfvlKMe3r4ca23bf21hE/f1Tee32g2n3iD7UkxBCm82b8N6i59XjNlU4xwwEdU2RsdU= 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 | 5 +++-- arch/arm64/mm/hugetlbpage.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 1464e990580a..994597a0bb0f 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)); @@ -1122,6 +1121,8 @@ extern void ptep_modify_prot_commit(struct vm_area_struct *vma, #define set_pte __set_pte #define set_ptes __set_ptes #define pte_clear __pte_clear +#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +#define ptep_get_and_clear __ptep_get_and_clear #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 510b2d4b89a9..c2a753541d13 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 @@ -236,7 +236,7 @@ static void clear_flush(struct mm_struct *mm, unsigned long i, saddr = addr; for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) - ptep_clear(mm, addr, ptep); + __ptep_get_and_clear(mm, addr, ptep); flush_tlb_range(&vma, saddr, addr); } @@ -411,7 +411,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);