linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Yangtao Li <tiny.windzz@gmail.com>
Cc: akpm@linux-foundation.org, kirill.shutemov@linux.intel.com,
	vbabka@suse.cz, yang.shi@linux.alibaba.com, rientjes@google.com,
	linux@dominikbrodowski.net, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm: mmap: remove unnecessary unlikely()
Date: Mon, 5 Nov 2018 07:51:05 +0100	[thread overview]
Message-ID: <20181105065037.GA4361@dhcp22.suse.cz> (raw)
In-Reply-To: <20181104124456.3424-1-tiny.windzz@gmail.com>

On Sun 04-11-18 07:44:56, Yangtao Li wrote:
> WARN_ON() already contains an unlikely(), so it's not necessary to use
> unlikely.

We should just get rid of this ugliness altogether. It no longer serves
its purpose.  This is a historical artifact from 2005 where do_brk
was called outside of the core mm. We do have a proper abstraction in
vm_brk_flags and that one does the locking properly.

> 
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
> ---
>  mm/mmap.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 6c04292e16a7..2077008ade0c 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2965,10 +2965,8 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
>  static inline void verify_mm_writelocked(struct mm_struct *mm)
>  {
>  #ifdef CONFIG_DEBUG_VM
> -	if (unlikely(down_read_trylock(&mm->mmap_sem))) {
> -		WARN_ON(1);
> +	if (WARN_ON(down_read_trylock(&mm->mmap_sem)))
>  		up_read(&mm->mmap_sem);
> -	}
>  #endif
>  }
>  
> -- 
> 2.17.0
> 

-- 
Michal Hocko
SUSE Labs

      reply	other threads:[~2018-11-05  6:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-04 12:44 [PATCH] mm: mmap: remove unnecessary unlikely() Yangtao Li
2018-11-05  6:51 ` Michal Hocko [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=20181105065037.GA4361@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@dominikbrodowski.net \
    --cc=rientjes@google.com \
    --cc=tiny.windzz@gmail.com \
    --cc=vbabka@suse.cz \
    --cc=yang.shi@linux.alibaba.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;
as well as URLs for NNTP newsgroup(s).