Re: [PATCH v2 1/2] mm/mmu_gather: delay rmap removal on UP as well
From: Zi Yan
Date: Mon Nov 16 2026 - 10:42:33 EST
On 16 Nov 2026, at 10:06, David Hildenbrand (Arm) wrote:
> Commit 5df397dec7c4 ("mm: delay page_remove_rmap() until after the TLB
> has been flushed") introduced delayed rmap removal of dirty pages until
> after the TLB flush, so writeback cannot clean a page that is still
> writable through a stale TLB entry.
>
> It skips this on UP, because on UP there are no remote TLBs (single CPU)
> and because the PTL prevents preemption.
>
> The PTL prevents preemption while removing the rmap, but the local TLB
> flush is usually only performed after dropping the PTL.
>
> Consequently, after dropping the PTL we could reschedule to another
> thread of the same mm, which does not flush the TLB. A kworker could
> then run into the original race with writeback: it cleans the folio,
> but the other thread can still modify it through the stale TLB entries,
> and these writes get lost.
>
> Fix it by simply not special-casing UP. Now, only architectures that
> select MMU_GATHER_NO_GATHER (s390) will skip delay_rmap handling.
>
> Fixes: 5df397dec7c4 ("mm: delay page_remove_rmap() until after the TLB has been flushed")
> Cc: stable@xxxxxxxxxxxxxxx
> Reported-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
> Link: https://lore.kernel.org/r/avrxOt_GyXLXNqtR@gremlin
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
> ---
> include/asm-generic/tlb.h | 6 +-----
> mm/mmu_gather.c | 2 --
> 2 files changed, 1 insertion(+), 7 deletions(-)
>
Makes sense to me.
Acked-by: Zi Yan <ziy@xxxxxxxxxx>
Best Regards,
Yan, Zi