diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-20 19:20:01 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-04-20 20:29:13 -0400 |
commit | a46ef99d80817a167477ed1c8b4d90ee0c2e726f (patch) | |
tree | 3d8c980c627e8b9c009dbf63628a9be8b8d1069f /arch | |
parent | e4eb1ff61b323d6141614e5458a1f53c7046ff8e (diff) |
VM: add "vm_munmap()" helper function
Like the vm_brk() function, this is the same as "do_munmap()", except it
does the VM locking for the caller.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/ia64/kernel/perfmon.c | 11 | ||||
-rw-r--r-- | arch/sparc/kernel/sys_sparc_64.c | 7 | ||||
-rw-r--r-- | arch/x86/kvm/x86.c | 4 |
3 files changed, 5 insertions, 17 deletions
diff --git a/arch/ia64/kernel/perfmon.c b/arch/ia64/kernel/perfmon.c index 9d0fd7d5bb82..2777310b698b 100644 --- a/arch/ia64/kernel/perfmon.c +++ b/arch/ia64/kernel/perfmon.c | |||
@@ -605,9 +605,9 @@ pfm_unprotect_ctx_ctxsw(pfm_context_t *x, unsigned long f) | |||
605 | } | 605 | } |
606 | 606 | ||
607 | static inline unsigned int | 607 | static inline unsigned int |
608 | pfm_do_munmap(struct mm_struct *mm, unsigned long addr, size_t len, int acct) | 608 | pfm_vm_munmap(struct mm_struct *mm, unsigned long addr, size_t len) |
609 | { | 609 | { |
610 | return do_munmap(mm, addr, len); | 610 | return vm_munmap(mm, addr, len); |
611 | } | 611 | } |
612 | 612 | ||
613 | static inline unsigned long | 613 | static inline unsigned long |
@@ -1473,13 +1473,8 @@ pfm_remove_smpl_mapping(struct task_struct *task, void *vaddr, unsigned long siz | |||
1473 | /* | 1473 | /* |
1474 | * does the actual unmapping | 1474 | * does the actual unmapping |
1475 | */ | 1475 | */ |
1476 | down_write(&task->mm->mmap_sem); | 1476 | r = pfm_vm_munmap(task->mm, (unsigned long)vaddr, size); |
1477 | |||
1478 | DPRINT(("down_write done smpl_vaddr=%p size=%lu\n", vaddr, size)); | ||
1479 | 1477 | ||
1480 | r = pfm_do_munmap(task->mm, (unsigned long)vaddr, size, 0); | ||
1481 | |||
1482 | up_write(&task->mm->mmap_sem); | ||
1483 | if (r !=0) { | 1478 | if (r !=0) { |
1484 | printk(KERN_ERR "perfmon: [%d] unable to unmap sampling buffer @%p size=%lu\n", task_pid_nr(task), vaddr, size); | 1479 | printk(KERN_ERR "perfmon: [%d] unable to unmap sampling buffer @%p size=%lu\n", task_pid_nr(task), vaddr, size); |
1485 | } | 1480 | } |
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index 232df9949530..022e57aadf5d 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c | |||
@@ -566,15 +566,10 @@ out: | |||
566 | 566 | ||
567 | SYSCALL_DEFINE2(64_munmap, unsigned long, addr, size_t, len) | 567 | SYSCALL_DEFINE2(64_munmap, unsigned long, addr, size_t, len) |
568 | { | 568 | { |
569 | long ret; | ||
570 | |||
571 | if (invalid_64bit_range(addr, len)) | 569 | if (invalid_64bit_range(addr, len)) |
572 | return -EINVAL; | 570 | return -EINVAL; |
573 | 571 | ||
574 | down_write(¤t->mm->mmap_sem); | 572 | return vm_munmap(current->mm, addr, len); |
575 | ret = do_munmap(current->mm, addr, len); | ||
576 | up_write(¤t->mm->mmap_sem); | ||
577 | return ret; | ||
578 | } | 573 | } |
579 | 574 | ||
580 | extern unsigned long do_mremap(unsigned long addr, | 575 | extern unsigned long do_mremap(unsigned long addr, |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4044ce0bf7c1..8beb9ce79364 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
@@ -6366,10 +6366,8 @@ void kvm_arch_commit_memory_region(struct kvm *kvm, | |||
6366 | if (!user_alloc && !old.user_alloc && old.rmap && !npages) { | 6366 | if (!user_alloc && !old.user_alloc && old.rmap && !npages) { |
6367 | int ret; | 6367 | int ret; |
6368 | 6368 | ||
6369 | down_write(¤t->mm->mmap_sem); | 6369 | ret = vm_munmap(current->mm, old.userspace_addr, |
6370 | ret = do_munmap(current->mm, old.userspace_addr, | ||
6371 | old.npages * PAGE_SIZE); | 6370 | old.npages * PAGE_SIZE); |
6372 | up_write(¤t->mm->mmap_sem); | ||
6373 | if (ret < 0) | 6371 | if (ret < 0) |
6374 | printk(KERN_WARNING | 6372 | printk(KERN_WARNING |
6375 | "kvm_vm_ioctl_set_memory_region: " | 6373 | "kvm_vm_ioctl_set_memory_region: " |