diff options
author | Namhyung Kim <namhyung@gmail.com> | 2011-05-24 20:11:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-05-25 11:39:06 -0400 |
commit | e922c4c5360980bfeb862b3ec307d36bb344dcae (patch) | |
tree | e8f4339b198dbb9830ec5313c6cc7ca639704c33 /mm/nommu.c | |
parent | b951bf2c4693bfc9744e11293be859209f65f579 (diff) |
mm: nommu: find vma using the sorted vma list
Now we have the sorted vma list, use it in the find_vma[_exact]() rather
than doing linear search on the rb-tree.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Greg Ungerer <gerg@uclinux.org>
Cc: David Howells <dhowells@redhat.com>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/nommu.c')
-rw-r--r-- | mm/nommu.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/mm/nommu.c b/mm/nommu.c index 2454d39dc068..e5318f8efde5 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -804,17 +804,15 @@ static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma) | |||
804 | struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr) | 804 | struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr) |
805 | { | 805 | { |
806 | struct vm_area_struct *vma; | 806 | struct vm_area_struct *vma; |
807 | struct rb_node *n = mm->mm_rb.rb_node; | ||
808 | 807 | ||
809 | /* check the cache first */ | 808 | /* check the cache first */ |
810 | vma = mm->mmap_cache; | 809 | vma = mm->mmap_cache; |
811 | if (vma && vma->vm_start <= addr && vma->vm_end > addr) | 810 | if (vma && vma->vm_start <= addr && vma->vm_end > addr) |
812 | return vma; | 811 | return vma; |
813 | 812 | ||
814 | /* trawl the tree (there may be multiple mappings in which addr | 813 | /* trawl the list (there may be multiple mappings in which addr |
815 | * resides) */ | 814 | * resides) */ |
816 | for (n = rb_first(&mm->mm_rb); n; n = rb_next(n)) { | 815 | for (vma = mm->mmap; vma; vma = vma->vm_next) { |
817 | vma = rb_entry(n, struct vm_area_struct, vm_rb); | ||
818 | if (vma->vm_start > addr) | 816 | if (vma->vm_start > addr) |
819 | return NULL; | 817 | return NULL; |
820 | if (vma->vm_end > addr) { | 818 | if (vma->vm_end > addr) { |
@@ -854,7 +852,6 @@ static struct vm_area_struct *find_vma_exact(struct mm_struct *mm, | |||
854 | unsigned long len) | 852 | unsigned long len) |
855 | { | 853 | { |
856 | struct vm_area_struct *vma; | 854 | struct vm_area_struct *vma; |
857 | struct rb_node *n = mm->mm_rb.rb_node; | ||
858 | unsigned long end = addr + len; | 855 | unsigned long end = addr + len; |
859 | 856 | ||
860 | /* check the cache first */ | 857 | /* check the cache first */ |
@@ -862,10 +859,9 @@ static struct vm_area_struct *find_vma_exact(struct mm_struct *mm, | |||
862 | if (vma && vma->vm_start == addr && vma->vm_end == end) | 859 | if (vma && vma->vm_start == addr && vma->vm_end == end) |
863 | return vma; | 860 | return vma; |
864 | 861 | ||
865 | /* trawl the tree (there may be multiple mappings in which addr | 862 | /* trawl the list (there may be multiple mappings in which addr |
866 | * resides) */ | 863 | * resides) */ |
867 | for (n = rb_first(&mm->mm_rb); n; n = rb_next(n)) { | 864 | for (vma = mm->mmap; vma; vma = vma->vm_next) { |
868 | vma = rb_entry(n, struct vm_area_struct, vm_rb); | ||
869 | if (vma->vm_start < addr) | 865 | if (vma->vm_start < addr) |
870 | continue; | 866 | continue; |
871 | if (vma->vm_start > addr) | 867 | if (vma->vm_start > addr) |