Re: [PATCH v2] mm/migrate: don't batch the TLB flush when there is nothing to batch
From: Zi Yan
Date: Sun Nov 08 2026 - 09:42:43 EST
On Sun Nov 8, 2026 at 7:52 AM EST, Huang, Ying wrote:
> Zhiteng Qiu <qiuzhiteng@xxxxxxxx> writes:
>
<snip>
>
> IMHO, the description above is a bit too long. Could you try to make it
> more concise?
I agree. It looks like AI generated.
>
>> Signed-off-by: Zhiteng Qiu <qiuzhiteng@xxxxxxxx>
>> ---
<snip>
>> @@ -1344,7 +1344,19 @@ static int migrate_folio_unmap(new_folio_t get_new_folio,
>> /* Establish migration ptes */
>> VM_BUG_ON_FOLIO(folio_test_anon(src) &&
>> !folio_test_ksm(src) && !anon_vma, src);
>> - try_to_migrate(src, mode == MIGRATE_ASYNC ? TTU_BATCH_FLUSH : 0);
>> + enum ttu_flags ttu = mode == MIGRATE_ASYNC ? TTU_BATCH_FLUSH : 0;
>> +
>> + /*
>> + * Batching only pays off when the rmap walk can meet more than
>> + * one PTE. A lone order-0 folio with a single mapping has
>> + * exactly one: batching it gains nothing, and it leaves
>> + * mm->tlb_flush_batched pending, so later page table changes
>> + * in this mm (e.g. NUMA scanning) flush the whole mm.
This comment can be simplified.
>> + */
>> + if (single_folio && !folio_test_large(src) &&
>> + !folio_maybe_mapped_shared(src))
>> + ttu &= ~TTU_BATCH_FLUSH;
>
> Is it possible to use a simplified version as below?
>
> enum ttu_flags ttu = 0;
>
> if (mode == MIGRATE_ASYNC &&
> (!single_folio || folio_mapcount(src) > 1))
LGTM, but I would keep folio_maybe_mapped_shared() to clarify the
intent. Would (!single_folio || folio_maybe_mapped_shared(src)) work?
> ttu = TTU_BATCH_FLUSH;
>
--
Best Regards,
Yan, Zi