From patchwork Wed Nov 15 16:30:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13457059 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 66A7DC072A2 for ; Wed, 15 Nov 2023 16:30:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 70A1D6B038D; Wed, 15 Nov 2023 11:30:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B9C26B038C; Wed, 15 Nov 2023 11:30:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 55AB06B038D; Wed, 15 Nov 2023 11:30:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 3CED36B038A for ; Wed, 15 Nov 2023 11:30:49 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 09D7D1402B0 for ; Wed, 15 Nov 2023 16:30:49 +0000 (UTC) X-FDA: 81460727418.05.D7B8CD5 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf07.hostedemail.com (Postfix) with ESMTP id 0BAF840006 for ; Wed, 15 Nov 2023 16:30:46 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; spf=pass (imf07.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=1700065847; 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=jmnwrE3omr0Bxs+vWpKdVpciKB3lJc8SQRQJZBtepEICFhCZclzzTsxRDnxAxHjUscNTj3 mO8eCE3K+nVgu73YPulYEvY4hbadUZfdwK/bCUzKVfVbVAXbo5bNhu8isaP2tzsDd4VhAO Hgpt1nkneBuheHpj1QN7aHJID9zcQmo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700065847; a=rsa-sha256; cv=none; b=oJOIWMb6Rwf7yd6TVV7n1kfOwMb1OQoqAesQf3mS0mO8ZQ1YugYh92L6CN+JLTmLzhZ26n 5EOtif0C70NQFvh5Js2AKxsMsv5tvx6sMk6K9vnvrsYrunCVBLWrVRim2W3gQoi0dXojrA pepiEq1t8BdIaUzeBgfDsjW187lH3uk= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; spf=pass (imf07.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 9A75DDA7; Wed, 15 Nov 2023 08:31:31 -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 E084A3F641; Wed, 15 Nov 2023 08:30:42 -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 Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 04/14] arm64/mm: pte_clear(): New layer to manage contig bit Date: Wed, 15 Nov 2023 16:30:08 +0000 Message-Id: <20231115163018.1303287-5-ryan.roberts@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231115163018.1303287-1-ryan.roberts@arm.com> References: <20231115163018.1303287-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0BAF840006 X-Rspam-User: X-Stat-Signature: z8gatb8jxqyedkx9qd8mtfigyfah3pxn X-Rspamd-Server: rspam03 X-HE-Tag: 1700065846-708965 X-HE-Meta: U2FsdGVkX1+jHD7xcCl84SCBt32oFQd29D+B9pRJtzZvtrKu+DdziF8/omv9hRwIrrwJrB6k3/59pXYGQm3Hm3aFruZWGZrhHeaDBUSTc5ssBj6bL7dPHpCLoWP3DO7AuIWgzarLMGXN/0b6dOdWaoSEg6hC37SHUbt4MLMcVeONACEYDzMX1CyLg/Q+p+udf28U8H9HNU9ewAC38S47FAUQRcATE274YlId360pcg2Y8i4AV377jCrW97LDE2EJq9GcZOQyO2BbS2ViXXTIbQ9HpRZCXOHubWZMYIn6/beoKNr8RHO12CQAfjF8r6iJOjcw3C6jAfQQ3+UI7nlOR4Pu7KFF7gjJeHSPf341cCtXvuG0jxvDRtNTgG59pI0CKzlx/S1zr6ubH2YUGlawoafCF+dxK9mjzG8u/Uum0sHZ9/pj7/yXGYkyJoPJ5KyQvwcgFjmtvkskn8EOxFfZBJCfrcjyYEfbWOOF3J3Xac8/tWFKf5x2jzC7Kd4jvBk9NUNmeByWJFDjzlcdO3LgZV53uFw9jRpJ9L2oe5d8zWYjCf7snFwnoYn41OqVgT7/o+c6b6x8On9SFDfWuDyLhLD0nTXkXupvdYoN4PuPRLNYeXmb0rAOTUDgxgoswd6R7NIWt6t0j7OnSoXON3GklTEZwPYrGHgVPYwFwr+JjVUxW5f/0Zep26STlEsy9GTsPiQT0szDlPccnFxEnaxOjA4P/eAhFQXbAnEoAeVeTlhUh90JvPSzjCg3WN8dvIdyal+5f9BGTr+e4vubXetygEU1EjFh9dqmr5yx7Ch87Ny8EaUbs0REzkflCNkxwT6BAomMHx7lJ8IWsrGUNkEIC1ZnpoOZVE9uHlgGrBB413/2K2AOf9aYjXW9EOPm4qYKxcu3h7mxtEYP3s1W6ffUAHX4zmX+7TqrEfwR41C6Ec48lb8XEQlSfTbYOvcmNrgrYEMjRT4d7UhvvI8ooXc HINsYsqB r/BpZsQOGlXd+GggPaaIXe+fMUDDNEdfT09p4RIbE9DNeJieGXlMnXb2Kogh0NeKwXTNRxciLzO5H6qXClBmAelqbgjBf/qiFw1TvyWmGZRv+aNddA7xjZQrFIcHe/0smo/lLZ692WPkM/A9Mkz6YndyjbMCcd/QKQkgcetZdtMn9DzKmILRXiIiIHdR+IERhw+u+8qZMbvOrhamPxx4nnX04LnKavIlZ3sVsUzWuM3tcQGm4Bkjy0nWqcyO9SJ9S1j0jpp8+Vj9eQGuktwn3+QbXJA== 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),