All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/memory_failure: Fix the missing pte_unmap() call
@ 2021-09-23 12:26 Qi Zheng
  2021-09-23 15:19 ` David Hildenbrand
  2021-09-23 23:17 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Qi Zheng @ 2021-09-23 12:26 UTC (permalink / raw)
  To: naoya.horiguchi, akpm; +Cc: linux-mm, linux-kernel, songmuchun, Qi Zheng

The paired pte_unmap() call is missing before the
dev_pagemap_mapping_shift() returns. So fix it.

Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
---
 mm/memory-failure.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index e2984c123e7e..4e5419f16fd4 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -306,6 +306,7 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
 		struct vm_area_struct *vma)
 {
 	unsigned long address = vma_address(page, vma);
+	unsigned long ret = 0;
 	pgd_t *pgd;
 	p4d_t *p4d;
 	pud_t *pud;
@@ -330,10 +331,12 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
 		return PMD_SHIFT;
 	pte = pte_offset_map(pmd, address);
 	if (!pte_present(*pte))
-		return 0;
+		goto unmap;
 	if (pte_devmap(*pte))
-		return PAGE_SHIFT;
-	return 0;
+		ret = PAGE_SHIFT;
+unmap:
+	pte_unmap(pte);
+	return ret;
 }
 
 /*
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/memory_failure: Fix the missing pte_unmap() call
  2021-09-23 12:26 [PATCH] mm/memory_failure: Fix the missing pte_unmap() call Qi Zheng
@ 2021-09-23 15:19 ` David Hildenbrand
  2021-09-23 15:30   ` Qi Zheng
  2021-09-23 23:17 ` Andrew Morton
  1 sibling, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2021-09-23 15:19 UTC (permalink / raw)
  To: Qi Zheng, naoya.horiguchi, akpm; +Cc: linux-mm, linux-kernel, songmuchun

On 23.09.21 14:26, Qi Zheng wrote:
> The paired pte_unmap() call is missing before the
> dev_pagemap_mapping_shift() returns. So fix it.
> 
> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
> ---
>   mm/memory-failure.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index e2984c123e7e..4e5419f16fd4 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -306,6 +306,7 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
>   		struct vm_area_struct *vma)
>   {
>   	unsigned long address = vma_address(page, vma);
> +	unsigned long ret = 0;
>   	pgd_t *pgd;
>   	p4d_t *p4d;
>   	pud_t *pud;
> @@ -330,10 +331,12 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
>   		return PMD_SHIFT;
>   	pte = pte_offset_map(pmd, address);
>   	if (!pte_present(*pte))
> -		return 0;
> +		goto unmap;
>   	if (pte_devmap(*pte))
> -		return PAGE_SHIFT;
> -	return 0;
> +		ret = PAGE_SHIFT;
> +unmap:
> +	pte_unmap(pte);
> +	return ret;
>   }
>   
>   /*
> 

I guess this code never runs on 32bit / highmem, that's why we didn't 
notice so far.

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/memory_failure: Fix the missing pte_unmap() call
  2021-09-23 15:19 ` David Hildenbrand
@ 2021-09-23 15:30   ` Qi Zheng
  0 siblings, 0 replies; 6+ messages in thread
From: Qi Zheng @ 2021-09-23 15:30 UTC (permalink / raw)
  To: David Hildenbrand, naoya.horiguchi, akpm
  Cc: linux-mm, linux-kernel, songmuchun



On 9/23/21 11:19 PM, David Hildenbrand wrote:
> On 23.09.21 14:26, Qi Zheng wrote:
>> The paired pte_unmap() call is missing before the
>> dev_pagemap_mapping_shift() returns. So fix it.
>>
>> Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
>> ---
>>   mm/memory-failure.c | 9 ++++++---
>>   1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index e2984c123e7e..4e5419f16fd4 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -306,6 +306,7 @@ static unsigned long 
>> dev_pagemap_mapping_shift(struct page *page,
>>           struct vm_area_struct *vma)
>>   {
>>       unsigned long address = vma_address(page, vma);
>> +    unsigned long ret = 0;
>>       pgd_t *pgd;
>>       p4d_t *p4d;
>>       pud_t *pud;
>> @@ -330,10 +331,12 @@ static unsigned long 
>> dev_pagemap_mapping_shift(struct page *page,
>>           return PMD_SHIFT;
>>       pte = pte_offset_map(pmd, address);
>>       if (!pte_present(*pte))
>> -        return 0;
>> +        goto unmap;
>>       if (pte_devmap(*pte))
>> -        return PAGE_SHIFT;
>> -    return 0;
>> +        ret = PAGE_SHIFT;
>> +unmap:
>> +    pte_unmap(pte);
>> +    return ret;
>>   }
>>   /*
>>
> 
> I guess this code never runs on 32bit / highmem, that's why we didn't 
> notice so far.

I guess so too.

> 
> Reviewed-by: David Hildenbrand <david@redhat.com>
> 

Thanks,
Qi


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/memory_failure: Fix the missing pte_unmap() call
  2021-09-23 12:26 [PATCH] mm/memory_failure: Fix the missing pte_unmap() call Qi Zheng
  2021-09-23 15:19 ` David Hildenbrand
@ 2021-09-23 23:17 ` Andrew Morton
  2021-09-24  0:31   ` Naoya Horiguchi
  2021-09-24  2:24   ` Qi Zheng
  1 sibling, 2 replies; 6+ messages in thread
From: Andrew Morton @ 2021-09-23 23:17 UTC (permalink / raw)
  To: Qi Zheng; +Cc: naoya.horiguchi, linux-mm, linux-kernel, songmuchun

On Thu, 23 Sep 2021 20:26:42 +0800 Qi Zheng <zhengqi.arch@bytedance.com> wrote:

> The paired pte_unmap() call is missing before the
> dev_pagemap_mapping_shift() returns. So fix it.
> 
> ...
>
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -306,6 +306,7 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
>  		struct vm_area_struct *vma)
>  {
>  	unsigned long address = vma_address(page, vma);
> +	unsigned long ret = 0;
>  	pgd_t *pgd;
>  	p4d_t *p4d;
>  	pud_t *pud;
> @@ -330,10 +331,12 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
>  		return PMD_SHIFT;
>  	pte = pte_offset_map(pmd, address);
>  	if (!pte_present(*pte))
> -		return 0;
> +		goto unmap;
>  	if (pte_devmap(*pte))
> -		return PAGE_SHIFT;
> -	return 0;
> +		ret = PAGE_SHIFT;
> +unmap:
> +	pte_unmap(pte);
> +	return ret;
>  }
>  

This is neater?

+++ a/mm/memory-failure.c
@@ -330,11 +330,8 @@ static unsigned long dev_pagemap_mapping
 	if (pmd_devmap(*pmd))
 		return PMD_SHIFT;
 	pte = pte_offset_map(pmd, address);
-	if (!pte_present(*pte))
-		goto unmap;
-	if (pte_devmap(*pte))
+	if (pte_present(*pte) && pte_devmap(*pte))
 		ret = PAGE_SHIFT;
-unmap:
 	pte_unmap(pte);
 	return ret;
 }
_


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/memory_failure: Fix the missing pte_unmap() call
  2021-09-23 23:17 ` Andrew Morton
@ 2021-09-24  0:31   ` Naoya Horiguchi
  2021-09-24  2:24   ` Qi Zheng
  1 sibling, 0 replies; 6+ messages in thread
From: Naoya Horiguchi @ 2021-09-24  0:31 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Qi Zheng, naoya.horiguchi, linux-mm, linux-kernel, songmuchun

On Thu, Sep 23, 2021 at 04:17:38PM -0700, Andrew Morton wrote:
> On Thu, 23 Sep 2021 20:26:42 +0800 Qi Zheng <zhengqi.arch@bytedance.com> wrote:
> 
> > The paired pte_unmap() call is missing before the
> > dev_pagemap_mapping_shift() returns. So fix it.
> > 
> > ...
> >
> > --- a/mm/memory-failure.c
> > +++ b/mm/memory-failure.c
> > @@ -306,6 +306,7 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
> >  		struct vm_area_struct *vma)
> >  {
> >  	unsigned long address = vma_address(page, vma);
> > +	unsigned long ret = 0;
> >  	pgd_t *pgd;
> >  	p4d_t *p4d;
> >  	pud_t *pud;
> > @@ -330,10 +331,12 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
> >  		return PMD_SHIFT;
> >  	pte = pte_offset_map(pmd, address);
> >  	if (!pte_present(*pte))
> > -		return 0;
> > +		goto unmap;
> >  	if (pte_devmap(*pte))
> > -		return PAGE_SHIFT;
> > -	return 0;
> > +		ret = PAGE_SHIFT;
> > +unmap:
> > +	pte_unmap(pte);
> > +	return ret;
> >  }
> >  
> 
> This is neater?
> 
> +++ a/mm/memory-failure.c
> @@ -330,11 +330,8 @@ static unsigned long dev_pagemap_mapping
>  	if (pmd_devmap(*pmd))
>  		return PMD_SHIFT;
>  	pte = pte_offset_map(pmd, address);
> -	if (!pte_present(*pte))
> -		goto unmap;
> -	if (pte_devmap(*pte))
> +	if (pte_present(*pte) && pte_devmap(*pte))
>  		ret = PAGE_SHIFT;
> -unmap:

This neater one looks good to me.

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm/memory_failure: Fix the missing pte_unmap() call
  2021-09-23 23:17 ` Andrew Morton
  2021-09-24  0:31   ` Naoya Horiguchi
@ 2021-09-24  2:24   ` Qi Zheng
  1 sibling, 0 replies; 6+ messages in thread
From: Qi Zheng @ 2021-09-24  2:24 UTC (permalink / raw)
  To: Andrew Morton; +Cc: naoya.horiguchi, linux-mm, linux-kernel, songmuchun



On 9/24/21 7:17 AM, Andrew Morton wrote:
> On Thu, 23 Sep 2021 20:26:42 +0800 Qi Zheng <zhengqi.arch@bytedance.com> wrote:
> 
>> The paired pte_unmap() call is missing before the
>> dev_pagemap_mapping_shift() returns. So fix it.
>>
>> ...
>>
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -306,6 +306,7 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
>>   		struct vm_area_struct *vma)
>>   {
>>   	unsigned long address = vma_address(page, vma);
>> +	unsigned long ret = 0;
>>   	pgd_t *pgd;
>>   	p4d_t *p4d;
>>   	pud_t *pud;
>> @@ -330,10 +331,12 @@ static unsigned long dev_pagemap_mapping_shift(struct page *page,
>>   		return PMD_SHIFT;
>>   	pte = pte_offset_map(pmd, address);
>>   	if (!pte_present(*pte))
>> -		return 0;
>> +		goto unmap;
>>   	if (pte_devmap(*pte))
>> -		return PAGE_SHIFT;
>> -	return 0;
>> +		ret = PAGE_SHIFT;
>> +unmap:
>> +	pte_unmap(pte);
>> +	return ret;
>>   }
>>   
> 
> This is neater?

Yes, and I see this neater version has merged into your mm tree,
thanks. :)

> 
> +++ a/mm/memory-failure.c
> @@ -330,11 +330,8 @@ static unsigned long dev_pagemap_mapping
>   	if (pmd_devmap(*pmd))
>   		return PMD_SHIFT;
>   	pte = pte_offset_map(pmd, address);
> -	if (!pte_present(*pte))
> -		goto unmap;
> -	if (pte_devmap(*pte))
> +	if (pte_present(*pte) && pte_devmap(*pte))
>   		ret = PAGE_SHIFT;
> -unmap:
>   	pte_unmap(pte);
>   	return ret;
>   }
> _
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-09-24  2:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-23 12:26 [PATCH] mm/memory_failure: Fix the missing pte_unmap() call Qi Zheng
2021-09-23 15:19 ` David Hildenbrand
2021-09-23 15:30   ` Qi Zheng
2021-09-23 23:17 ` Andrew Morton
2021-09-24  0:31   ` Naoya Horiguchi
2021-09-24  2:24   ` Qi Zheng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.