From patchwork Thu Jun 22 14:41:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 111712 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5130042vqr; Thu, 22 Jun 2023 08:00:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6KsTmzKQRay0dYwhhyr2UetPPMUSvBq4GC9ylhY7Kwn1E4WxG0ZxQE5X26n5w3Tr4DF2Nx X-Received: by 2002:a17:903:1c7:b0:1b6:9bf3:616b with SMTP id e7-20020a17090301c700b001b69bf3616bmr4604343plh.23.1687446003733; Thu, 22 Jun 2023 08:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687446003; cv=none; d=google.com; s=arc-20160816; b=II7f8Gq6B6JaZal08gYbCbbaFofDKv5ZfKLULfg6eWQsOimUjYp7HiRS5byM5VsOGO AP77qsXFD9+Y3Q39DAMQTvIbtLuo0H3dcVCYrCYQsXOhrasvQ156GQVJ11qX1n52Pdq0 TsT56yllReOQUbJ94cySvX3QwnuTrmIo3KB/iQs68gBPeYm/N1GDiYkZTNkA3ZKQgmlY FHSuG+W74gIZPjhCl35aSQEBamaX9mVKVlPTKpjaYg+m/AhZFp495oKQyPmAxOw+RbNh s7Y5RptuPPurBOaIrPqBmT34zs+no6l6JN3OaJNDUvvCFD2hVIXCOqAXZ1pnTyhkMjlq 1pNQ== 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=AS1XtnxRscbzxA0kaRz9FvWsJTVqgcu/WVonKiamoVo=; b=UPIM04A1ipcqc+OMq1hJCdRmMBOLeV+S6cLKtR450c+dSg2ee61oVqjtetZ0XRTzqb h6FyEgJF7nxgmBvDN99CvvI4gk5Ym5/YYBTE8GrcIJI76z84nEjDO8aztOn9Av4qhjj5 rSbljImGaYosUqotXgwOxgX9ITO/qspPbzJdNae4GiXq3iItM6Yx019HNwowqAw/YI0Y s2PwbPBRQRtpcveS2rfxRCLJCJF+ofQdGa9zcXzvy5/kTki4znS8PC2xddB5ccLQeUHt yk5jQC9wJYxRnHMEJs3Ksrlsis223XogXQSz0AbJ0tRhXRCYZpP+IhB5zZaXcJ1iNEBG J03A== 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 a21-20020a170902b59500b001b3d822f131si6539673pls.239.2023.06.22.07.59.50; Thu, 22 Jun 2023 08:00:03 -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 S231748AbjFVOnB (ORCPT + 99 others); Thu, 22 Jun 2023 10:43:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231725AbjFVOmp (ORCPT ); Thu, 22 Jun 2023 10:42:45 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D4C851FF6 for ; Thu, 22 Jun 2023 07:42:39 -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 200F6C14; Thu, 22 Jun 2023 07:43:23 -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 8FFBD3F663; Thu, 22 Jun 2023 07:42:36 -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 04/14] arm64/mm: ptep_get_and_clear(): New layer to manage contig bit Date: Thu, 22 Jun 2023 15:41:59 +0100 Message-Id: <20230622144210.2623299-5-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?1769415381040981358?= X-GMAIL-MSGID: =?utf-8?q?1769415381040981358?= 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 | 10 ++++++++-- arch/arm64/mm/hugetlbpage.c | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 06b5dca469f5..2a525e72537d 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)); @@ -1146,6 +1145,13 @@ static inline void pte_clear(struct mm_struct *mm, __pte_clear(mm, addr, ptep); } +#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +static inline pte_t ptep_get_and_clear(struct mm_struct *mm, + unsigned long addr, pte_t *ptep) +{ + return __ptep_get_and_clear(mm, addr, ptep); +} + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PGTABLE_H */ diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index eebd3107c7d2..931a17f3c3fb 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 @@ -429,7 +429,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);