From patchwork Fri Feb 2 08:07:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13542346 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 6F8E7C4828E for ; Fri, 2 Feb 2024 08:09:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 06B046B0098; Fri, 2 Feb 2024 03:09:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 01B136B0099; Fri, 2 Feb 2024 03:09:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD7616B009A; Fri, 2 Feb 2024 03:09:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id CD6E46B0098 for ; Fri, 2 Feb 2024 03:09:00 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A610F40E96 for ; Fri, 2 Feb 2024 08:09:00 +0000 (UTC) X-FDA: 81746138040.30.7142872 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf07.hostedemail.com (Postfix) with ESMTP id 21B3A40006 for ; Fri, 2 Feb 2024 08:08:58 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706861339; 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=it+CriqSISuFYBxAlX4OlkX2JArsjio+LXEUKYR9urU=; b=vkNX56opphBfGTq/B9QQnRGCsWI58DqkMP4WhW2kokZqdMiSZ9MzNoeKjdSD7Y2fSGv6vf cnmjXY/UUe5kL295ookDjpgfdOofh85Ha+qLv2Wir3Kkvpkwc/Igmv8srYYPX3MrHYJwDm i2WTcAwqznUXFiq7VTCra+i2c2heLBg= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; 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 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706861339; a=rsa-sha256; cv=none; b=o6chUhvMu4UO34oe5+ieeItv8QgHg1KWsXh/b1gHmlUlWlyi8BUy89pT89q0Gb861AD9aU +m3AjxHBPkWochsjPfsCvG8xSDJmIjjCxT5duLqmxsaPRmk2gfmEhpaVFH0XTHCkaNniIn lhp9ZYh3lDl8CmFE3arGDkiLPwJOVF0= 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 9ED401A2D; Fri, 2 Feb 2024 00:09:40 -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 B2CAC3F5A1; Fri, 2 Feb 2024 00:08:54 -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 11/25] arm64/mm: pte_clear(): New layer to manage contig bit Date: Fri, 2 Feb 2024 08:07:42 +0000 Message-Id: <20240202080756.1453939-12-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-Rspam-User: X-Stat-Signature: xzid7ojh98xrsy4934x6npxfoue9esrh X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 21B3A40006 X-HE-Tag: 1706861338-669181 X-HE-Meta: U2FsdGVkX1+cN1MfBEJuf2CTZMungjqpPADrI2SWx4G0o+3EhTJN9MGRbMoiyOiIJkBwzvw86o9s9jwn2a+4APfM1mLuT2bjiXhfWzTWrJPGEVpi3gH848ucKJQmmF0IbI1wJFAIKt5CQAtuzOrS1H35GcVlzQNzLTECqUp5OlyzCsmJQ1O00KtFh+1WXJL3ahNQ7PUgDnjKPiBRH/SiZqujqT9bm/nmTeIs9EA6hOMOjctCMffpL7zmjHueb/x6RUhLWtS8uV2qfJgXQAqn29KaQa5cOISq6oDUf8DBxfaK/WfbidarXwCzq4maKfTDCcsWlSJo7lD+sox+nqlE4Bes+7m3PK1ePFHPxu3mnp9vRc8ZkE8qBGGSdv5zyAqxZoWCg6s9cKmdtC/wIKWOrmUG32eaHbXvSNWQWm1ERI7ByyeOjgTJDIwCawpdDA1IQ4BjKGRPBtnIsNIPa5mc5NjV2pk5huwbrsFpyKWJkaN2oJDgiy816Wj2leFVs7up/CcP85uBGR4Q4ZkPInhot197PoR4oDETAKIQD7L7jiJipWN2A3huMBIvPfU4tcETe38b8kYAYKsKdyJhysssEpu6vehMLUYU0I2ZuiuFnhVY2E1IIYZXJN05BQNv4Lrh/+MMsZQkqZx9XJcYfLI0bC+iqCEj/tmuTL5QmNPbJD/hKMcKHMKY8C6dyvUdT4J9FNndLGzHp4Fi1XfxoXyQPCjNePAM/xn/UcHLL6v9a0R+6mb+H4onoe4vGDY32BwWAuLzyQI0Khf3B6qohvgFGBEBWNKgUndWxyPaJvurOmrfCtzZ8Cz0AOUOEP8cRD3+eTW87i36O/orfzKpgx2Rot+ncj+0WpG5GkTXWRoCr5GZFEALxTviq31+vNmtnN9gg49DA7ChdW3QhjX01yUA2FbV5nDahwV2GobOw/QlGaQ1zdx7EMy4Bdaut7rMq30tukmkd/YPI3sKmBL6aUe A3g== 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 | 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 f1fd6c5e3eca..3b0ff58109c5 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))) @@ -1140,6 +1140,7 @@ 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 #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 9d7e7315eaa3..3d73b83cf97f 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 7cc1930f0e10..bcaa5a5d86f8 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),