diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-20 18:35:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-20 20:28:17 -0400 |
commit | e4eb1ff61b323d6141614e5458a1f53c7046ff8e (patch) | |
tree | 7a0251509c169b0df1a6bf4bc47c5bca709e06da /mm/mmap.c | |
parent | 3b422e9c2c020a1137349c614da7f9c9761a0922 (diff) |
VM: add "vm_brk()" helper function
It does the same thing as "do_brk()", except it handles the VM locking
too.
It turns out that all external callers want that anyway, so we can make
do_brk() static to just mm/mmap.c while at it.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/mmap.c')
-rw-r--r-- | mm/mmap.c | 16 |
1 files changed, 14 insertions, 2 deletions
@@ -240,6 +240,8 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma) | |||
240 | return next; | 240 | return next; |
241 | } | 241 | } |
242 | 242 | ||
243 | static unsigned long do_brk(unsigned long addr, unsigned long len); | ||
244 | |||
243 | SYSCALL_DEFINE1(brk, unsigned long, brk) | 245 | SYSCALL_DEFINE1(brk, unsigned long, brk) |
244 | { | 246 | { |
245 | unsigned long rlim, retval; | 247 | unsigned long rlim, retval; |
@@ -2136,7 +2138,7 @@ static inline void verify_mm_writelocked(struct mm_struct *mm) | |||
2136 | * anonymous maps. eventually we may be able to do some | 2138 | * anonymous maps. eventually we may be able to do some |
2137 | * brk-specific accounting here. | 2139 | * brk-specific accounting here. |
2138 | */ | 2140 | */ |
2139 | unsigned long do_brk(unsigned long addr, unsigned long len) | 2141 | static unsigned long do_brk(unsigned long addr, unsigned long len) |
2140 | { | 2142 | { |
2141 | struct mm_struct * mm = current->mm; | 2143 | struct mm_struct * mm = current->mm; |
2142 | struct vm_area_struct * vma, * prev; | 2144 | struct vm_area_struct * vma, * prev; |
@@ -2232,7 +2234,17 @@ out: | |||
2232 | return addr; | 2234 | return addr; |
2233 | } | 2235 | } |
2234 | 2236 | ||
2235 | EXPORT_SYMBOL(do_brk); | 2237 | unsigned long vm_brk(unsigned long addr, unsigned long len) |
2238 | { | ||
2239 | struct mm_struct *mm = current->mm; | ||
2240 | unsigned long ret; | ||
2241 | |||
2242 | down_write(&mm->mmap_sem); | ||
2243 | ret = do_brk(addr, len); | ||
2244 | up_write(&mm->mmap_sem); | ||
2245 | return ret; | ||
2246 | } | ||
2247 | EXPORT_SYMBOL(vm_brk); | ||
2236 | 2248 | ||
2237 | /* Release all mmaps. */ | 2249 | /* Release all mmaps. */ |
2238 | void exit_mmap(struct mm_struct *mm) | 2250 | void exit_mmap(struct mm_struct *mm) |