Re: [PATCH v2 1/2] mm/mmu_gather: delay rmap removal on UP as well
From: David Hildenbrand (Arm)
Date: Mon Nov 16 2026 - 10:18:38 EST
On 11/16/26 16:16, Lorenzo Stoakes (ARM) wrote:
> On Mon, Nov 16, 2026 at 04:06:58PM +0100, 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
>
> Nitty, but I think better as Closes? :P
Ack, fixed it on #2 but forget it here ... why does checkpatch not complain? Weird.
Will change when picking :)
--
Cheers,
David