diff mbox series

mm: mmap: remove verify_mm_writelocked()

Message ID 20181108174856.10811-1-tiny.windzz@gmail.com (mailing list archive)
State New, archived
Headers show
Series mm: mmap: remove verify_mm_writelocked() | expand

Commit Message

Yangtao Li Nov. 8, 2018, 5:48 p.m. UTC
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.

Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>
---
 mm/mmap.c | 16 ----------------
 1 file changed, 16 deletions(-)

Comments

Michal Hocko Nov. 8, 2018, 5:53 p.m. UTC | #1
On Thu 08-11-18 12:48:56, Yangtao Li wrote:
> 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.
> 
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/mmap.c | 16 ----------------
>  1 file changed, 16 deletions(-)
> 
> diff --git a/mm/mmap.c b/mm/mmap.c
> index f7cd9cb966c0..1cee506494d2 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -2910,16 +2910,6 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
>  	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
> @@ -2946,12 +2936,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
>  	 */
> -- 
> 2.17.0
>
David Rientjes Nov. 14, 2018, 10:20 p.m. UTC | #2
On Thu, 8 Nov 2018, Yangtao Li wrote:

> 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.
> 
> Signed-off-by: Yangtao Li <tiny.windzz@gmail.com>

Acked-by: David Rientjes <rientjes@google.com>
diff mbox series

Patch

diff --git a/mm/mmap.c b/mm/mmap.c
index f7cd9cb966c0..1cee506494d2 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2910,16 +2910,6 @@  SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
 	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
@@ -2946,12 +2936,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
 	 */