From patchwork Thu Jun 22 14:42:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 111707 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5129074vqr; Thu, 22 Jun 2023 07:58:30 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CeaQCnFOy+LfL3kLi1RNkWXJ7hrqt4FjOo8Kf+MIBuEZXQKibO6E1QrrcVmSxHVvp3qMk X-Received: by 2002:a17:90b:11d2:b0:25e:aedf:e82b with SMTP id gv18-20020a17090b11d200b0025eaedfe82bmr17731064pjb.15.1687445910410; Thu, 22 Jun 2023 07:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687445910; cv=none; d=google.com; s=arc-20160816; b=r5EofLfVUmhctXJtK9UdFh5AxW5b4XXm9trJau/+JOVHhgym2uMFiOaMGtb6w/0rRo hODoaQ7dKiIm6xN3NGxnGnypeCxWuCj7u36Q1tucCSDyCOGo452CsL2U7dYW2wMonhb8 wpsxbRQLGXau+a/0FXFKsX5+yy2ZRPJPWJM4QgRcvqRh0nLsP37IDtvlNVchY7/1uUUf usLEyOenlw/RU4mPHXigaf0IeIGYmQHqvD0sYmHyb1MNodyWGpoyG3VL1q+N2arN4FDz TPt/inndLZmvFf8NoQmZjG2aJ8ELjI/0S70P8ZEIvzKOt0mpFaUf6EiAi6+63bloq8zr Nvow== 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=IEufNZScMSs5MVwG9Ps+h77UK8rEp6c++7KnxZ9ZyzQ=; b=Ri1uFy+UH7G27NH5GJ5AYwKy3QtzMsw5OhugbWBHIhWEAl7b6PLs/pLI/5ub93IKcR wUMpYOTwP6JDiLDspQq2Kg1so6WAHtUvgh4/93jjUMm/UyeLULhJqNZy107gL1qrxpxZ HHnv32xr5CVFWlMN9yWP8zUhfONSFQUaQlQ2JRUTenv0H7XvW9gf3cWFn16xr/Wd8ejY 4K3u1Q/dEZbODHCJ18XLpnsW3w3vig+WCr8bP3aqHIPgjz1VFLhIUnfrqaBlKDqnOO53 CYxm9RTpF4y73OGRjnRVszsurywTpd0fk4r3uVSCOkgm/BU6/z8Rl2w4zEit7j1+dLLa +kHQ== 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 mv12-20020a17090b198c00b0025baa49fa95si6810636pjb.1.2023.06.22.07.58.17; Thu, 22 Jun 2023 07:58:30 -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 S231820AbjFVOnH (ORCPT + 99 others); Thu, 22 Jun 2023 10:43:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231653AbjFVOmt (ORCPT ); Thu, 22 Jun 2023 10:42:49 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 532111FCB for ; Thu, 22 Jun 2023 07:42:42 -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 EDA091042; Thu, 22 Jun 2023 07:43:25 -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 6998E3F663; Thu, 22 Jun 2023 07:42:39 -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 05/14] arm64/mm: ptep_test_and_clear_young(): New layer to manage contig bit Date: Thu, 22 Jun 2023 15:42:00 +0100 Message-Id: <20230622144210.2623299-6-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?1769415282956343884?= X-GMAIL-MSGID: =?utf-8?q?1769415282956343884?= 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 | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 2a525e72537d..1f4efa17cc39 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -887,8 +887,9 @@ static inline bool pud_user_accessible_page(pud_t pud) /* * Atomic pte/pmd modifications. */ -#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG -static inline int __ptep_test_and_clear_young(pte_t *ptep) +static inline int __ptep_test_and_clear_young(struct vm_area_struct *vma, + unsigned long address, + pte_t *ptep) { pte_t old_pte, pte; @@ -903,18 +904,11 @@ static inline int __ptep_test_and_clear_young(pte_t *ptep) return pte_young(pte); } -static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, - unsigned long address, - pte_t *ptep) -{ - return __ptep_test_and_clear_young(ptep); -} - #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH static inline int ptep_clear_flush_young(struct vm_area_struct *vma, unsigned long address, pte_t *ptep) { - int young = ptep_test_and_clear_young(vma, address, ptep); + int young = __ptep_test_and_clear_young(vma, address, ptep); if (young) { /* @@ -937,7 +931,7 @@ static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma, unsigned long address, pmd_t *pmdp) { - return ptep_test_and_clear_young(vma, address, (pte_t *)pmdp); + return __ptep_test_and_clear_young(vma, address, (pte_t *)pmdp); } #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ @@ -1152,6 +1146,13 @@ static inline pte_t ptep_get_and_clear(struct mm_struct *mm, return __ptep_get_and_clear(mm, addr, ptep); } +#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG +static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, + unsigned long addr, pte_t *ptep) +{ + return __ptep_test_and_clear_young(vma, addr, ptep); +} + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PGTABLE_H */