Skip to content

Commit

Permalink
speed up madvise_need_mmap_write() usage
Browse files Browse the repository at this point in the history
In the new madvise_need_mmap_write() call we can avoid an extra case
statement and function call as follows.

Signed-off-by: Jason Baron <[email protected]>
Cc: Nishanth Aravamudan <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Nick Piggin <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
jibaron authored and Linus Torvalds committed Jul 16, 2007
1 parent 897e679 commit f797779
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,11 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
struct vm_area_struct * vma, *prev;
int unmapped_error = 0;
int error = -EINVAL;
int write;
size_t len;

if (madvise_need_mmap_write(behavior))
write = madvise_need_mmap_write(behavior);
if (write)
down_write(&current->mm->mmap_sem);
else
down_read(&current->mm->mmap_sem);
Expand Down Expand Up @@ -354,7 +356,7 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
vma = find_vma(current->mm, start);
}
out:
if (madvise_need_mmap_write(behavior))
if (write)
up_write(&current->mm->mmap_sem);
else
up_read(&current->mm->mmap_sem);
Expand Down

0 comments on commit f797779

Please sign in to comment.