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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (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 2A4BDC46CD2 for ; Tue, 30 Jan 2024 09:34:52 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4TPKky6GHtz3cTx for ; Tue, 30 Jan 2024 20:34:50 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=arm.com (client-ip=217.140.110.172; helo=foss.arm.com; envelope-from=ryan.roberts@arm.com; receiver=lists.ozlabs.org) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lists.ozlabs.org (Postfix) with ESMTP id 4TPKjw4jmhz3c1J for ; Tue, 30 Jan 2024 20:33:55 +1100 (AEDT) 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 54663DA7; Tue, 30 Jan 2024 01:34:08 -0800 (PST) Received: from [10.57.79.54] (unknown [10.57.79.54]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A8A173F738; Tue, 30 Jan 2024 01:33:21 -0800 (PST) Message-ID: Date: Tue, 30 Jan 2024 09:33:19 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 8/9] mm/mmu_gather: add tlb_remove_tlb_entries() Content-Language: en-GB To: David Hildenbrand , linux-kernel@vger.kernel.org References: <20240129143221.263763-1-david@redhat.com> <20240129143221.263763-9-david@redhat.com> From: Ryan Roberts In-Reply-To: <20240129143221.263763-9-david@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Alexander Gordeev , Christian Borntraeger , Arnd Bergmann , Vasily Gorbik , Peter Zijlstra , "Aneesh Kumar K.V" , linuxppc-dev@lists.ozlabs.org, Matthew Wilcox , linux-mm@kvack.org, Nick Piggin , Catalin Marinas , "Naveen N. Rao" , Andrew Morton , Will Deacon , Heiko Carstens , Sven Schnelle Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 29/01/2024 14:32, David Hildenbrand wrote: > Let's add a helper that lets us batch-process multiple consecutive PTEs. > > Note that the loop will get optimized out on all architectures except on > powerpc. We have to add an early define of __tlb_remove_tlb_entry() on > ppc to make the compiler happy (and avoid making tlb_remove_tlb_entries() a > macro). > > Signed-off-by: David Hildenbrand Reviewed-by: Ryan Roberts > --- > arch/powerpc/include/asm/tlb.h | 2 ++ > include/asm-generic/tlb.h | 20 ++++++++++++++++++++ > 2 files changed, 22 insertions(+) > > diff --git a/arch/powerpc/include/asm/tlb.h b/arch/powerpc/include/asm/tlb.h > index b3de6102a907..1ca7d4c4b90d 100644 > --- a/arch/powerpc/include/asm/tlb.h > +++ b/arch/powerpc/include/asm/tlb.h > @@ -19,6 +19,8 @@ > > #include > > +static inline void __tlb_remove_tlb_entry(struct mmu_gather *tlb, pte_t *ptep, > + unsigned long address); > #define __tlb_remove_tlb_entry __tlb_remove_tlb_entry > > #define tlb_flush tlb_flush > diff --git a/include/asm-generic/tlb.h b/include/asm-generic/tlb.h > index 428c3f93addc..bd00dd238b79 100644 > --- a/include/asm-generic/tlb.h > +++ b/include/asm-generic/tlb.h > @@ -616,6 +616,26 @@ static inline void tlb_flush_p4d_range(struct mmu_gather *tlb, > __tlb_remove_tlb_entry(tlb, ptep, address); \ > } while (0) > > +/** > + * tlb_remove_tlb_entries - remember unmapping of multiple consecutive ptes for > + * later tlb invalidation. > + * > + * Similar to tlb_remove_tlb_entry(), but remember unmapping of multiple > + * consecutive ptes instead of only a single one. > + */ > +static inline void tlb_remove_tlb_entries(struct mmu_gather *tlb, > + pte_t *ptep, unsigned int nr, unsigned long address) > +{ > + tlb_flush_pte_range(tlb, address, PAGE_SIZE * nr); > + for (;;) { > + __tlb_remove_tlb_entry(tlb, ptep, address); > + if (--nr == 0) > + break; > + ptep++; > + address += PAGE_SIZE; > + } > +} > + > #define tlb_remove_huge_tlb_entry(h, tlb, ptep, address) \ > do { \ > unsigned long _sz = huge_page_size(h); \