From patchwork Mon Dec 4 10:54:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13478193 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 6E77FC4167B for ; Mon, 4 Dec 2023 10:55:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 02C2D6B02AC; Mon, 4 Dec 2023 05:55:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F1D076B02AE; Mon, 4 Dec 2023 05:55:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DE4E66B02AF; Mon, 4 Dec 2023 05:55:31 -0500 (EST) 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 CF2D86B02AC for ; Mon, 4 Dec 2023 05:55:31 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id A6D70C01B3 for ; Mon, 4 Dec 2023 10:55:31 +0000 (UTC) X-FDA: 81528829662.17.D8BFE93 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf26.hostedemail.com (Postfix) with ESMTP id F03EB14001C for ; Mon, 4 Dec 2023 10:55:29 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf26.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=1701687330; 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=2IQirIHWGTN0C5ucPumITjyI4YT5MYNWep5+T8WG/E4=; b=LHK6A9PSaFK2TIUKq77IpIb8Oax8AkHtjWy5ymCt2YNmSCXGSv3jZ19n0FAcq8W6g5xcAI 4i2UfRymtUyMX7/jPHarylvS1TmGUPvv1IrJgWbiaAGh8P1IJ3UySL4xeEPLXoGfuDmJun tBdLHAwes73zWdv09ki49xsosP9kryU= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf26.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=1701687330; a=rsa-sha256; cv=none; b=8QKyJU++xEXS/omZhyqAaHGY1vzgNJQzsbr2meHFktkyOHbbXZhFay5nTCWu2PJEoRLx6G z+LVkEwRA2l8pBLzQhgEz72/ZJ3zyFY/x5G8omQGnGiT//JlbU/RcXNODfiiQwXyAAfY64 J256SPY/gp0poilHRfmrHLYeHKDVCCA= 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 8C236169E; Mon, 4 Dec 2023 02:56:16 -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 D844F3F6C4; Mon, 4 Dec 2023 02:55:25 -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 v3 09/15] arm64/mm: ptep_set_wrprotect(): New layer to manage contig bit Date: Mon, 4 Dec 2023 10:54:34 +0000 Message-Id: <20231204105440.61448-10-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231204105440.61448-1-ryan.roberts@arm.com> References: <20231204105440.61448-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: F03EB14001C X-Stat-Signature: qtsobpexsjeumr5teeeb4f1yt1xgp9ts X-Rspam-User: X-HE-Tag: 1701687329-497280 X-HE-Meta: U2FsdGVkX1/PULnP2x0arf79hsISNrNUotMtAUREe5+MZYKLWZkWZlR/NhydVF2UJ9GlUB7bc9VtS4fJMoh4JVly+35EHXbIg68n0BHtFd5fYT6mBrrEelhjYUtMq+9XUnEvtODqQlMXtnFPWqREM0DaLlgCuE7ZJlrrK0R8dxzFC+vDQ98eaKhnHEN8L6nA693beYCM4SQsGlW6B/w1iNRrBxAAyJF9tcOrqlPiMhW+aAYoIXEe9EPtrT+7JP5Ei2LVS+gNZfn60GObJMqrAYXp9Ud7spCwY+/R0Gtf6xs2MeaOy3IIqfSLaswR2dYnxA5S7VrVS8uUA7+/SGMYKzL4x4Ff21kak920C49dm4VUKj9mtp9QgyZHdSb6Z9Qua26Ls6VItjyyWGNpYz2dECK14iPn0e+CSkh2+eAXDcxqObA31IdsBWVlwNVqYl0ReKJ5l8lince04h+HkLbtUXJ3ZHSnk3jjXL6u9tVxzOar6DIZo+MV9ScyC0x5irsb5mL6JKLmXWe4Qv3u61Eu3gCZdgi/8mx1EsPu7/wUVVElhQGIcgmOUDZ9+2frGuxkM1Kz5i+9Z17i3iXOUT7bhlPRQDEbbuoAk2YArhsNv8X6CHQDTNrPotGGqmeDHde/6Yt7hZlPKpHJfKUjRUWzpQLHlNrTn5Vfs9l2ehXygLMBqJKEcQC1CzCvLM3OJ1NCiN8G1IToGEupluZckz4THyQGsd5DQRiZNpGICm+wR72cy7DQ3m0l9Gn+0E4++y45++xtWckZsqK8qam9GT3WIoQFIfN0e2RuZah8recUyyPwRUaypgbzezUCL1/t4MWp3G+vTaWAhZndm+4ptJXF/6K60CG4raquiqMF058sBi7/nv5//FVKr6uG0ddvzsxG1gRqAA5rVPDO3YofkyeBfSFHIkslQOORBVo9R4MvbaLc1vzbD/YcdbHvH076t71aK1+Qogc2HXg1zgTxruT g7qkTRKI FO07pnnTWXUETOffCnuXp3jGRkH7uhpfDsqwLdHi/N0wQZiYz4eKiUO3UA/8lti3eoIaykD+aMbztLdSFQJC7PUcDB1e4X4rpEWgzlosSUsczlpk4WzZYVXZSMO6hl1NKVwzhg9jhb+i5y0NMrBiwW3j2JYl81uUH4gzi7SpZtOMInS2eORR6WzU2QORgPDTqwcALWjNnRuz8HIxyWHCDvR/ugxJdtgZgTwzrLM21ouofJw8ATNDlX035U1H7XQlbW/7nxMDu90tw1symK7/aJhhtjA== 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 | 10 ++++++---- arch/arm64/mm/hugetlbpage.c | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index fc1005222ee4..423cc32b2777 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -958,11 +958,11 @@ static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ /* - * ptep_set_wrprotect - mark read-only while trasferring potential hardware + * __ptep_set_wrprotect - mark read-only while trasferring potential hardware * dirty status (PTE_DBM && !PTE_RDONLY) to the software PTE_DIRTY bit. */ -#define __HAVE_ARCH_PTEP_SET_WRPROTECT -static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long address, pte_t *ptep) +static inline void __ptep_set_wrprotect(struct mm_struct *mm, + unsigned long address, pte_t *ptep) { pte_t old_pte, pte; @@ -980,7 +980,7 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres static inline void pmdp_set_wrprotect(struct mm_struct *mm, unsigned long address, pmd_t *pmdp) { - ptep_set_wrprotect(mm, address, (pte_t *)pmdp); + __ptep_set_wrprotect(mm, address, (pte_t *)pmdp); } #define pmdp_establish pmdp_establish @@ -1120,6 +1120,8 @@ extern void ptep_modify_prot_commit(struct vm_area_struct *vma, #define ptep_test_and_clear_young __ptep_test_and_clear_young #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH #define ptep_clear_flush_young __ptep_clear_flush_young +#define __HAVE_ARCH_PTEP_SET_WRPROTECT +#define ptep_set_wrprotect __ptep_set_wrprotect #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index c2a753541d13..952462820d9d 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -493,7 +493,7 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm, pte_t pte; if (!pte_cont(READ_ONCE(*ptep))) { - ptep_set_wrprotect(mm, addr, ptep); + __ptep_set_wrprotect(mm, addr, ptep); return; }