From patchwork Wed Nov 15 16:30:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13457060 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 F09CBC5AE4A for ; Wed, 15 Nov 2023 16:30:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E0056B038C; Wed, 15 Nov 2023 11:30:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 88EB66B038E; Wed, 15 Nov 2023 11:30:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7562D6B038F; Wed, 15 Nov 2023 11:30:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 63D626B038C for ; Wed, 15 Nov 2023 11:30:52 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1DD11C0340 for ; Wed, 15 Nov 2023 16:30:52 +0000 (UTC) X-FDA: 81460727544.11.259C683 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf18.hostedemail.com (Postfix) with ESMTP id 040BC1C0027 for ; Wed, 15 Nov 2023 16:30:49 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.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=1700065850; a=rsa-sha256; cv=none; b=RuSwiJ/qznr2ENdaT1vA3hTj+PedMwUtLFq5ekQBfhr2M+bV0EcRS42/Ni3nFJ8zeMTtdP kH8k/pAJMJZhh6dEJKneQCbSgt+mdZ+6NgtcjvHkjDM862eJSGRlNhejasUgOBDQvpngDc lQu50NI76skvWxdhex7S16ypgz5wGRA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf18.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=1700065850; 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=g7RKJubwZGuwzYxXs5rxmgWa6Yt6X+DHtCiVrTsfCrg=; b=8aT7WyZ6TYfwz7WTvV13WYVxwEjojtYxy9x4ZeEEhMXT5Ov1WWl1mgmWALTkFVX0+r2Iz3 DrwVjWP45mXLYjB+MOXtuD1SwYdIn5VMFpJQA+ks6+07huA8upDnidxwQk0SFMkcfu9cpl +PK7llrwj58ASDvNWUYl9ZGqDq2pHYs= 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 DD98E1595; Wed, 15 Nov 2023 08:31:34 -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 2F7823F641; Wed, 15 Nov 2023 08:30:46 -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 Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 05/14] arm64/mm: ptep_get_and_clear(): New layer to manage contig bit Date: Wed, 15 Nov 2023 16:30:09 +0000 Message-Id: <20231115163018.1303287-6-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231115163018.1303287-1-ryan.roberts@arm.com> References: <20231115163018.1303287-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 040BC1C0027 X-Stat-Signature: pgp4uo3qqwtngkwf6urmk5xmeynbdfpu X-Rspam-User: X-HE-Tag: 1700065849-272628 X-HE-Meta: U2FsdGVkX18B1UV1Sk32JpDxV1WESQDiTUlPMTlFgAhXPPZJixg6e9Nmo3/XrSGg3fS1fk3sOQvopTPzXOg3YIOWvFDBGJhWu6p5JcHNBcTIVlBSvnX1zmUm6jrL5X1iwJRiJCm/nKFVv+LuxJgTe+e/egRZagp/L1xmSweWoa43vp5K6FV6BElBPuISQq0ubUGbKO2KzbKMt2bELn/34b498SB5aQQV8Pv83Toa7emYRfWtjucj2D7bbaPuUsb1WC+rOcoPvsCAn4+RvXtNOyh9FbKH+KeqqDVMuf93SbKoGpOY1u+045ysvocnePsbjO1GRkoEmVfCdgaj1FqX62o7accIWKgKD9zPPI143ccYMsCmC2yciu/LoYVh3EJsRq4Dp+HbS3ee7WNghtgV7XOirKYP/tNqWXnw/G+SS79IWZu2WkIL/YN/+EogxH1HBBh5Y02jYqZqJu1OAqJmc8ulRBMD1EEHM7IHfyogi85RJuFzQy9jSWRFOLSM3JcNDM/aU+Ow6Q03egaRhTyGowc7adZvMJEHFdD06ae0fBlUqOVVX0erAIoW5oH+97jDzbPMS9hRdWXPvyzUz2eRX5wTWo+XIW5Jt5LAh5vLDM27BvH/2FW2D/lHSf4Z2Fncgva472ZTJugsADEePYFiqjxwWD8wfkP5JAhythApF2LG4rqVx2fLXLBZbocJYGceHTvOk8XMSH2uqcbjlwo/8jZB89jRTcXrfr0RuT/WWMjUkBFoU6shptih/n/9zxUKKUFoLzQ/Xyo3as8AqCnERS7OdY3uM5fT9J8obDLaTdKLdpUIyR5fnUkpHxQWM928O0g5Gkn3N4xDzkWxVQ4gEhstYuQcp6GwkhIqQ0xtor4zXu/mCCViz7fgkdAT+NBO4dsKA5G5Z4enMqI3ixpr0UuGuyMzfSRkrb1WGwrOOmdxmOYz7wxnqQdshbIZUZ+ft7fMWVFh2vDh6W++A00 AB6ob3Ro ZKeDFIP8Mp3duUYmSeLLm1t9PoeoqO+4AFCaQDRbGi3Io8TUbSSH2Jh2f2Chc+OP9NBFzLQXosUeTEB9iZEznng8Gr5uVXV1VFGD2fDXeo5lI9IqvMRFB+c0XrfyPTE0KQwuJzoS6Imx4qhpETC4qwMkGpBjMwpyNKS40CVHI9EDujsb3x0vNjoadrKiNWjEe8R3fXyrs/SlU7SkdkJo+Gq8zIyd/r2QjINeH+4H1fVHIHEnIqc3ZvW8hELNZ6aVe/Wy3tMENCexaarStZiE4+3BIFA== 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. 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);