Skip to contentSkip to conversation

mm/migrate_device.c: Fix a misleading and out-dated comment

PATCH Applied Alistair Popple 2 participants 2 messages Aug 30, 2022

Subsystems (2)
lore
Share & tools
lore

Alistair Popple

author reviewer
#0 lore raw

PATCH v2 1/1 mm/migrate_device.c: Fix a misleading and out-dated comment

Commit ab09243aa95a ("mm/migrate.c: remove MIGRATE_PFN_LOCKED") changed the way trylock_page() in migrate_vma_collect_pmd() works without updating the comment. Reword the comment to be less misleading and a better reflection of what happens.

Fixes ab09243aa95a ("mm/migrate.c: remove MIGRATE_PFN_LOCKED")
---
 mm/migrate_device.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)
mm/migrate_device.c +10 -3
index 5052093d0262..9e7ec925ec51 100644
@@ -179,9 +179,16 @@ static int migrate_vma_collect_pmd(pmd_t *pmdp,
 		get_page(page);
 
 		/*
-		 * Optimize for the common case where page is only mapped once
-		 * in one process. If we can lock the page, then we can safely
-		 * set up a special migration page table entry now.
+		 * We rely on trylock_page() to avoid deadlock between
+		 * concurrent migrations where each is waiting on the others
+		 * page lock. If we can't immediately lock the page we fail this
+		 * migration as it is only best effort anyway.
+		 *
+		 * If we can lock the page it's safe to set up a migration entry
+		 * now. In the common case where the page is mapped once in a
+		 * single process setting up the migration entry now is an
+		 * optimisation to avoid walking the rmap later with
+		 * try_to_migrate().
 		 */
 		if (trylock_page(page)) {
 			bool anon_exclusive;
Signature · 1 line
2.35.1
Acked-by on v2 1/1
#1 lore raw
Quoted 8 lines · Alistair Popple

Commit ab09243aa95a ("mm/migrate.c: remove MIGRATE_PFN_LOCKED") changed the way trylock_page() in migrate_vma_collect_pmd() works without updating the comment. Reword the comment to be less misleading and a better reflection of what happens.

Fixes ab09243aa95a ("mm/migrate.c: remove MIGRATE_PFN_LOCKED")

Thanks,

Signature · 1 line
Peter Xu