mm: mmap: remove unnecessary unlikely()
Subsystems (2)
PATCH 1/1 mm: mmap: remove unnecessary unlikely()
WARN_ON() already contains an unlikely(), so it's not necessary to use unlikely.
Signed-off-by Yangtao Li <[email protected]>
--- mm/mmap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
mm/mmap.c +1 -3
@@ -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 }
Signature · 1 line
2.17.0
Quoted 2 lines · Yangtao Li
WARN_ON()already contains anunlikely(), 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.
Quoted 25 lines
Signed-off-by Yangtao Li <[email protected]>--- mm/mmap.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)mm/mmap.c +1
-3@@ -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 }Signature · 1 line
2.17.0
Signature · 2 lines
Michal Hocko SUSE Labs