Re: [PATCH v3] mm/migrate: don't batch the TLB flush when there is nothing to batch

From: David Hildenbrand (Arm)

Date: Mon Nov 09 2026 - 15:39:03 EST


On 11/9/26 17:18, Zhiteng Qiu wrote:
> On 11/9/26 14:07, David Hildenbrand (Arm) wrote:
>> For the future, please don't send new revisions in reply to old revisions.
>
> Sorry about that. I'll send the next revision as a new thread.
>
>> Is there no way to avoid that boolean?
>
> [...]
>
>> This is all information the caller could provide, and the caller could just
>> provide the TTU flag then instead of passing a new "bool".
>>
>> Also, likely this check can be put into a separate helper function.
>
> Agreed. I'll move the decision into a helper called from
> migrate_pages_batch() and pass the resulting flags to
> migrate_folio_unmap().
>
>> I am not quite happy about the folio_mapcount() check, though: as soon as we
>> optimize try_to_unmap() to batch better for large folios, it would be just plain
>> wrong.
>
> That makes sense. A large folio's mapcount alone would not tell us
> how many separate flushes are needed once its PTEs can be handled
> in a batch.
>
> Would it make sense to restrict the optimization to a single,
> singly mapped small folio and keep batching for all large folios,
> as in the scope of v2? The changelog performance numbers were
> measured with the v2 check. Or do you have a different direction
> in mind?

Likely best to focus on small folios first.

--
Cheers,

David