linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miaohe Lin <linmiaohe@huawei.com>
To: Hugh Dickins <hughd@google.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: <linux-kernel@vger.kernel.org>, <linux-mm@kvack.org>
Subject: Re: [PATCH] ksm: Revert "use GET_KSM_PAGE_NOLOCK to get ksm page in remove_rmap_item_from_tree()"
Date: Mon, 10 May 2021 14:57:06 +0800	[thread overview]
Message-ID: <0e04877c-5b2d-b810-7464-108e793b84d3@huawei.com> (raw)
In-Reply-To: <alpine.LSU.2.11.2105092253500.1127@eggly.anvils>

On 2021/5/10 13:59, Hugh Dickins wrote:
> This reverts commit 3e96b6a2e9ad929a3230a22f4d64a74671a0720b.
> General Protection Fault in rmap_walk_ksm() under memory pressure:
> remove_rmap_item_from_tree() needs to take page lock, of course.
> 

I'am really sorry about it! And many thanks for this bugfix!
It seems rmap_walk_ksm() relies on the page lock to protect against
concurrent modifications to that page's node of the stable tree.
Could you please add a comment in remove_rmap_item_from_tree() to
clarify this in case similar trouble again? Many thanks!

> Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
> 
>  mm/ksm.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> --- 5.13-rc1/mm/ksm.c	2021-05-09 17:03:44.010422188 -0700
> +++ linux/mm/ksm.c	2021-05-09 22:12:39.403008350 -0700
> @@ -776,11 +776,12 @@ static void remove_rmap_item_from_tree(s
>  		struct page *page;
>  
>  		stable_node = rmap_item->head;
> -		page = get_ksm_page(stable_node, GET_KSM_PAGE_NOLOCK);
> +		page = get_ksm_page(stable_node, GET_KSM_PAGE_LOCK);
>  		if (!page)
>  			goto out;
>  
>  		hlist_del(&rmap_item->hlist);
> +		unlock_page(page);
>  		put_page(page);
>  
>  		if (!hlist_empty(&stable_node->hlist))
> .
> 


  reply	other threads:[~2021-05-10  6:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-10  5:59 [PATCH] ksm: Revert "use GET_KSM_PAGE_NOLOCK to get ksm page in remove_rmap_item_from_tree()" Hugh Dickins
2021-05-10  6:57 ` Miaohe Lin [this message]
2021-05-10 23:42   ` Hugh Dickins
2021-05-11  1:40     ` 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=0e04877c-5b2d-b810-7464-108e793b84d3@huawei.com \
    --to=linmiaohe@huawei.com \
    --cc=akpm@linux-foundation.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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;
as well as URLs for NNTP newsgroup(s).