提交 f7977793 编写于 作者: J Jason Baron 提交者: Linus Torvalds

speed up madvise_need_mmap_write() usage

In the new madvise_need_mmap_write() call we can avoid an extra case
statement and function call as follows.
Signed-off-by: NJason Baron <jbaron@redhat.com>
Cc: Nishanth Aravamudan <nacc@us.ibm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 897e679b
...@@ -287,9 +287,11 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior) ...@@ -287,9 +287,11 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
struct vm_area_struct * vma, *prev; struct vm_area_struct * vma, *prev;
int unmapped_error = 0; int unmapped_error = 0;
int error = -EINVAL; int error = -EINVAL;
int write;
size_t len; size_t len;
if (madvise_need_mmap_write(behavior)) write = madvise_need_mmap_write(behavior);
if (write)
down_write(&current->mm->mmap_sem); down_write(&current->mm->mmap_sem);
else else
down_read(&current->mm->mmap_sem); down_read(&current->mm->mmap_sem);
...@@ -354,7 +356,7 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior) ...@@ -354,7 +356,7 @@ asmlinkage long sys_madvise(unsigned long start, size_t len_in, int behavior)
vma = find_vma(current->mm, start); vma = find_vma(current->mm, start);
} }
out: out:
if (madvise_need_mmap_write(behavior)) if (write)
up_write(&current->mm->mmap_sem); up_write(&current->mm->mmap_sem);
else else
up_read(&current->mm->mmap_sem); up_read(&current->mm->mmap_sem);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册