diff options
author | Michel Lespinasse <walken@google.com> | 2012-10-08 19:31:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-09 03:22:39 -0400 |
commit | 6b2dbba8b6ac4df26f72eda1e5ea7bab9f950e08 (patch) | |
tree | 422ed8d7ac2fe45069f20cfba84a9a097bf444af /include/linux/mm.h | |
parent | fff3fd8a1210a165252cd7cd01206da7a90d3a06 (diff) |
mm: replace vma prio_tree with an interval tree
Implement an interval tree as a replacement for the VMA prio_tree. The
algorithms are similar to lib/interval_tree.c; however that code can't be
directly reused as the interval endpoints are not explicitly stored in the
VMA. So instead, the common algorithm is moved into a template and the
details (node type, how to get interval endpoints from the node, etc) are
filled in using the C preprocessor.
Once the interval tree functions are available, using them as a
replacement to the VMA prio tree is a relatively simple, mechanical job.
Signed-off-by: Michel Lespinasse <walken@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Hillf Danton <dhillf@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r-- | include/linux/mm.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 5ddb11b2b4bb..0f671ef09eba 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -10,7 +10,6 @@ | |||
10 | #include <linux/list.h> | 10 | #include <linux/list.h> |
11 | #include <linux/mmzone.h> | 11 | #include <linux/mmzone.h> |
12 | #include <linux/rbtree.h> | 12 | #include <linux/rbtree.h> |
13 | #include <linux/prio_tree.h> | ||
14 | #include <linux/atomic.h> | 13 | #include <linux/atomic.h> |
15 | #include <linux/debug_locks.h> | 14 | #include <linux/debug_locks.h> |
16 | #include <linux/mm_types.h> | 15 | #include <linux/mm_types.h> |
@@ -1355,22 +1354,27 @@ extern void zone_pcp_reset(struct zone *zone); | |||
1355 | extern atomic_long_t mmap_pages_allocated; | 1354 | extern atomic_long_t mmap_pages_allocated; |
1356 | extern int nommu_shrink_inode_mappings(struct inode *, size_t, size_t); | 1355 | extern int nommu_shrink_inode_mappings(struct inode *, size_t, size_t); |
1357 | 1356 | ||
1358 | /* prio_tree.c */ | 1357 | /* interval_tree.c */ |
1359 | void vma_prio_tree_add(struct vm_area_struct *, struct vm_area_struct *old); | 1358 | void vma_interval_tree_add(struct vm_area_struct *vma, |
1360 | void vma_prio_tree_insert(struct vm_area_struct *, struct prio_tree_root *); | 1359 | struct vm_area_struct *old, |
1361 | void vma_prio_tree_remove(struct vm_area_struct *, struct prio_tree_root *); | 1360 | struct address_space *mapping); |
1362 | struct vm_area_struct *vma_prio_tree_next(struct vm_area_struct *vma, | 1361 | void vma_interval_tree_insert(struct vm_area_struct *node, |
1363 | struct prio_tree_iter *iter); | 1362 | struct rb_root *root); |
1364 | 1363 | void vma_interval_tree_remove(struct vm_area_struct *node, | |
1365 | #define vma_prio_tree_foreach(vma, iter, root, begin, end) \ | 1364 | struct rb_root *root); |
1366 | for (prio_tree_iter_init(iter, root, begin, end), vma = NULL; \ | 1365 | struct vm_area_struct *vma_interval_tree_iter_first(struct rb_root *root, |
1367 | (vma = vma_prio_tree_next(vma, iter)); ) | 1366 | unsigned long start, unsigned long last); |
1367 | struct vm_area_struct *vma_interval_tree_iter_next(struct vm_area_struct *node, | ||
1368 | unsigned long start, unsigned long last); | ||
1369 | |||
1370 | #define vma_interval_tree_foreach(vma, root, start, last) \ | ||
1371 | for (vma = vma_interval_tree_iter_first(root, start, last); \ | ||
1372 | vma; vma = vma_interval_tree_iter_next(vma, start, last)) | ||
1368 | 1373 | ||
1369 | static inline void vma_nonlinear_insert(struct vm_area_struct *vma, | 1374 | static inline void vma_nonlinear_insert(struct vm_area_struct *vma, |
1370 | struct list_head *list) | 1375 | struct list_head *list) |
1371 | { | 1376 | { |
1372 | vma->shared.vm_set.parent = NULL; | 1377 | list_add_tail(&vma->shared.nonlinear, list); |
1373 | list_add_tail(&vma->shared.vm_set.list, list); | ||
1374 | } | 1378 | } |
1375 | 1379 | ||
1376 | /* mmap.c */ | 1380 | /* mmap.c */ |