From nobody Sun Sep 14 07:24:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1757317277151398.1715516228046; Mon, 8 Sep 2025 00:41:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1114649.1461513 (Exim 4.92) (envelope-from ) id 1uvWUo-0006DJ-Ei; Mon, 08 Sep 2025 07:41:02 +0000 Received: by outflank-mailman (output) from mailman id 1114649.1461513; Mon, 08 Sep 2025 07:41:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uvWUo-0006D2-AH; Mon, 08 Sep 2025 07:41:02 +0000 Received: by outflank-mailman (input) for mailman id 1114649; Mon, 08 Sep 2025 07:41:01 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1uvWUn-0004k6-Tz for xen-devel@lists.xenproject.org; Mon, 08 Sep 2025 07:41:01 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 2994595e-8c87-11f0-9809-7dc792cee155; Mon, 08 Sep 2025 09:40:59 +0200 (CEST) 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 AE1BA2A2A; Mon, 8 Sep 2025 00:40:50 -0700 (PDT) Received: from e123572-lin.arm.com (e123572-lin.cambridge.arm.com [10.1.194.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 538FB3F63F; Mon, 8 Sep 2025 00:40:54 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2994595e-8c87-11f0-9809-7dc792cee155 From: Kevin Brodsky To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, Kevin Brodsky , Alexander Gordeev , Andreas Larsson , Andrew Morton , Boris Ostrovsky , Borislav Petkov , Catalin Marinas , Christophe Leroy , Dave Hansen , David Hildenbrand , "David S. Miller" , "H. Peter Anvin" , Ingo Molnar , Jann Horn , Juergen Gross , "Liam R. Howlett" , Lorenzo Stoakes , Madhavan Srinivasan , Michael Ellerman , Michal Hocko , Mike Rapoport , Nicholas Piggin , Peter Zijlstra , Ryan Roberts , Suren Baghdasaryan , Thomas Gleixner , Vlastimil Babka , Will Deacon , Yeoreum Yun , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, sparclinux@vger.kernel.org, xen-devel@lists.xenproject.org Subject: [PATCH v2 5/7] powerpc/mm: support nested lazy_mmu sections Date: Mon, 8 Sep 2025 08:39:29 +0100 Message-ID: <20250908073931.4159362-6-kevin.brodsky@arm.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20250908073931.4159362-1-kevin.brodsky@arm.com> References: <20250908073931.4159362-1-kevin.brodsky@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1757317279180116600 Content-Type: text/plain; charset="utf-8" The lazy_mmu API now allows nested sections to be handled by arch code: enter() can return a flag if called inside another lazy_mmu section, so that the matching call to leave() leaves any optimisation enabled. This patch implements that new logic for powerpc: if there is an active batch, then enter() returns LAZY_MMU_NESTED and the matching leave() leaves batch->active set. The preempt_{enable,disable} calls are left untouched as they already handle nesting themselves. TLB flushing is still done in leave() regardless of the nesting level, as the caller may rely on it whether nesting is occurring or not. Signed-off-by: Kevin Brodsky --- arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h b/arch/powe= rpc/include/asm/book3s/64/tlbflush-hash.h index c9f1e819e567..e92bce2efca6 100644 --- a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h @@ -39,9 +39,13 @@ static inline lazy_mmu_state_t arch_enter_lazy_mmu_mode(= void) */ preempt_disable(); batch =3D this_cpu_ptr(&ppc64_tlb_batch); - batch->active =3D 1; =20 - return LAZY_MMU_DEFAULT; + if (!batch->active) { + batch->active =3D 1; + return LAZY_MMU_DEFAULT; + } else { + return LAZY_MMU_NESTED; + } } =20 static inline void arch_leave_lazy_mmu_mode(lazy_mmu_state_t state) @@ -54,7 +58,10 @@ static inline void arch_leave_lazy_mmu_mode(lazy_mmu_sta= te_t state) =20 if (batch->index) __flush_tlb_pending(batch); - batch->active =3D 0; + + if (state !=3D LAZY_MMU_NESTED) + batch->active =3D 0; + preempt_enable(); } =20 --=20 2.47.0