From patchwork Fri Feb 2 08:07:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13542347 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 63A8FC4828E for ; Fri, 2 Feb 2024 08:09:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9C476B009A; Fri, 2 Feb 2024 03:09:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E4C3B6B009B; Fri, 2 Feb 2024 03:09:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D13ED6B009C; Fri, 2 Feb 2024 03:09:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BF04F6B009A for ; Fri, 2 Feb 2024 03:09:04 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 918C7120E67 for ; Fri, 2 Feb 2024 08:09:04 +0000 (UTC) X-FDA: 81746138208.26.F05990B Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf14.hostedemail.com (Postfix) with ESMTP id CD4A1100009 for ; Fri, 2 Feb 2024 08:09:02 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706861343; 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=ugmxcY8A+ihqkEHAUXwkD3Iz3A7BIhWHSuJUsSWcNFg=; b=C32oAZ5OGaR5D+fTxGECbJ8RPzh7tNcuT3QMJwu1MfFx2wH6jUYhTv0ZfWfuLAsMiiBuNd FVVAIPPRBi9Xr0flpzNnwepbjfEe3LeW4wJBD0+fUh6Gu3QFzY+RJ4Uw69ayokB2Q2w39C KQu6bkqwH+Kv/2nT95CeaG8WzoomqsE= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=none; spf=pass (imf14.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706861343; a=rsa-sha256; cv=none; b=prt2PlMc3oO9HPBIWk+Z2rj7ofO2FvKuvJPXdyrLt8xM4E78cIX4mRrWhsuu5hLkylpa1U 4UgMDdtA2QyR/yqzBslOJdvR+vS8CwfOY9s1hW2IE7efYgbGHfIF+/Dwmq1sCh+I3bblyF P06o2TzY7L9ROSjBth+WP1rBLeXTdOw= 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 70FC91A9A; Fri, 2 Feb 2024 00:09:44 -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 852FB3F5A1; Fri, 2 Feb 2024 00:08:58 -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 12/25] arm64/mm: ptep_get_and_clear(): New layer to manage contig bit Date: Fri, 2 Feb 2024 08:07:43 +0000 Message-Id: <20240202080756.1453939-13-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> MIME-Version: 1.0 X-Rspamd-Queue-Id: CD4A1100009 X-Rspam-User: X-Stat-Signature: 8z8pyri976iksgzeoxo5k7tmykysmn7s X-Rspamd-Server: rspam01 X-HE-Tag: 1706861342-242968 X-HE-Meta: U2FsdGVkX1/cYfnpvm4eXeeqYnV9oK6LZEfDtxLdPcHR/WMEWYBjnfm2ZHda1dyLmsvVh0UlVf/kV3My/GpgGFz893146kTM93tigDxI/gFqwNs3nguLZHgw5PYqaBhI+HVeIhvQXGxmL3DpxCK/Xjx8jH0WG0LZ7+aWlC0RZbY9j8kcRbSQviWZ+G2bxo0tvpS/msCgptZ5Zx4lLPAqiTa2wYQd65XOfzTU4bD9Tn6d8sTbIb5EoKOaA/6IV3xzIjzb0nRMeuZcsfYU5vZ7chnBVOQSctCt6NWMoevyn/pp/aK3eLXpUqGSKYMzsP+1dyGD78GyhM+eS7DgBKynfbSga3DMz3MXOtcTHVLBl4wNOBy7t2xWHuKnZFk2GUu0X1vnwBGlOizxc0Szpa/gwRrBR7bi/HnWmBadludP4LczwRklnGCMe2MEq+WpbQlOwL0tYJ145u9BHfOk3N3tNGXmeNFJ3K9mlLj5/swpIwcVFQf8aVUj+2za385407ATZpn5dCjcP31f6+SqigzRcLK7547E6rsCNUZs881zgxHxCWNLU3urKtWbVjlD0+DXLOJwz96qlADa+QGjK5bVEBt+PX0FS2nPRcsvhYWU4FNTmgBpbzdLg3Mn5pFkqBQ2R1csdjBDyYGAca/aUC9mMKFBkcd607OOQb3jaKzoQqDfpsr7yxBdhNByi3W3qlxOQ4Gg0l/dxPn2NbxDtRgDhq7/Suh1j84Xi+F0zOT0EaVMMQZQm9YR93NfUqfYLF6uLF/TFrtX2KK61Fe3PxPEc/VQNnzkDfM+8fwZBjtcHwGZm0eUxBOJN0ifL7R6gdGlCCiySEOY/tiU77bAaleBEmZYEuEV0oAnn5ZLyUkxxh1bQYeVQjLwQPP15iks2q/91CwUh/NcDosnRYWapLLPJgO/QhJq8nxB4iRCZbV+zCNx2iNQuSoWn5P/Lbnm7zGMFJ1PB7N7EI7XDLXlEUo QCqTEpA6 3+Yb89zIWiHCI6Wkq8Lnu5qrXbXIGaIlGGu9slJr4ate+Vbg2mUG5c96VxGBfKTFO4X1oNpyYd9bttWquDt/oxAkgK/W68erqetV+Qr2RjgjVLdzCAU8BMf+Ghav5CoRTWYTAXUxaQvZN3hPuZnsyVuR1RINBsUJvzeblIHtpoJjJHr2YY1xy1fEFL/GzVrtPkZqUyDdfyHgixdXb6yKb6/uRwUahdLl0P5QVwyKnwkGAfichBQAQBKCe591By4P8MxoBZ5OvQQY2QEryVCzY/eLZNVnQnoolbMr3P+G3+sytyis= 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. Tested-by: John Hubbard Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 5 +++-- arch/arm64/mm/hugetlbpage.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 3b0ff58109c5..5f560326116e 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -953,8 +953,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)); @@ -1141,6 +1140,8 @@ void vmemmap_update_pte(unsigned long addr, pte_t *ptep, pte_t pte); #define set_pte __set_pte #define set_ptes __set_ptes #define pte_clear __pte_clear +#define __HAVE_ARCH_PTEP_GET_AND_CLEAR +#define ptep_get_and_clear __ptep_get_and_clear #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 3d73b83cf97f..7e74e7b67107 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 @@ -236,7 +236,7 @@ static void clear_flush(struct mm_struct *mm, unsigned long i, saddr = addr; for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) - ptep_clear(mm, addr, ptep); + __ptep_get_and_clear(mm, addr, ptep); flush_tlb_range(&vma, saddr, addr); } @@ -411,7 +411,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);