Skip to contentSkip to conversation

mm/migrate_device: fix double unlock

PATCH In review Sunny Patel 3 participants 4 messages Apr 13 – Apr 14

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

PATCH 1/1 mm/migrate_device: fix double unlock

migrate_vma_collect_huge_pmd() calls spin_unlock(ptl) after softleaf_entry_wait_on_locked(), which already releases the ptl.

Fixes a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
---
 mm/migrate_device.c | 1 -
 1 file changed, 1 deletion(-)
mm/migrate_device.c +0 -1
index 8079676c8f1f..7eb2f87ea39d 100644
@@ -177,7 +177,6 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,
 
 		if (softleaf_is_migration(entry)) {
 			softleaf_entry_wait_on_locked(entry, ptl);
-			spin_unlock(ptl);
 			return -EAGAIN;
 		}
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 17 lines · Sunny Patel

migrate_vma_collect_huge_pmd() calls spin_unlock(ptl) after softleaf_entry_wait_on_locked(), which already releases the ptl.

Fixes a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
---
 mm/migrate_device.c | 1 -
 1 file changed, 1 deletion(-)
mm/migrate_device.c +0 -0
index 8079676c8f1f..7eb2f87ea39d 100644

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

Quoted 7 lines
mm/migrate_device.c +0 -1
@@ -177,7 +177,6 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,
 
 		if (softleaf_is_migration(entry)) {
 			softleaf_entry_wait_on_locked(entry, ptl);
-			spin_unlock(ptl);
 			return -EAGAIN;
 		}
 

As raised by Matthew, the entire code block is dead code:

https://lore.kernel.org/linux-mm/[email protected]/

And I even Ack'ed it /facepalm

So we should take that (cleanup) patch instead. Thanks!

Signature · 3 lines
Cheers,

David
#2 lore raw
Quoted 28 lines · David Hildenbrand (Arm)
Quoted 17 lines · Sunny Patel

migrate_vma_collect_huge_pmd() calls spin_unlock(ptl) after softleaf_entry_wait_on_locked(), which already releases the ptl.

Fixes a30b48bf1b24 ("mm/migrate_device: implement THP migration of zone device pages")
---
 mm/migrate_device.c | 1 -
 1 file changed, 1 deletion(-)
mm/migrate_device.c +0 -0
index 8079676c8f1f..7eb2f87ea39d 100644

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

Quoted 7 lines
mm/migrate_device.c +0 -1
@@ -177,7 +177,6 @@ static int migrate_vma_collect_huge_pmd(pmd_t *pmdp, unsigned long start,
 
 		if (softleaf_is_migration(entry)) {
 			softleaf_entry_wait_on_locked(entry, ptl);
-			spin_unlock(ptl);
 			return -EAGAIN;
 		}
 

As raised by Matthew, the entire code block is dead code:

Quoted 6 lines

https://lore.kernel.org/linux-mm/[email protected]/

And I even Ack'ed it /facepalm

So we should take that (cleanup) patch instead. Thanks!

+1

Balbir

#3 lore raw
In reply to David Hildenbrand (Arm)
Quoted 4 lines · David Hildenbrand (Arm)

As raised by Matthew, the entire code block is dead code:
https://lore.kernel.org/linux-mm/[email protected]/
And I even Ack'ed it /facepalm
So we should take that (cleanup) patch instead. Thanks!

+1

Thanks for the pointer. I will drop my cleanup patch and defer to above patch at the above link instead since it already addresses the same dead code block and has your Ack.

Thanks,
Sunny Patel