Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp686741rdb; Fri, 2 Feb 2024 00:13:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvs/xFGT2UnsKbx4SpxVnc7fQiJ8DUrHd/rWzkGEy9uRxdfG2Z7orAfzCSbuG8cEO/8pnR X-Received: by 2002:a81:ad17:0:b0:602:cb6c:5121 with SMTP id l23-20020a81ad17000000b00602cb6c5121mr4941809ywh.31.1706861598337; Fri, 02 Feb 2024 00:13:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706861598; cv=pass; d=google.com; s=arc-20160816; b=WTTl6kFqxK3kZG259s95wQSeHYpCTJR7hI4TBOMrLyJTB7qdRSIjoZof1IcB6ws7dc oZYIEQnjsD+tGpd3CHwJRXSfDOClmCv4KhfVqBZbLczxxlUnNy2FemKXq1Z0YHe6ZxTk fCSne2KIZNpO/luUwyHcOyEMkKldFGoZpLFTEuviPneCylPlMgQA7DXSNa/UPGhnaS6y Fc2kLsphSIxCAxiajHGrj/goyW+dBr1tFsBqfGz3u5YAFqjlPYVPBBn6QkpOkIaJH0bo G3Dk5sQ+7Ba9fn672vy20k6A7NFzWKgOPp0feTwnZoTem1ZmWSpVHYJ1eNEL9mWITh5V Lo7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=0Nx3YcaR5GnneSzYgrn5cd9bIJsd379LdaU+eavGkDo=; fh=m3M3CzpvE6OksPUGv0JdQR+JDnc/pWHBXAu6635fzLY=; b=vyEimcomlVm/S3NPIi4inVV8Q9gZ7b5j2wHf4ueA+VIVEg0SJR+XgwqKDlYtLXZEC2 SGQUGawoMK6PjTDHh/pCJDNf7v9ELE5Lw1s09P4UIovuBY9u3l0DYv46KqIktYqBH15X ZOz4uvPcLgjSyaefvWht0uj0XmVQoikknlXjjhw8Ywk+ag/6ONVIhwaE+rvfjbkMiPrh giJXrIM2PyJVRk/GX7n5oj9+/O3yDHMtySSxb35C6Bzy39HQZK4HEkCchvFJT9Q9gvKz i84qcMkTc9sLU2tcHE8rKWjT8ZX33LCNUta7MiXdtarNwSR4xdHKGNCC5nEk+SI6vy8o o/Dw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-49426-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49426-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=1; AJvYcCVB/HPaxkATpfXXwM1bQT59ur+y57eTZvCF24W6Gxo4+ZowBVjJEsQU0Ecp3wGX6Jp8SpU7is6cU2vxkoHz820xKK/5A0TYo4ahiSUy4g== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c21-20020ac85a95000000b0042bf5d1400asi1452902qtc.343.2024.02.02.00.13.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 00:13:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49426-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-49426-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49426-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 464A01C29E0B for ; Fri, 2 Feb 2024 08:12:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4BB6482CB; Fri, 2 Feb 2024 08:09:08 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5DE53481DC for ; Fri, 2 Feb 2024 08:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861348; cv=none; b=U0yzrCvd6HZp4T9z16yOVKyGrF/2cHzy55Mpn9Q+ctSyYHxXU8Pp9nGDDlg7QljqX5hLNp1mnaNdUS9XRnANFcya9hhQymIP51xAMSJPMC5ca9WafDaIeuLv3+1F/69OjxFAtXqHNQhJ9qYfHG4VadIjR9PvZcAxm7BSPe+6LE8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706861348; c=relaxed/simple; bh=AG3StyilrRM5xxbk53S/sAlOGN0ZJ67ygxAh0JhYtFs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VyCpJ/bFCCGmtIgLfz70ognDK3WFEZLkjY4Rfns3VNETZYQi5KT1kKe0HFfwdWydig9gdbpHBIz6M1Uu+ouYBs2OuyACO6yMG1uNTzbs/hBJtL9uxWMJa3df7dXDG3qbR2zHBpUABn5nbCYqRxrAUqeCcyBrIIcaeH9cPMraSZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 426DA1AC1; Fri, 2 Feb 2024 00:09:48 -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 570433F5A1; Fri, 2 Feb 2024 00:09:02 -0800 (PST) From: Ryan Roberts To: Catalin Marinas , Will Deacon , Ard Biesheuvel , Marc Zyngier , James Morse , Andrey Ryabinin , Andrew Morton , Matthew Wilcox , Mark Rutland , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi , Nicholas Piggin , Christophe Leroy , "Aneesh Kumar K.V" , "Naveen N. Rao" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 13/25] arm64/mm: ptep_test_and_clear_young(): New layer to manage contig bit Date: Fri, 2 Feb 2024 08:07:44 +0000 Message-Id: <20240202080756.1453939-14-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240202080756.1453939-1-ryan.roberts@arm.com> References: <20240202080756.1453939-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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. Tested-by: John Hubbard Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 5f560326116e..77a8b100e1cd 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -899,8 +899,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; @@ -915,18 +916,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) { /* @@ -949,7 +943,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 */ @@ -1142,6 +1136,8 @@ void vmemmap_update_pte(unsigned long addr, pte_t *ptep, pte_t pte); #define pte_clear __pte_clear #define __HAVE_ARCH_PTEP_GET_AND_CLEAR #define ptep_get_and_clear __ptep_get_and_clear +#define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG +#define ptep_test_and_clear_young __ptep_test_and_clear_young #endif /* !__ASSEMBLY__ */ -- 2.25.1