Skip to contentSkip to conversation

mm: Remove arch_flush_tlb_batched_pending() arch helper

PATCH Applied Ryan Roberts 5 participants 7 messages Jun 9, 2025 – Jun 12, 2025

Subsystems (5)
Memory management x86 RISC-V arm64 +1 more subsystems
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm: Remove arch_flush_tlb_batched_pending() arch helper

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()").

---
 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(-)
arch/arm64/include/asm/tlbflush.h +0 -11
index aa9efee17277..18a5dc0c9a54 100644
@@ -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
arch/riscv/include/asm/tlbflush.h +0 -1
index 1a20dd746a49..eed0abc40514 100644
@@ -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;
arch/riscv/mm/tlbflush.c +0 -5
index e737ba7949b1..8404530ec00f 100644
@@ -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,
arch/x86/include/asm/tlbflush.h +0 -5
index e9b81876ebe4..00daedfefc1b 100644
@@ -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,
mm/rmap.c +1 -1
index fb63d9256f09..fd160ddaa980 100644
@@ -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

Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Ryan Roberts

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().

Quoted 7 lines

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()").

Thanks, love to see an arch_*() helper go :)

Couple points below.

Quoted 13 lines
---
 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(-)
arch/arm64/include/asm/tlbflush.h +0 -0
index aa9efee17277..18a5dc0c9a54 100644

arch/arm64/include/asm/tlbflush.h static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) · line 330

Quoted 9 lines
arch/arm64/include/asm/tlbflush.h +0 -6
@@ -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.
- */

Hm are we losing information here? I guess it's hard to know whewre to put this though.

Quoted 57 lines
arch/arm64/include/asm/tlbflush.h +0 -5
-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
arch/riscv/include/asm/tlbflush.h +0 -1
index 1a20dd746a49..eed0abc40514 100644
@@ -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;
arch/riscv/mm/tlbflush.c +0 -5
index e737ba7949b1..8404530ec00f 100644
@@ -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,
arch/x86/include/asm/tlbflush.h +0 -5
index e9b81876ebe4..00daedfefc1b 100644
@@ -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,
mm/rmap.c +0 -0
index fb63d9256f09..fd160ddaa980 100644

mm/rmap.c void flush_tlb_batched_pending(struct mm_struct *mm) · line 749

Quoted 5 lines
mm/rmap.c +1 -1
@@ -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);

I see that CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH is only implemented in riscv (if !nommu), x86, arm64, and therefore we are only going to invoke this for those arches which previously did the same anyway, so this is safe.

Kinda wish we could avoid this ugly #ifdef #else #endif pattern here in mm/rmap.c but probably necessary in this case.

Quoted 6 lines
mm/rmap.c +0 -1
 		/*
 		 * If the new TLB flushing is pending during flushing, leave
 		 * mm->tlb_flush_batched as is, to avoid losing flushing.
--

2.43.0

#2 lore raw
Quoted 11 lines · Lorenzo Stoakes
Quoted 10 lines · Ryan Roberts

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()").

Quoted 6 lines
Quoted 2 lines

Thanks, love to see an arch_*() helper go :)

Thanks!

Quoted 19 lines

Couple points below.

Quoted 16 lines
---
 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(-)
arch/arm64/include/asm/tlbflush.h +0 -0
index aa9efee17277..18a5dc0c9a54 100644
@@ -322,17 +322,6 @@ static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm)
 	return true;
 }
 
Quoted 9 lines

arch/arm64/include/asm/tlbflush.h static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) · line 330

Quoted 6 lines
arch/arm64/include/asm/tlbflush.h +0 -6
-/*
- * 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.
- */

Hm are we losing information here? I guess it's hard to know whewre to put this though.

The generic version of this comment exists above flush_tlb_batched_pending() in rmap.c.

For the arm64-specific description of why we need to flush the whole mm, that's captured in Commit 4b634918384c ("arm64/mm: Close theoretical race where stale TLB entry remains valid"), although I accept that may not be the first place someone looks.

I don't think we should be defining arch_ helpers just to provide a hook for some arch-specific comments though.

Quoted 60 lines
Quoted 60 lines
arch/arm64/include/asm/tlbflush.h +0 -5
-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
arch/riscv/include/asm/tlbflush.h +0 -1
index 1a20dd746a49..eed0abc40514 100644
@@ -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;
arch/riscv/mm/tlbflush.c +0 -5
index e737ba7949b1..8404530ec00f 100644
@@ -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,
arch/x86/include/asm/tlbflush.h +0 -5
index e9b81876ebe4..00daedfefc1b 100644
@@ -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,
mm/rmap.c +0 -0
index fb63d9256f09..fd160ddaa980 100644
@@ -746,7 +746,7 @@ void flush_tlb_batched_pending(struct mm_struct *mm)
 	int flushed = batch >> TLB_FLUSH_BATCH_FLUSHED_SHIFT;
 
Quoted 8 lines

mm/rmap.c void flush_tlb_batched_pending(struct mm_struct *mm) · line 749

Quoted 3 lines
mm/rmap.c +1 -1
 	if (pending != flushed) {
-		arch_flush_tlb_batched_pending(mm);
+		flush_tlb_mm(mm);

I see that CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH is only implemented in riscv (if !nommu), x86, arm64, and therefore we are only going to invoke this for those arches which previously did the same anyway, so this is safe.

It's also the way it used to be done before arm64 joined the party and thought it could optimize by just issuing a DSB. I since discoved that the DSB approach is buggy so arm64 has now fallen back to flush_tlb_mm() so the reason for the original introduction of arch_flush_tlb_batched_pending() has gone.

Thanks,
Ryan

Quoted 10 lines

Kinda wish we could avoid this ugly #ifdef #else #endif pattern here in mm/rmap.c but probably necessary in this case.

Quoted 6 lines
mm/rmap.c +0 -1
 		/*
 		 * If the new TLB flushing is pending during flushing, leave
 		 * mm->tlb_flush_batched as is, to avoid losing flushing.
--

2.43.0

#3 lore raw
Quoted 53 lines · Ryan Roberts
Quoted 11 lines · Lorenzo Stoakes
Quoted 10 lines · Ryan Roberts

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()").

Quoted 6 lines
Quoted 2 lines

Thanks, love to see an arch_*() helper go :)

Thanks!

Quoted 19 lines

Couple points below.

Quoted 16 lines
---
 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(-)
arch/arm64/include/asm/tlbflush.h +0 -0
index aa9efee17277..18a5dc0c9a54 100644
@@ -322,17 +322,6 @@ static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm)
 	return true;
 }
 
Quoted 9 lines

arch/arm64/include/asm/tlbflush.h static inline bool arch_tlbbatch_should_defer(struct mm_struct *mm) · line 330

Quoted 6 lines
arch/arm64/include/asm/tlbflush.h +0 -6
-/*
- * 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.
- */

Hm are we losing information here? I guess it's hard to know whewre to put this though.

The generic version of this comment exists above flush_tlb_batched_pending() in rmap.c.

Quoted 7 lines

For the arm64-specific description of why we need to flush the whole mm, that's captured in Commit 4b634918384c ("arm64/mm: Close theoretical race where stale TLB entry remains valid"), although I accept that may not be the first place someone looks.

I don't think we should be defining arch_ helpers just to provide a hook for some arch-specific comments though.

Yeah completely agree.

Quoted 70 lines
Quoted 61 lines
Quoted 61 lines
arch/arm64/include/asm/tlbflush.h +0 -5
-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
arch/riscv/include/asm/tlbflush.h +0 -1
index 1a20dd746a49..eed0abc40514 100644
@@ -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;
arch/riscv/mm/tlbflush.c +0 -5
index e737ba7949b1..8404530ec00f 100644
@@ -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,
arch/x86/include/asm/tlbflush.h +0 -5
index e9b81876ebe4..00daedfefc1b 100644
@@ -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,
mm/rmap.c +0 -0
index fb63d9256f09..fd160ddaa980 100644
@@ -746,7 +746,7 @@ void flush_tlb_batched_pending(struct mm_struct *mm)
 	int flushed = batch >> TLB_FLUSH_BATCH_FLUSHED_SHIFT;
 
Quoted 8 lines

mm/rmap.c void flush_tlb_batched_pending(struct mm_struct *mm) · line 749

Quoted 3 lines
mm/rmap.c +1 -1
 	if (pending != flushed) {
-		arch_flush_tlb_batched_pending(mm);
+		flush_tlb_mm(mm);

I see that CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH is only implemented in riscv (if !nommu), x86, arm64, and therefore we are only going to invoke this for those arches which previously did the same anyway, so this is safe.

Quoted 4 lines

It's also the way it used to be done before arm64 joined the party and thought it could optimize by just issuing a DSB. I since discoved that the DSB approach is buggy so arm64 has now fallen back to flush_tlb_mm() so the reason for the original introduction of arch_flush_tlb_batched_pending() has gone.

Ack thanks for the background!

Quoted 15 lines

Thanks,
Ryan

Quoted 10 lines

Kinda wish we could avoid this ugly #ifdef #else #endif pattern here in mm/rmap.c but probably necessary in this case.

Quoted 6 lines
mm/rmap.c +0 -1
 		/*
 		 * If the new TLB flushing is pending during flushing, leave
 		 * mm->tlb_flush_batched as is, to avoid losing flushing.
--

2.43.0

Reviewed-by on v1 1/1
#4 lore raw
In reply to Ryan Roberts
Quoted 5 lines · Ryan Roberts

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().

Quoted 7 lines

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()").

Makes sense to replace arch callbacks with common generic functions applicable for all platforms.

Quoted 91 lines
---
 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(-)
arch/arm64/include/asm/tlbflush.h +0 -11
index aa9efee17277..18a5dc0c9a54 100644
@@ -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
arch/riscv/include/asm/tlbflush.h +0 -1
index 1a20dd746a49..eed0abc40514 100644
@@ -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;
arch/riscv/mm/tlbflush.c +0 -5
index e737ba7949b1..8404530ec00f 100644
@@ -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,
arch/x86/include/asm/tlbflush.h +0 -5
index e9b81876ebe4..00daedfefc1b 100644
@@ -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,
mm/rmap.c +1 -2
index fb63d9256f09..fd160ddaa980 100644
@@ -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

Acked-by on v1 1/1
#5 lore raw
In reply to Ryan Roberts
Quoted 5 lines · Ryan Roberts

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().

Quoted 8 lines

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()").

---

Signature · 3 lines
Cheers,

David / dhildenb
maintainer Acked-by on v1 1/1
#6 lore raw
In reply to Ryan Roberts
Quoted 12 lines · Ryan Roberts

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()").

Quoted 7 lines
---
 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(-)

Thank you, Ryan!

I assume this will go via akpm rather than the arch tree?

Will