All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qi Zheng <zhengqi.arch@bytedance.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: naoya.horiguchi@nec.com, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, songmuchun@bytedance.com
Subject: Re: [PATCH] mm/memory_failure: Fix the missing pte_unmap() call
Date: Fri, 24 Sep 2021 10:24:06 +0800	[thread overview]
Message-ID: <2eca94ce-4e26-aff6-240d-39baf1a9cc36@bytedance.com> (raw)
In-Reply-To: <20210923161738.990b61933c96df78bc1bf96d@linux-foundation.org>



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;
>   }
> _
> 

      parent reply	other threads:[~2021-09-24  2:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2eca94ce-4e26-aff6-240d-39baf1a9cc36@bytedance.com \
    --to=zhengqi.arch@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.com \
    --cc=songmuchun@bytedance.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.