Skip to contentSkip to conversation

mm/migrate_device: remove dead migration entry check in migrate_vma_collect_huge_pmd()

PATCH Applied Davidlohr Bueso 4 participants 4 messages Feb 12

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/migrate_device: remove dead migration entry check in migrate_vma_collect_huge_pmd()

The softleaf_is_migration() check is unreachable as entries that are not device_private are filtered out. Similarly, the PTE-level equivalent in migrate_vma_collect_pmd() skips migration entries.

This dead branch also contained a double spin_unlock(ptl) bug.

---
 mm/migrate_device.c | 6 ------
 1 file changed, 6 deletions(-)
mm/migrate_device.c +0 -7
index c2855235fd9a..b40c1d49677d 100644
@@ -175,13 +175,6 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,
 			return migrate_vma_collect_skip(start, end, walk);
 		}
 
-		if (softleaf_is_migration(entry)) {
-			migration_entry_wait_on_locked(entry, ptl);
-			spin_unlock(ptl);
-			return -EAGAIN;
-		}
-
 		if (softleaf_is_device_private_write(entry))
 			write = MIGRATE_PFN_WRITE;
 	} else {
--

2.39.5

reviewer Reviewed-by on v1 1/1
#1 lore raw

On 2026-02-12 at 12:46 +1100, Davidlohr Bueso <[email protected]> wrote...

Quoted 5 lines

The softleaf_is_migration() check is unreachable as entries that are not device_private are filtered out. Similarly, the PTE-level equivalent in migrate_vma_collect_pmd() skips migration entries.

This dead branch also contained a double spin_unlock(ptl) bug.

Heh. You beat me by 10 minutes :-) I was just checking to see if the fix had already been sent before pressing send on mine.

You probably want to add:

Fixes a30b48bf1b244 ("mm/migrate_device: implement THP migration of zone device pages")

But other than that this looks good so:

Quoted 27 lines
---
 mm/migrate_device.c | 6 ------
 1 file changed, 6 deletions(-)
mm/migrate_device.c +0 -7
index c2855235fd9a..b40c1d49677d 100644
@@ -175,13 +175,6 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,
 			return migrate_vma_collect_skip(start, end, walk);
 		}
 
-		if (softleaf_is_migration(entry)) {
-			migration_entry_wait_on_locked(entry, ptl);
-			spin_unlock(ptl);
-			return -EAGAIN;
-		}
-
 		if (softleaf_is_device_private_write(entry))
 			write = MIGRATE_PFN_WRITE;
 	} else {
--

2.39.5

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Davidlohr Bueso
Quoted 9 lines · Davidlohr Bueso

The softleaf_is_migration() check is unreachable as entries that are not device_private are filtered out. Similarly, the PTE-level equivalent in migrate_vma_collect_pmd() skips migration entries.

This dead branch also contained a double spin_unlock(ptl) bug.

---

Signature · 3 lines
Cheers,

David
Acked-by on v1 1/1
#3 lore raw
In reply to Davidlohr Bueso
Quoted 19 lines · Davidlohr Bueso

The softleaf_is_migration() check is unreachable as entries that are not device_private are filtered out. Similarly, the PTE-level equivalent in migrate_vma_collect_pmd() skips migration entries.

This dead branch also contained a double spin_unlock(ptl) bug.

---
 mm/migrate_device.c | 6 ------
 1 file changed, 6 deletions(-)
mm/migrate_device.c +0 -0
index c2855235fd9a..b40c1d49677d 100644
@@ -175,13 +175,6 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,
 			return migrate_vma_collect_skip(start, end, walk);
 		}

mm/migrate_device.c static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start, · line 180

Quoted 10 lines
mm/migrate_device.c +0 -6
 
-		if (softleaf_is_migration(entry)) {
-			migration_entry_wait_on_locked(entry, ptl);
-			spin_unlock(ptl);
-			return -EAGAIN;
-		}
-
 		if (softleaf_is_device_private_write(entry))
 			write = MIGRATE_PFN_WRITE;
 	} else {