From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C068C44508 for ; Tue, 14 Jul 2026 14:06:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=W11OhnWcGHVOZmGTaRtReQ7d9g+T7FOsV0FghI7A38A=; b=0bXV2pR0c/lejl353CIQk5WtAy zh1La1p+sEd6rGhdaXJv6CxlRciWiiiLqKeXEzTi9AS02MxgWu2mrOJ10p+RZGy2+viIDZ8x7YvxJ fZEir0cdMDMjQSEIs0SJyEyp4qbNfPwgo4+aPfuOVNvocHDMwPlMDAL9/IA//h/y2wKG9jDEoDsU9 Ga2en4e9Q9zfRDZVISC5xcG8rwn1ZrQYJ9jE90SlIBwydFgNq7NqEDDFGhsv2OFxHnrF6CP4K9skE /GVHZCbUHwCM3AEexF5887/nua7DmYrkAy2LDs+hg3BxLwoxVJkiO+w4uHEUvtgj2QARhowzO2yX5 JI9dYNiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wjdmP-0000000CIlP-0hOw; Tue, 14 Jul 2026 14:06:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wjdmK-0000000CIfs-3J6Z; Tue, 14 Jul 2026 14:06:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=W11OhnWcGHVOZmGTaRtReQ7d9g+T7FOsV0FghI7A38A=; b=NOAhe+cAI685Mm8H1luQoTaZNR gtCT23KTCH1R2+PUTYGMg/0g853lmjM5Slvksr5najZSUs//CI2p0SYX6sJMr7pO74y9/l3hfq6KO jGR0jLLKb64i1rIC0k26gCB+t5dgS7f5c5XRZNMtg7dLudXd2y1vwaSACGcuWw/wbKE3h5eGAY33K 6EdLKaHocwp3t65hXwSn5So48WKIBcSRS9bcMmFfP10xE14m/UZjufn97CAnVPF8z9VRf+fCqk52f 5Pn+ydicpcFcn4Np6MCO/WK72e8p4j5vBqVxHdDnVjjKDIgAoKn7NM224gYMqfhgP4Caj5DVgxpU0 kdZynuSQ==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.99.2 #2 (Red Hat Linux)) id 1wjdmG-0000000CZ7J-32ur; Tue, 14 Jul 2026 14:06:31 +0000 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 357EF1BCA; Tue, 14 Jul 2026 07:06:23 -0700 (PDT) Received: from localhost.localdomain (e123572-lin.cambridge.arm.com [10.2.208.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0D7CA3F7B4; Tue, 14 Jul 2026 07:06:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1784037987; bh=0Ls2F5YWtI+Ww29NmMlh3ILvDXBv7NqjYutzPTWlWAY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Vw/DcaipPFO7n11+mYGQ7sNvjiW4bDFKvxM87pb4Zb7kuc57MeI8Zk26C7/35oDk9 zqUNmHcLyquGe9NI65E4Her4eCylK5913yMxY4xf0bE1WBcJGqN4rBz8A8PaHgPJxY 8H47S03cWv8hSaCgq8C8KHighveKeuoCTTOKDHQY= From: Kevin Brodsky Date: Tue, 14 Jul 2026 15:03:59 +0100 Subject: [PATCH 10/22] sparc: mm: use mm_is_kernel() for kernel mm checks MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260714-remove_pgtable_cdtor-v1-10-44be8a7685d7@arm.com> References: <20260714-remove_pgtable_cdtor-v1-0-44be8a7685d7@arm.com> In-Reply-To: <20260714-remove_pgtable_cdtor-v1-0-44be8a7685d7@arm.com> To: linux-mm@kvack.org Cc: Kevin Brodsky , Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Pasha Tatashin , Russell King , Catalin Marinas , Will Deacon , Ryan Roberts , linux-arm-kernel@lists.infradead.org, Huacai Chen , loongarch@lists.linux.dev, "James E.J. Bottomley" , Helge Deller , linux-parisc@vger.kernel.org, Madhavan Srinivasan , Michael Ellerman , linuxppc-dev@lists.ozlabs.org, Paul Walmsley , Palmer Dabbelt , Albert Ou , linux-riscv@lists.infradead.org, Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Gerald Schaefer , linux-s390@vger.kernel.org, "David S. Miller" , Andreas Larsson , sparclinux@vger.kernel.org, Richard Weinberger , Anton Ivanov , Johannes Berg , linux-um@lists.infradead.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Ning Sun , x86@kernel.org, tboot-devel@lists.sourceforge.net, Ard Biesheuvel , Ilias Apalodimas , linux-efi@vger.kernel.org, Vishal Moola , Alistair Popple , "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1784037902; l=3538; i=kevin.brodsky@arm.com; s=20260427; h=from:subject:message-id; bh=0Ls2F5YWtI+Ww29NmMlh3ILvDXBv7NqjYutzPTWlWAY=; b=VJPLQX/cB8CHz8XN2ewL2VVdeyfHItZBmFDR5s9RbTft/6Q4d42mZh1rja83yviws3jmyIGiU WKKijSfDJjoB4fJ0orVPQbnc54Akn8lFl91qUqv6PDas/mRRckHwzdj X-Developer-Key: i=kevin.brodsky@arm.com; a=ed25519; pk=N2QG+eJKrvkNovwhhwJhnJ4+ScVfsGCHldmqLfcMTFs= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260714_150629_904584_D8B4BC39 X-CRM114-Status: GOOD ( 15.73 ) X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+linux-um=archiver.kernel.org@lists.infradead.org The new MMF_KERNEL flag identifies kernel-owned mm's. Checking the flag with mm_is_kernel() is preferred over comparing directly against &init_mm. No functional change, as only init_mm has MMF_KERNEL set for now. pgtable_64.h previously forward-declared init_mm to avoid pulling in mm_types.h. It seems that including mm_types.h is not causing troubles any more, so we can also use mm_is_kernel() there and drop the forward declaration. Assisted-by: Codex:GPT-5.5 Signed-off-by: Kevin Brodsky --- arch/sparc/include/asm/mmu_context_64.h | 2 +- arch/sparc/include/asm/pgtable_64.h | 6 ++---- arch/sparc/mm/init_64.c | 2 +- arch/sparc/mm/tlb.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/arch/sparc/include/asm/mmu_context_64.h b/arch/sparc/include/asm/mmu_context_64.h index 78bbacc14d2d..e88bc61aeb04 100644 --- a/arch/sparc/include/asm/mmu_context_64.h +++ b/arch/sparc/include/asm/mmu_context_64.h @@ -83,7 +83,7 @@ static inline void switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, str int cpu = smp_processor_id(); per_cpu(per_cpu_secondary_mm, cpu) = mm; - if (unlikely(mm == &init_mm)) + if (unlikely(mm_is_kernel(mm))) return; spin_lock_irqsave(&mm->context.lock, flags); diff --git a/arch/sparc/include/asm/pgtable_64.h b/arch/sparc/include/asm/pgtable_64.h index 0837ebbc5dce..960f8bf1ec5a 100644 --- a/arch/sparc/include/asm/pgtable_64.h +++ b/arch/sparc/include/asm/pgtable_64.h @@ -86,6 +86,7 @@ extern unsigned long VMALLOC_END; #define vmemmap ((struct page *)VMEMMAP_BASE) #include +#include #include bool kern_addr_valid(unsigned long addr); @@ -885,9 +886,6 @@ static inline unsigned long pud_pfn(pud_t pud) #define p4d_set(p4dp, pudp) \ (p4d_val(*(p4dp)) = (__pa((unsigned long) (pudp)))) -/* We cannot include at this point yet: */ -extern struct mm_struct init_mm; - /* Actual page table PTE updates. */ void tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, pte_t *ptep, pte_t orig, int fullmm, @@ -903,7 +901,7 @@ static void maybe_tlb_batch_add(struct mm_struct *mm, unsigned long vaddr, * SUN4V NOTE: _PAGE_VALID is the same value in both the SUN4U * and SUN4V pte layout, so this inline test is fine. */ - if (likely(mm != &init_mm) && pte_accessible(mm, orig)) + if (likely(!mm_is_kernel(mm)) && pte_accessible(mm, orig)) tlb_batch_add(mm, vaddr, ptep, orig, fullmm, hugepage_shift); } diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 103db4683b16..e0b678349e3a 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -788,7 +788,7 @@ static void mmu_context_wrap(void) */ mm = per_cpu(per_cpu_secondary_mm, cpu); - if (unlikely(!mm || mm == &init_mm)) + if (unlikely(!mm || mm_is_kernel(mm))) continue; old_ctx = mm->context.sparc64_ctx_val; diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index 6d9dd5eb1328..47083c287a94 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -179,7 +179,7 @@ static void tlb_batch_pmd_scan(struct mm_struct *mm, unsigned long vaddr, static void __set_pmd_acct(struct mm_struct *mm, unsigned long addr, pmd_t orig, pmd_t pmd) { - if (mm == &init_mm) + if (mm_is_kernel(mm)) return; if ((pmd_val(pmd) ^ pmd_val(orig)) & _PAGE_PMD_HUGE) { -- 2.51.2