linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Miaohe Lin <linmiaohe@huawei.com>
Cc: <mike.kravetz@oracle.com>, <shakeelb@google.com>,
	<hannes@cmpxchg.org>, <vbabka@suse.cz>, <walken@google.com>,
	<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/rmap: Fix potential pte_unmap on an not mapped pte
Date: Wed, 27 Jan 2021 16:09:21 -0800	[thread overview]
Message-ID: <20210127160921.989f01c83d6703148f6bc316@linux-foundation.org> (raw)
In-Reply-To: <20210127093349.39081-1-linmiaohe@huawei.com>

On Wed, 27 Jan 2021 04:33:49 -0500 Miaohe Lin <linmiaohe@huawei.com> wrote:

> For PMD-mapped page (usually THP), pvmw->pte is NULL. For PTE-mapped THP,
> pvmw->pte is mapped. But for HugeTLB pages, pvmw->pte is not mapped and set
> to the relevant page table entry. So in page_vma_mapped_walk_done(), we may
> do pte_unmap() for HugeTLB pte which is not mapped. Fix this by checking
> pvmw->page against PageHuge before trying to do pte_unmap().
> 

What are the runtime consequences of this?  Is there a workload which
is known to trigger it?

IOW, how do we justify a -stable backport of this fix?

>
> --- a/include/linux/rmap.h
> +++ b/include/linux/rmap.h
> @@ -213,7 +213,8 @@ struct page_vma_mapped_walk {
>  
>  static inline void page_vma_mapped_walk_done(struct page_vma_mapped_walk *pvmw)
>  {
> -	if (pvmw->pte)
> +	/* HugeTLB pte is set to the relevant page table entry without pte_mapped. */
> +	if (pvmw->pte && !PageHuge(pvmw->page))
>  		pte_unmap(pvmw->pte);
>  	if (pvmw->ptl)
>  		spin_unlock(pvmw->ptl);
> -- 
> 2.19.1


  reply	other threads:[~2021-01-28  0:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27  9:33 Miaohe Lin
2021-01-28  0:09 ` Andrew Morton [this message]
2021-01-28  1:54   ` Miaohe Lin

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=20210127160921.989f01c83d6703148f6bc316@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=shakeelb@google.com \
    --cc=vbabka@suse.cz \
    --cc=walken@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox