Re: [PATCH v5] mm/migrate: don't batch the TLB flush when there is nothing to batch
From: Zhiteng Qiu
Date: Sat Dec 05 2026 - 01:29:15 EST
Hi David,
> Two tabs please.
I've changed the continuation lines in folio_migrate_ttu_flags() to
use two tabs in v6.
> Curious ... why do we even have to unmap if ... already unmapped? :)
We already skip try_to_migrate() if the source is unmapped when we
check it under the folio lock. An unmapped page-cache folio can still
need to migrate, e.g. during compaction. migrate_folio_unmap() also
locks the source, checks writeback and locks the destination. On
success it records the migration state in the destination and leaves
both folios locked for the move. FOLIO_WAS_MAPPED stays clear in
this case, so the move also skips remove_migration_ptes().
The unlocked folio_mapped() check you quoted in v5 was only there to
predict whether the folio would queue a flush. A fault can map a
page-cache folio between that check and the lock, and writeback can
stop the unmap of a folio that looked mapped. In v6 I've dropped
that check and use current->tlb_ubc.flush_required to decide whether
the tail can share a pending flush.
Thanks,
Zhiteng