All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm: mmap: remove unnecessary unlikely()
@ 2018-11-04 12:44 Yangtao Li
  2018-11-05  6:51 ` Michal Hocko
  0 siblings, 1 reply; 2+ messages in thread
From: Yangtao Li @ 2018-11-04 12:44 UTC (permalink / raw)
  To: akpm, mhocko, kirill.shutemov, vbabka, yang.shi, rientjes, linux
  Cc: linux-mm, linux-kernel, Yangtao Li

WARN_ON() already contains an unlikely(), so it's not necessary to use
unlikely.

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: mmap: remove unnecessary unlikely()
  2018-11-04 12:44 [PATCH] mm: mmap: remove unnecessary unlikely() Yangtao Li
@ 2018-11-05  6:51 ` Michal Hocko
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2018-11-05  6:51 UTC (permalink / raw)
  To: Yangtao Li
  Cc: akpm, kirill.shutemov, vbabka, yang.shi, rientjes, linux,
	linux-mm, linux-kernel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-05  6:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-04 12:44 [PATCH] mm: mmap: remove unnecessary unlikely() Yangtao Li
2018-11-05  6:51 ` Michal Hocko

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.