diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-06 21:23:36 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-03-06 21:23:36 -0500 |
commit | 097d59106a8e4b42d07c9892fdd7790f1659c6ff (patch) | |
tree | babf61a0287b0f09f80580847274877831ed6869 /mm/mlock.c | |
parent | 71fece9511717750d86691e0f517ad04f3c8a801 (diff) |
vm: avoid using find_vma_prev() unnecessarily
Several users of "find_vma_prev()" were not in fact interested in the
previous vma if there was no primary vma to be found either. And in
those cases, we're much better off just using the regular "find_vma()",
and then "prev" can be looked up by just checking vma->vm_prev.
The find_vma_prev() semantics are fairly subtle (see Mikulas' recent
commit 83cd904d271b: "mm: fix find_vma_prev"), and the whole "return
prev by reference" means that it generates worse code too.
Thus this "let's avoid using this inconvenient and clearly too subtle
interface when we don't really have to" patch.
Cc: Mikulas Patocka <mpatocka@redhat.com>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/mlock.c')
-rw-r--r-- | mm/mlock.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/mlock.c b/mm/mlock.c index 4f4f53bdc65d..ef726e8aa8e9 100644 --- a/mm/mlock.c +++ b/mm/mlock.c | |||
@@ -385,10 +385,11 @@ static int do_mlock(unsigned long start, size_t len, int on) | |||
385 | return -EINVAL; | 385 | return -EINVAL; |
386 | if (end == start) | 386 | if (end == start) |
387 | return 0; | 387 | return 0; |
388 | vma = find_vma_prev(current->mm, start, &prev); | 388 | vma = find_vma(current->mm, start); |
389 | if (!vma || vma->vm_start > start) | 389 | if (!vma || vma->vm_start > start) |
390 | return -ENOMEM; | 390 | return -ENOMEM; |
391 | 391 | ||
392 | prev = vma->vm_prev; | ||
392 | if (start > vma->vm_start) | 393 | if (start > vma->vm_start) |
393 | prev = vma; | 394 | prev = vma; |
394 | 395 | ||