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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EC37C5B543 for ; Tue, 10 Jun 2025 06:22:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C50A36B007B; Tue, 10 Jun 2025 02:22:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C01696B0089; Tue, 10 Jun 2025 02:22:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B17336B008A; Tue, 10 Jun 2025 02:22:34 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 938096B007B for ; Tue, 10 Jun 2025 02:22:34 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4124D811A5 for ; Tue, 10 Jun 2025 06:22:34 +0000 (UTC) X-FDA: 83538497028.23.F7199EC Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf23.hostedemail.com (Postfix) with ESMTP id 0A0B0140002 for ; Tue, 10 Jun 2025 06:22:31 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf23.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749536552; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HglzH6nltUgcBqzzWRIaC4iA25lZjbDpZVuSs0uwEq4=; b=H6VoyzKB8bLiXP/aOL44e8DmN6I2X+U8w0PedX/PFob3bBs5HvoRN2iF3y1R/i1n3Q28tv 9F6ShjgHwuNSRPN7h22TmpLYv88HnFXcLTHqcZfdY99n7ch2NDwKNMc/gXGYUp9RDwxCN8 xY/cYa9/nYjud8IUoNiKUAb5+tZeTIw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf23.hostedemail.com: domain of anshuman.khandual@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=anshuman.khandual@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749536552; a=rsa-sha256; cv=none; b=5YcHtJZEB5KbyNxd3pw4Sm9uB8nCNK6qaOEG35Dlj6ul2tZ5XQRC0+CzweF1F5hNqbzo+Y PzismaBN01XPfVQOlufgeMTxqqzE/+dulfWT6nr9OLBEnABcPpGSm2DRi9j7gwSqC0woOR nA2btH2aGaaeq4APOsUJp5YIMmO9/ts= 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 AE37414BF; Mon, 9 Jun 2025 23:22:11 -0700 (PDT) Received: from [10.163.32.103] (unknown [10.163.32.103]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8F0793F673; Mon, 9 Jun 2025 23:22:23 -0700 (PDT) Message-ID: Date: Tue, 10 Jun 2025 11:52:20 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] mm: Remove arch_flush_tlb_batched_pending() arch helper To: Ryan Roberts , Andrew Morton , Catalin Marinas , Will Deacon , Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , David Hildenbrand , Lorenzo Stoakes , Rik van Riel , "Liam R. Howlett" , Vlastimil Babka , Harry Yoo Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org References: <20250609103132.447370-1-ryan.roberts@arm.com> Content-Language: en-US From: Anshuman Khandual In-Reply-To: <20250609103132.447370-1-ryan.roberts@arm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 0A0B0140002 X-Stat-Signature: wgrggmyb1eafb5pw8kd85h6ddwj5jqyo X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1749536551-657561 X-HE-Meta: U2FsdGVkX1+U7DQzfQc+WL0kV12dJyplj/MAcb+KY8SLaypJ2NxkoDgmf0PsDsUDjPcGLC6vfIaTN1r9XyR0PPJuJ75QGF5YWjr1l8yRPltA7ozDMQLESlWQcGt0khFk+iC7BvrewvxtYVZ4dUZF6C5rUQGbrANEEz7Im+M6znEXpETiR4MP1KLc00l0uPipCVlimkCvjjMi7FNGXfR1BeSGFxk1bCmmp6wC6hzz1sJohWxqSRuhGtTKeSQme/rNyTHwTgQM+cQl7elXsV7NBUK0B3AAbBc421hHNcMzN7d/b7r1xpuSOgOQ91Pc+NtgLwWc4JzztpOteYV9dofRDiE1xWUFIcwkyZU3z0Sy4UC5v3NWqvDwiNwyH08LPeW9JnS3E7ysPYqJH+x++1r1IMFJZQ92O+R9Tp2ZaDRezoj6h6TxsgCZaCpHlwZqYTLYpOOZ+Osn43I+MloSPab3vFDbIIJON9fMnGdW7jVBOoQesQBbNONWuXxCcknr0QeawfxFEclsNfVBD+2WnMNkvq6XU9QWi+74UUJ5CbASUm70n38XsJrhHJ2j0e1IWFV9GuTfWRMFDLhMxDgZ/FAVBcebsVntP1RcRjYGIvXbJI7UBWQcZGxhLl+Zf98LniP+mjkfxNO18ndJ2OdMWb11xEJ+RAcpvtfjjcepaSgGUQYTUjjpcK6M3foPbB7x0MZP4ApLyMkUS9kpBmCsWI78GT54OtUhi1WFi2KGWZPU53IYaQQJf67XaD9Imrr+/Sc5OmYnm84sxvbjgxnMFXCS8qGDRWmdXyDEpfp83uTUgNIs0yRAjmAQ0A7O3/uHbBOUOdc91dB8hNJNlp5N0CJTGf7B/4J4tGh99COxqfsW1tvjGuMuYvxxM4iFaHhsY95628J2jVtcc9Ib+fJ0zwNQGZDOUDNd7FVfoe7g+t0VYrai20z5Y4xalx0Yv8/p38bStwTUU24kziNPV9OgaU6 vJBjsqLK iEM2dEF2N65AXAqCthArc2wy+Gd7nqhxR2uuAI7EI++uIguj+xcV/F9csF6Kiko2k0SSL+je135qFqpHJi+pn11hKb8ykNZwquAjf9aMV6jdKUDhLS1SHDoCzLuuxPF4MIkuYIERM64H5w/raprAl23kfEjJeBDQvfizYylLPh2ViY6ujCrC4MdtFGWYmiRipqFBLWhPGf7/reDniXSqBiJPzlrRSbN05/rYZK/k4ws7X11alG7zPwBrNuynOUxsLEAftpxvSPG3egpCmHspnGrTdXENYvYKnSlpRru9auZxMOx8HVoq4qWvelayRG8OwP3AA 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: On 09/06/25 4:01 PM, Ryan Roberts wrote: > Since commit 4b634918384c ("arm64/mm: Close theoretical race where stale > TLB entry remains valid"), all arches that use tlbbatch for reclaim > (arm64, riscv, x86) implement arch_flush_tlb_batched_pending() with a > flush_tlb_mm(). > > So let's simplify by removing the unnecessary abstraction and doing the > flush_tlb_mm() directly in flush_tlb_batched_pending(). This effectively > reverts commit db6c1f6f236d ("mm/tlbbatch: introduce > arch_flush_tlb_batched_pending()"). > > Suggested-by: Will Deacon > Signed-off-by: Ryan Roberts Makes sense to replace arch callbacks with common generic functions applicable for all platforms. Reviewed-by: Anshuman Khandual > --- > arch/arm64/include/asm/tlbflush.h | 11 ----------- > arch/riscv/include/asm/tlbflush.h | 1 - > arch/riscv/mm/tlbflush.c | 5 ----- > arch/x86/include/asm/tlbflush.h | 5 ----- > mm/rmap.c | 2 +- > 5 files changed, 1 insertion(+), 23 deletions(-) > > diff --git a/arch/arm64/include/asm/tlbflush.h b/arch/arm64/include/asm/tlbflush.h > index aa9efee17277..18a5dc0c9a54 100644 > --- a/arch/arm64/include/asm/tlbflush.h > +++ b/arch/arm64/include/asm/tlbflush.h > @@ -322,17 +322,6 @@ static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) > return true; > } > > -/* > - * If mprotect/munmap/etc occurs during TLB batched flushing, we need to ensure > - * all the previously issued TLBIs targeting mm have completed. But since we > - * can be executing on a remote CPU, a DSB cannot guarantee this like it can > - * for arch_tlbbatch_flush(). Our only option is to flush the entire mm. > - */ > -static inline void arch_flush_tlb_batched_pending(struct mm_struct *mm) > -{ > - flush_tlb_mm(mm); > -} > - > /* > * To support TLB batched flush for multiple pages unmapping, we only send > * the TLBI for each page in arch_tlbbatch_add_pending() and wait for the > diff --git a/arch/riscv/include/asm/tlbflush.h b/arch/riscv/include/asm/tlbflush.h > index 1a20dd746a49..eed0abc40514 100644 > --- a/arch/riscv/include/asm/tlbflush.h > +++ b/arch/riscv/include/asm/tlbflush.h > @@ -63,7 +63,6 @@ void flush_pud_tlb_range(struct vm_area_struct *vma, unsigned long start, > bool arch_tlbbatch_should_defer(struct mm_struct *mm); > void arch_tlbbatch_add_pending(struct arch_tlbflush_unmap_batch *batch, > struct mm_struct *mm, unsigned long start, unsigned long end); > -void arch_flush_tlb_batched_pending(struct mm_struct *mm); > void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch); > > extern unsigned long tlb_flush_all_threshold; > diff --git a/arch/riscv/mm/tlbflush.c b/arch/riscv/mm/tlbflush.c > index e737ba7949b1..8404530ec00f 100644 > --- a/arch/riscv/mm/tlbflush.c > +++ b/arch/riscv/mm/tlbflush.c > @@ -234,11 +234,6 @@ void arch_tlbbatch_add_pending(struct arch_tlbflush_unmap_batch *batch, > mmu_notifier_arch_invalidate_secondary_tlbs(mm, start, end); > } > > -void arch_flush_tlb_batched_pending(struct mm_struct *mm) > -{ > - flush_tlb_mm(mm); > -} > - > void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch) > { > __flush_tlb_range(NULL, &batch->cpumask, > diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h > index e9b81876ebe4..00daedfefc1b 100644 > --- a/arch/x86/include/asm/tlbflush.h > +++ b/arch/x86/include/asm/tlbflush.h > @@ -356,11 +356,6 @@ static inline void arch_tlbbatch_add_pending(struct arch_tlbflush_unmap_batch *b > mmu_notifier_arch_invalidate_secondary_tlbs(mm, 0, -1UL); > } > > -static inline void arch_flush_tlb_batched_pending(struct mm_struct *mm) > -{ > - flush_tlb_mm(mm); > -} > - > extern void arch_tlbbatch_flush(struct arch_tlbflush_unmap_batch *batch); > > static inline bool pte_flags_need_flush(unsigned long oldflags, > diff --git a/mm/rmap.c b/mm/rmap.c > index fb63d9256f09..fd160ddaa980 100644 > --- a/mm/rmap.c > +++ b/mm/rmap.c > @@ -746,7 +746,7 @@ void flush_tlb_batched_pending(struct mm_struct *mm) > int flushed = batch >> TLB_FLUSH_BATCH_FLUSHED_SHIFT; > > if (pending != flushed) { > - arch_flush_tlb_batched_pending(mm); > + flush_tlb_mm(mm); > /* > * If the new TLB flushing is pending during flushing, leave > * mm->tlb_flush_batched as is, to avoid losing flushing. > -- > 2.43.0 > >