[PATCH] mm/migrate_device: fix double unlock

Sunny Patel posted 1 patch 2 months, 1 week ago
mm/migrate_device.c | 1 -
1 file changed, 1 deletion(-)
[PATCH] mm/migrate_device: fix double unlock
Posted by Sunny Patel 2 months, 1 week ago
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")

Cc: stable@vger.kernel.org

Signed-off-by: Sunny Patel <nueralspacetech@gmail.com>
---
 mm/migrate_device.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/mm/migrate_device.c b/mm/migrate_device.c
index 8079676c8f1f..7eb2f87ea39d 100644
--- a/mm/migrate_device.c
+++ b/mm/migrate_device.c
@@ -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;
 		}
 
-- 
2.43.0
Re: [PATCH] mm/migrate_device: fix double unlock
Posted by David Hildenbrand (Arm) 2 months, 1 week ago
On 4/13/26 23:15, Sunny Patel wrote:
> 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")
> 
> Cc: stable@vger.kernel.org
> 
> Signed-off-by: Sunny Patel <nueralspacetech@gmail.com>
> ---
>  mm/migrate_device.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
> index 8079676c8f1f..7eb2f87ea39d 100644
> --- a/mm/migrate_device.c
> +++ b/mm/migrate_device.c
> @@ -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/20260212014611.416695-1-dave@stgolabs.net/

And I even Ack'ed it /facepalm

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

-- 
Cheers,

David
Re: [PATCH] mm/migrate_device: fix double unlock
Posted by Sunny Patel 2 months, 1 week ago
On 4/14/26 20:03, David Hildenbrand (Arm) wrote:
> As raised by Matthew, the entire code block is dead code:
> https://lore.kernel.org/linux-mm/20260212014611.416695-1-dave@stgolabs.net/
> 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
Re: [PATCH] mm/migrate_device: fix double unlock
Posted by Balbir Singh 2 months, 1 week ago
On 4/14/26 20:03, David Hildenbrand (Arm) wrote:
> On 4/13/26 23:15, Sunny Patel wrote:
>> 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")
>>
>> Cc: stable@vger.kernel.org
>>
>> Signed-off-by: Sunny Patel <nueralspacetech@gmail.com>
>> ---
>>  mm/migrate_device.c | 1 -
>>  1 file changed, 1 deletion(-)
>>
>> diff --git a/mm/migrate_device.c b/mm/migrate_device.c
>> index 8079676c8f1f..7eb2f87ea39d 100644
>> --- a/mm/migrate_device.c
>> +++ b/mm/migrate_device.c
>> @@ -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/20260212014611.416695-1-dave@stgolabs.net/
> 
> And I even Ack'ed it /facepalm
> 
> So we should take that (cleanup) patch instead. Thanks!
> 

+1

Balbir