Commit f7977793240d836e60ff413e94e6914f08e10941

Authored by Jason Baron
Committed by Linus Torvalds
1 parent 897e679b17

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: Jason 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: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff

... ... @@ -287,9 +287,11 @@
287 287 struct vm_area_struct * vma, *prev;
288 288 int unmapped_error = 0;
289 289 int error = -EINVAL;
  290 + int write;
290 291 size_t len;
291 292  
292   - if (madvise_need_mmap_write(behavior))
  293 + write = madvise_need_mmap_write(behavior);
  294 + if (write)
293 295 down_write(&current->mm->mmap_sem);
294 296 else
295 297 down_read(&current->mm->mmap_sem);
... ... @@ -354,7 +356,7 @@
354 356 vma = find_vma(current->mm, start);
355 357 }
356 358 out:
357   - if (madvise_need_mmap_write(behavior))
  359 + if (write)
358 360 up_write(&current->mm->mmap_sem);
359 361 else
360 362 up_read(&current->mm->mmap_sem);