From patchwork Thu Jun 22 14:42:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 111698 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5123328vqr; Thu, 22 Jun 2023 07:48:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5gs98W278/ZXzDqDWfDXwWcJiZU3kxLD5uOADsNpIyu8aL1Kph2uqeLtIGn1SULgWRIjFv X-Received: by 2002:a17:903:2451:b0:1ac:a6b0:1c87 with SMTP id l17-20020a170903245100b001aca6b01c87mr23865717pls.48.1687445308405; Thu, 22 Jun 2023 07:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687445308; cv=none; d=google.com; s=arc-20160816; b=T9LSH1Ixi5G8FJt6GwSIpgFQcCPTi9u7zPlC/hsXtGFUl7vWHV2KmRlEYcadlrPD0u W734BmOpD3FhcFMSwHO+gwOSnxFx0HKhHKcPE5aC77Y9nj1ti027A3ZDU0SSucflc6OU 4PphyVOZvl9fBIVQVLfGpXk24WA9Kk+bLcaWVKLMJV/lK58nGnDJ1HGdtqAI7Tuf/lTM grhns6US1pgfqloGJVIH2FFy6AKO5maIqdSpGLi1Blls++4wlO/ik1igs0w75UoCCKlh f4Ssi332bov3rITWRAm72Nbx1zHZdJ1vcxNgBLv3s6TX4VLnr+Due2emPdqwU2H03gTr fOtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=LGmsfh5ujWnepK3ZoOUTFN5hSel/MimSSYZZvfFi/dY=; b=yf0yLgMonG7rtCwv23vfBGM3p6tSUr4H9mwKNwdrWUHgD37/zIddchr+J+yiYIXD/w LJLSqzQ1mcwXT+AoG5BHUpmSjWdTASVIddR2wv+MWg4hzQ1Q1GN6Jbw8JB/Z7MF5aFo8 1ZygAKofFvhYgwb9a8rRnOcxnxr/VPMqiYpiwshOF10MBvvfzWbFb4YasXoA6OBcYbgZ FYsRw/oL4Hbdh4fU9DFBJsdL5P4zh9pJM1eGOLEllXH1ddyDwGfu6qsCuKYflTQZJNH8 3k3+UoqTFE0bZxds3Cmc7it3iRWd/z0xnK6kh6ASxJHfF9kOTCyXe7UOt1X1+M0IdTIp qhZg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a170902d88e00b001b51183cef3si6542624plz.214.2023.06.22.07.48.16; Thu, 22 Jun 2023 07:48:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231777AbjFVOnR (ORCPT + 99 others); Thu, 22 Jun 2023 10:43:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231791AbjFVOm7 (ORCPT ); Thu, 22 Jun 2023 10:42:59 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 05E061FEF for ; Thu, 22 Jun 2023 07:42:48 -0700 (PDT) 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 A0A93C14; Thu, 22 Jun 2023 07:43:31 -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 1CB8C3F663; Thu, 22 Jun 2023 07:42:45 -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 07/14] arm64/mm: ptep_set_wrprotect(): New layer to manage contig bit Date: Thu, 22 Jun 2023 15:42:02 +0100 Message-Id: <20230622144210.2623299-8-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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769414651210656268?= X-GMAIL-MSGID: =?utf-8?q?1769414651210656268?= 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 | 15 +++++++++++---- arch/arm64/mm/hugetlbpage.c | 2 +- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 450428b11c49..2fcc3b19c873 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 @@ -1159,6 +1159,13 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma, return __ptep_clear_flush_young(vma, addr, ptep); } +#define __HAVE_ARCH_PTEP_SET_WRPROTECT +static inline void ptep_set_wrprotect(struct mm_struct *mm, + unsigned long addr, pte_t *ptep) +{ + __ptep_set_wrprotect(mm, addr, ptep); +} + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PGTABLE_H */ diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 931a17f3c3fb..7d5eb71db396 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -511,7 +511,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; }