mm/mmap.c: remove verify_mm_writelocked()
authorYangtao Li <tiny.windzz@gmail.com>
Fri, 28 Dec 2018 08:34:09 +0000 (00:34 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 28 Dec 2018 20:11:47 +0000 (12:11 -0800)
We should get rid of this function.  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 so there is no need to use this function.

Link: http://lkml.kernel.org/r/20181108174856.10811-1-tiny.windzz@gmail.com
Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: David Rientjes <rientjes@google.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/mmap.c

index 7bb6438..f901065 100644 (file)
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2973,16 +2973,6 @@ out:
        return ret;
 }
 
-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);
-               up_read(&mm->mmap_sem);
-       }
-#endif
-}
-
 /*
  *  this is really a simplified "do_mmap".  it only handles
  *  anonymous maps.  eventually we may be able to do some
@@ -3009,12 +2999,6 @@ static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long fla
        if (error)
                return error;
 
-       /*
-        * mm->mmap_sem is required to protect against another thread
-        * changing the mappings in case we sleep.
-        */
-       verify_mm_writelocked(mm);
-
        /*
         * Clear old maps.  this also does some error checking for us
         */