From patchwork Thu Oct 12 19:54:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 1847764 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=Q4znoG+4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S60jz3Q5Wz1yqn for ; Fri, 13 Oct 2023 06:55:35 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=Q4znoG+4; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4S60jz2KcVz3cnS for ; Fri, 13 Oct 2023 06:55:35 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=Q4znoG+4; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1236::1; helo=casper.infradead.org; envelope-from=willy@infradead.org; receiver=lists.ozlabs.org) Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4S60hc5Xryz3cPS for ; Fri, 13 Oct 2023 06:54:24 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=4Fn16qTKKDmoLngNQQ4GEd7U5ZLcnF6YO5R8MQyfSP8=; b=Q4znoG+4HTWnq0dTqEVCZDI+uU hA3CQAVGkFSg2dpaJpUkrb/5/eEF0IDrT3s5i4tS7hpXbiAAQY+8ibHf+KzbOF8oeotjoTwwuPmmc GpfmV4h3npc4vpGkaXRtVeY/9x1KlYtZaX0jsYJmMGPvwg050F7IO2wMW97T1zHc0RTAkqo6o1yrY toYhtsBPqOmkV6mbEZp8VIcBLAEcPoXTijfBSGuc/OEltetagGKrkoQoi1SRb8JnGMwbTJeCWC8EK uENSf+cYkLUQW8Xw9/Fofki1b5m+dp86eGjFpKBOSCAJQGLpeUHVc9o8km0Nq/3hrNQ+9WDEph8KB uDmo8dIw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qr1lA-001BSX-D7; Thu, 12 Oct 2023 19:54:16 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Subject: [PATCH 1/2] powerpc: Allow nesting of lazy MMU mode Date: Thu, 12 Oct 2023 20:54:14 +0100 Message-Id: <20231012195415.282357-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231012195415.282357-1-willy@infradead.org> References: <20231012195415.282357-1-willy@infradead.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Erhard Furtner , "Matthew Wilcox \(Oracle\)" , linux-sparc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, David Woodhouse Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" As noted in commit 49147beb0ccb ("x86/xen: allow nesting of same lazy mode"), we can now nest calls to arch_enter_lazy_mmu_mode(). Use ->active as a counter instead of a flag and only drain the batch when the counter hits 0. Signed-off-by: Matthew Wilcox (Oracle) Fixes: bcc6cc832573 ("mm: add default definition of set_ptes()") --- arch/powerpc/include/asm/book3s/64/tlbflush-hash.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h index 146287d9580f..bc845d876ed2 100644 --- a/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h +++ b/arch/powerpc/include/asm/book3s/64/tlbflush-hash.h @@ -38,7 +38,7 @@ static inline void arch_enter_lazy_mmu_mode(void) */ preempt_disable(); batch = this_cpu_ptr(&ppc64_tlb_batch); - batch->active = 1; + batch->active++; } static inline void arch_leave_lazy_mmu_mode(void) @@ -49,9 +49,8 @@ static inline void arch_leave_lazy_mmu_mode(void) return; batch = this_cpu_ptr(&ppc64_tlb_batch); - if (batch->index) + if ((--batch->active == 0) && batch->index) __flush_tlb_pending(batch); - batch->active = 0; preempt_enable(); } From patchwork Thu Oct 12 19:54:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 1847765 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=rIqwWkkv; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4S60ky3xd5z1yqn for ; Fri, 13 Oct 2023 06:56:26 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=rIqwWkkv; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4S60kw6LMRz3dF9 for ; Fri, 13 Oct 2023 06:56:24 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=rIqwWkkv; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=infradead.org (client-ip=2001:8b0:10b:1236::1; helo=casper.infradead.org; envelope-from=willy@infradead.org; receiver=lists.ozlabs.org) Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4S60hg3czkz3cPK for ; Fri, 13 Oct 2023 06:54:27 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=CSyPT7b+OGrcLFhMzi1tWe4i8irwCIBA39LooloVVJI=; b=rIqwWkkvXo/CE5Euy2SwaFBxhU 801Ba4eMfLWmgrn1MXv3PKag+tTKsavJbeMJwqNtD7uF35YP3EMCYSXQa1m0wxcVCHRb6ywGJLmWj ACsJomCKgV8Jo1WvXVKZtCZIpMF22aqC+M463aa/CpAWBzHZnTGL4e+GnIKf6/8zxbymD43OzHTB1 Bs/9qFG/TYzl5CppW9Sk912lGrLi7vgfS03lrrxcZNFCHu5l6Q51Fsn9DTibGNc2twZ6IDBCl2f/T 99WhlqG3f9laCDRDDWz/PkZdMUVCnhUQrt1HfF7AqBk2qVjJyt0bvw5ag39BTRCjlIf9znJLL6vyZ bu3cqdzQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qr1lA-001BSa-Fn; Thu, 12 Oct 2023 19:54:16 +0000 From: "Matthew Wilcox (Oracle)" To: linux-kernel@vger.kernel.org Subject: [PATCH 2/2] sparc: Allow nesting of lazy MMU mode Date: Thu, 12 Oct 2023 20:54:15 +0100 Message-Id: <20231012195415.282357-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20231012195415.282357-1-willy@infradead.org> References: <20231012195415.282357-1-willy@infradead.org> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Erhard Furtner , "Matthew Wilcox \(Oracle\)" , linux-sparc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, David Woodhouse Errors-To: linuxppc-dev-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" As noted in commit 49147beb0ccb ("x86/xen: allow nesting of same lazy mode"), we can now nest calls to arch_enter_lazy_mmu_mode(). Use ->active as a counter instead of a flag and only drain the batch when the counter hits 0. Signed-off-by: Matthew Wilcox (Oracle) Fixes: bcc6cc832573 ("mm: add default definition of set_ptes()") --- arch/sparc/mm/tlb.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/sparc/mm/tlb.c b/arch/sparc/mm/tlb.c index b44d79d778c7..a82c7c32e47d 100644 --- a/arch/sparc/mm/tlb.c +++ b/arch/sparc/mm/tlb.c @@ -54,16 +54,15 @@ void arch_enter_lazy_mmu_mode(void) { struct tlb_batch *tb = this_cpu_ptr(&tlb_batch); - tb->active = 1; + tb->active++; } void arch_leave_lazy_mmu_mode(void) { struct tlb_batch *tb = this_cpu_ptr(&tlb_batch); - if (tb->tlb_nr) + if ((--tb->active == 0) && tb->tlb_nr) flush_tlb_pending(); - tb->active = 0; } static void tlb_batch_add_one(struct mm_struct *mm, unsigned long vaddr,