From patchwork Mon Dec 4 10:54:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13478189 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 2C509C4167B for ; Mon, 4 Dec 2023 10:55:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B74AD6B02A3; Mon, 4 Dec 2023 05:55:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B25546B02A5; Mon, 4 Dec 2023 05:55:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9ED706B02A6; Mon, 4 Dec 2023 05:55:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8CD726B02A3 for ; Mon, 4 Dec 2023 05:55:17 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 67B2EC01B2 for ; Mon, 4 Dec 2023 10:55:17 +0000 (UTC) X-FDA: 81528829074.27.0F4CF55 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf13.hostedemail.com (Postfix) with ESMTP id B431920027 for ; Mon, 4 Dec 2023 10:55:15 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.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=1701687315; 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=YwPKQQiak6Wq4SeQDrdHtDBJcvIfgSIZ07B41IMN5A0=; b=4ERqG71lLYfwQK9CsW5U52Mjrnzy/kRp3DLQiWXoJlBfGcGsuqPLp5KCwAZlKR/MOqUYqB XGhY3mkJnuYwjSZZeT2oPgK2F4NYoH4tr4Fcr812+fvFXxvh1H4/xNPPg8CWDcTdef/Jof cp1U3nUpsNbiOI5mvbWbb6zvad8c4lc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701687315; a=rsa-sha256; cv=none; b=UW5yh9G3OuD5yzlxvPcKY0lUppg4+5tjrPv8N1KlnR9FgqRGx0omVKpy4E3V2XkeVQRLyY FylYFJVqXiGDGHId3CFi4qIq5CbeK72CBDSemkmuGLfx0eq65xFCN2ff8E6SABk47wLB6y 3F+yEdaqXYaKpAXXdijoQR7Vrh7RrOA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.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 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 07857139F; Mon, 4 Dec 2023 02:56:02 -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 53EE93F6C4; Mon, 4 Dec 2023 02:55:11 -0800 (PST) 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 , David Hildenbrand , Kefeng Wang , John Hubbard , Zi Yan , Barry Song <21cnbao@gmail.com>, Alistair Popple , Yang Shi Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/15] arm64/mm: pte_clear(): New layer to manage contig bit Date: Mon, 4 Dec 2023 10:54:30 +0000 Message-Id: <20231204105440.61448-6-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231204105440.61448-1-ryan.roberts@arm.com> References: <20231204105440.61448-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: B431920027 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: c4znddjdc8fwb6r6gqg3wgfmacb6m6ra X-HE-Tag: 1701687315-228622 X-HE-Meta: U2FsdGVkX1+pq1oa4YQc72WtTEhT45fPwGU/Yu0EoNGJaGmlO6uv8C2LWHMpkqG2NjpoRUGqupg4q/uGokdpGYmxfWCxp0E49S8bQcsQkJoELwtKDiLcWo9AlwQ956r/TpsujdjWxPjYu/iXiEpnyXLIyKXjUcxrYUny1KWXHZy77jDeH5ufZy0hllDpzIicswc0FvfDR06TF1RXxuraP9ItQQGEz/VDEYwnIVPGROJDOfo3yd37LnKDSu2Dm4tJVgrEEL51nRqHWA8XjVKVjU8Tc7yFFRXDBAmVBprzZWqlf1kvSWrGel3TGNKlrWvEy1tS1muGQTLTYAgOemYVgauLDqnXJMmE7LefGgpNuoNKwxa8h7jw2nToPmzcgw1nJ+FWXVxKn7TqWFY2fAMiNgjFj1ZZmLTfJQ5TZfddbQD+BcyHVw0DJF16Gf3kNiKNrkNFCxL+0hTCWB01a7nX2HFNzQXRshyUDBJoFB8+buXMCveGSejCDepqN1p5p7kjpkQgVY3+tgF+vxULO/q4pFH7i5zZcBsl3s9FhezlyygI6I28oqgK0CmK3vx/1K+azS2ncQTz87n/9O17uBUrwkXXG6pD3oYVgo2aTZVhuJA8cUgOF55t4sra+rN/qsIn2L3nco6PkrQWycullRrLR5fT3Mc1p63qyVX41BJipm8AWWmE0mb75nsJSClx36AiEPC6e1zhBFIFkEeNEIHrxz14FlVV5pcr0bYM5HAbJxSHuHrCDIDmY7RE9i5YQao74UDxLj0L+xUlK0f3VAOEwEl1dOQB2+elPaYB1RmkDytQcnSSlFxNDMrkkkg/ASGuTLztE01UyJ0qEC+i1oc9V0jbpygUbq/VDp0Oh+aBgqXpy6AwhMiMQZg80ck0hEqZSXDqlBdHXvwU+1eUbfJmfsMAuZgNNJILnbQp2NQLkWBH4KeGLIHEWfpUx2nFe0rjdw2JtK1TEUhYNEmdAGB MyzUtBx+ 4RcpdO0/fZFM9G0UiYZhOU2sS0Y1TQ/C9WYwMeXV6+Afk3Ye0474gAKxz8Jtd86xNK0ch44jsSVYsGcqDo5TO4FRRocQvadyeCOyfvqVpiwC1dnuzpzdPHaCTxYu4beoh45/lcpHfWqaFeKWuYDr+p8pF1pwbMFmIHJtzvHZ8VKV0//OiXVU48R4UsXoiJhoA/e7FnGRZPFLICZp9BQ0U3rIM8gEai20sqG5m3NHWp/afZaEOUs8PDmAYjEgaD59pQpzqskvgmyTIOcia1xsABWJDsQ== 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. Signed-off-by: Ryan Roberts --- arch/arm64/include/asm/pgtable.h | 3 ++- arch/arm64/mm/fixmap.c | 2 +- arch/arm64/mm/hugetlbpage.c | 2 +- arch/arm64/mm/mmu.c | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 323ec91add60..1464e990580a 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -93,7 +93,7 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) __pte(__phys_to_pte_val((phys_addr_t)(pfn) << PAGE_SHIFT) | pgprot_val(prot)) #define pte_none(pte) (!pte_val(pte)) -#define pte_clear(mm, addr, ptep) \ +#define __pte_clear(mm, addr, ptep) \ __set_pte(ptep, __pte(0)) #define pte_page(pte) (pfn_to_page(pte_pfn(pte))) @@ -1121,6 +1121,7 @@ extern void ptep_modify_prot_commit(struct vm_area_struct *vma, #define set_pte __set_pte #define set_ptes __set_ptes +#define pte_clear __pte_clear #endif /* !__ASSEMBLY__ */ diff --git a/arch/arm64/mm/fixmap.c b/arch/arm64/mm/fixmap.c index 51cd4501816d..bfc02568805a 100644 --- a/arch/arm64/mm/fixmap.c +++ b/arch/arm64/mm/fixmap.c @@ -123,7 +123,7 @@ void __set_fixmap(enum fixed_addresses idx, if (pgprot_val(flags)) { __set_pte(ptep, pfn_pte(phys >> PAGE_SHIFT, flags)); } else { - pte_clear(&init_mm, addr, ptep); + __pte_clear(&init_mm, addr, ptep); flush_tlb_kernel_range(addr, addr+PAGE_SIZE); } } diff --git a/arch/arm64/mm/hugetlbpage.c b/arch/arm64/mm/hugetlbpage.c index 741cb53672fd..510b2d4b89a9 100644 --- a/arch/arm64/mm/hugetlbpage.c +++ b/arch/arm64/mm/hugetlbpage.c @@ -400,7 +400,7 @@ void huge_pte_clear(struct mm_struct *mm, unsigned long addr, ncontig = num_contig_ptes(sz, &pgsize); for (i = 0; i < ncontig; i++, addr += pgsize, ptep++) - pte_clear(mm, addr, ptep); + __pte_clear(mm, addr, ptep); } pte_t huge_ptep_get_and_clear(struct mm_struct *mm, diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index e884279b268e..080e9b50f595 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -859,7 +859,7 @@ static void unmap_hotplug_pte_range(pmd_t *pmdp, unsigned long addr, continue; WARN_ON(!pte_present(pte)); - pte_clear(&init_mm, addr, ptep); + __pte_clear(&init_mm, addr, ptep); flush_tlb_kernel_range(addr, addr + PAGE_SIZE); if (free_mapped) free_hotplug_page_range(pte_page(pte),