linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Hugh Dickins <hughd@google.com>,
	 Andrea Arcangeli <aarcange@redhat.com>,
	linux-mm@kvack.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/ksm: Don't WARN if page is still mapped in remove_stable_node()
Date: Wed, 20 Nov 2019 20:12:13 -0800 (PST)	[thread overview]
Message-ID: <alpine.LSU.2.11.1911202007550.1733@eggly.anvils> (raw)
In-Reply-To: <20191119131850.5675-1-aryabinin@virtuozzo.com>

On Tue, 19 Nov 2019, Andrey Ryabinin wrote:

> It's possible to hit the WARN_ON_ONCE(page_mapped(page)) in
> remove_stable_node() when it races with __mmput() and squeezes
> in between ksm_exit() and exit_mmap().
> 
>  WARNING: CPU: 0 PID: 3295 at mm/ksm.c:888 remove_stable_node+0x10c/0x150
> 
>  Call Trace:
>   remove_all_stable_nodes+0x12b/0x330
>   run_store+0x4ef/0x7b0
>   kernfs_fop_write+0x200/0x420
>   vfs_write+0x154/0x450
>   ksys_write+0xf9/0x1d0
>   do_syscall_64+0x99/0x510
>   entry_SYSCALL_64_after_hwframe+0x49/0xbe
> 
> Remove the warning as there is nothing scary going on.
> 
> Fixes: cbf86cfe04a6 ("ksm: remove old stable nodes more thoroughly")
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>

Thanks -
Acked-by: Hugh Dickins <hughd@google.com>

> Cc: <stable@vger.kernel.org>

For removing a WARN_ON_ONCE? No, I don't think this needs to go to
stable; but I won't resist if Andrew or autobot insist otherwise.

> ---
>  mm/ksm.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/mm/ksm.c b/mm/ksm.c
> index dbee2eb4dd05..7905934cd3ad 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -885,13 +885,13 @@ static int remove_stable_node(struct stable_node *stable_node)
>  		return 0;
>  	}
>  
> -	if (WARN_ON_ONCE(page_mapped(page))) {
> -		/*
> -		 * This should not happen: but if it does, just refuse to let
> -		 * merge_across_nodes be switched - there is no need to panic.
> -		 */
> -		err = -EBUSY;
> -	} else {
> +	/*
> +	 * Page could be still mapped if this races with __mmput() running in
> +	 * between ksm_exit() and exit_mmap(). Just refuse to let
> +	 * merge_across_nodes/max_page_sharing be switched.

Good comment, thank you.

> +	 */
> +	err = -EBUSY;
> +	if (!page_mapped(page)) {
>  		/*
>  		 * The stable node did not yet appear stale to get_ksm_page(),
>  		 * since that allows for an unmapped ksm page to be recognized
> -- 
> 2.23.0


      reply	other threads:[~2019-11-21  4:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-19 13:18 Andrey Ryabinin
2019-11-21  4:12 ` Hugh Dickins [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=alpine.LSU.2.11.1911202007550.1733@eggly.anvils \
    --to=hughd@google.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=aryabinin@virtuozzo.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