Re: [PATCH 7.2 v10 1/2] mm/mmu_gather: prepare to skip redundant sync IPIs

Peter Zijlstra
2026-04-24T15:05:13Z

On Fri, Apr 24, 2026 at 02:25:27PM +0800, Lance Yang wrote:
> diff --git a/mm/mmu_gather.c b/mm/mmu_gather.c
> index 3985d856de7f..37a6a711c37e 100644
> --- a/mm/mmu_gather.c
> +++ b/mm/mmu_gather.c
> @@ -283,6 +283,14 @@ void tlb_remove_table_sync_one(void)
> * It is however sufficient for software page-table walkers that rely on
> * IRQ disabling.
> */
> +
> + /*
> + * Skip IPI if the preceding TLB flush already synchronized with
> + * all CPUs that could be doing software/lockless page table walks.
> + */
> + if (tlb_table_flush_implies_ipi_broadcast())
> + return;
> +
> smp_call_function(tlb_remove_table_smp_sync, NULL, 1);
> }
>
> @@ -312,6 +320,13 @@ static void tlb_remove_table_free(struct mmu_table_batch *batch)
> */
> void tlb_remove_table_sync_rcu(void)
> {
> + /*
> + * Skip RCU wait if the preceding TLB flush already synchronized
> + * with all CPUs that could be doing software/lockless page table walks.
> + */
> + if (tlb_table_flush_implies_ipi_broadcast())
> + return;
> +
> synchronize_rcu();
> }

So I don't like this at all.... The comment says there is a preceding
TLB flush, but there is nothing that guarantees there is. One would have
to go audit all users and ensure this is always true.

This thing is incredibly fragile.

Also, the comment in gup_fast() is nonsense, the local_irq_disable()
isn't about tlb_remove_table_sync_one(), it is primarily about TLBI
IPIs.