Skip to content

migrate_pages: fix deadlock in batched synchronous migration

Huang Ying linux-mm lkml 1 version Applied

Status from this message: [merged mm-hotfixes-stable] migrate_pages-move-split-folios-processing-out-of-migrate_pages_batch.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 0 repliesApplied 3/3

v2 from the cover letter

- Rebased on latest upstream.

- Restore the total retry number of synchronous migrations and removed "force" logic from migrate_folio_unmap(). Thanks Hugh!

- Revised some comments per Baolin's comment. Thanks!

- Collected reviewed-by and tested-by.

Patches in v1 All 3 applied

#Subject and filesSizeRepliesApplied
1/3migrate_pages: fix deadlock in batched migrationmm/migrate.c+26 -430 repliesApplied
2/3migrate_pages: move split folios processing out of migrate_pages_batch()mm/migrate.c+28 -500 repliesApplied
3/3migrate_pages: try migrate in batch asynchronously firstlymm/migrate.c+62 -180 repliesApplied

Reviews trailers per patch

2 of 3 patches have a Reviewed-by or Acked-by.

PatchBaolin WangHugh Dickins
1/3
2/3R-b
3/3R-b T-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH -V2 0/3] migrate_pages: fix deadlock in batched synchronous migration

Two deadlock bugs were reported for the migrate_pages() batching series. Thanks Hugh and Pengfei. Analysis shows that if we have locked some other folios except the one we are migrating, it's not safe in general to wait synchronously, for example, to wait the writeback to complete or wait to lock the buffer head.

So 1/3 fixes the deadlock in a simple way, where the batching support for the synchronous migration is disabled. The change is straightforward and easy to be understood. While 3/3 re-introduce the batching for synchronous migration via trying to migrate asynchronously in batch optimistically, then fall back to migrate synchronously one by one for fail-to-migrate folios. Test shows that this can restore the TLB flushing batching performance for synchronous migration effectively.

Changelogs:

v2:

- Rebased on latest upstream.

- Restore the total retry number of synchronous migrations and removed "force" logic from migrate_folio_unmap(). Thanks Hugh!

- Revised some comments per Baolin's comment. Thanks!

- Collected reviewed-by and tested-by.

Best Regards,
Huang, Ying