aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mmap.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-04-20 18:35:40 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-04-20 20:28:17 -0400
commite4eb1ff61b323d6141614e5458a1f53c7046ff8e (patch)
tree7a0251509c169b0df1a6bf4bc47c5bca709e06da /mm/mmap.c
parent3b422e9c2c020a1137349c614da7f9c9761a0922 (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.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/mm/mmap.c b/mm/mmap.c
index a7bf6a31c9f6..df51891c8646 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -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
243static unsigned long do_brk(unsigned long addr, unsigned long len);
244
243SYSCALL_DEFINE1(brk, unsigned long, brk) 245SYSCALL_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 */
2139unsigned long do_brk(unsigned long addr, unsigned long len) 2141static 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
2235EXPORT_SYMBOL(do_brk); 2237unsigned 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}
2247EXPORT_SYMBOL(vm_brk);
2236 2248
2237/* Release all mmaps. */ 2249/* Release all mmaps. */
2238void exit_mmap(struct mm_struct *mm) 2250void exit_mmap(struct mm_struct *mm)