Re: [PATCH 4/7] mm/migrate: add batch-copy path in migrate_pages_batch

From: Karim Manaouil

Date: Mon Jun 08 2026 - 17:17:38 EST


On Tue, Jun 09, 2026 at 02:10:21AM +0530, Garg, Shivank wrote:
>
>
> On 6/8/2026 9:06 PM, Zi Yan wrote:
> >
> > Maybe do this optimization in a separate patch to make it simpler to review.
> >
> > BTW, the whole migration code has become more and more complicated due to
> > batching at different levels, I wonder if it is worth the complication to
> > optimize for the rare memory error case.
>
>
> I agree on complication, but I think this change is actually simpler than my previous patch.
>
> Using per-folio marker lets me drop the already_copied arg that was passed through
> different function:
> migrate_folios_move() -> migrate_folio_move() -> move_to_new_folio().
> And there is no separate error path with this.
>
> Whoever performs the batch copy (migrate_folios_mc_copy() or a driver callback)
> sets FOLIO_CONTENT_COPIED on each dst it successfully copied, and __migrate_folio()
> reads that marker to skip folio_mc_copy().
>
> If copy is unsuccessful (e.g. memory error), FOLIO_CONTENT_COPIED is NOT marked,
> and __migrate_folio() will not skip the folio_mc_copy().

I fully agree on this as well. It's much simpler and cleaner than
passing down already_copied flag.

> Since the per-folio marking is the natural implementation for this, I kept it
> in this patch (af44801ee).
>
> Git Tree for reference: https://github.com/AMDESE/linux-mm/commits/shivank/batch-migrate-offload-v6-wip
>
>
> Thanks,
> Shivank

--
~karim