summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRajesh Venkatasubramanian <vrajesh@umich.edu>2004-08-22 22:57:07 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-08-22 22:57:07 -0700
commit86de37f0de2be6b0c51c0210dd6533177353f864 (patch)
treeb0b20494f4b84df74d8ef79c7ec1d40b1e907566 /include
parente66c6753333b9c2b1cf5daf0b73814b5fdb09c41 (diff)
[PATCH] prio_tree: iterator + vma_prio_tree_next cleanup
Currently we have: while ((vma = vma_prio_tree_next(vma, root, &iter, begin, end)) != NULL) do_something_with(vma); Then iter,root,begin,end are all transfered unchanged to various functions. This patch hides them in struct iter instead. It slightly lessens source, code size, and stack usage. Patch compiles and tested lightly. Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Signed-off-by: Rajesh Venkatasubramanian <vrajesh@umich.edu> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include')
-rw-r--r--include/linux/mm.h9
-rw-r--r--include/linux/prio_tree.h12
2 files changed, 18 insertions, 3 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 0e30d4079c8a..fc8716245294 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -602,9 +602,12 @@ extern void si_meminfo_node(struct sysinfo *val, int nid);
void vma_prio_tree_add(struct vm_area_struct *, struct vm_area_struct *old);
void vma_prio_tree_insert(struct vm_area_struct *, struct prio_tree_root *);
void vma_prio_tree_remove(struct vm_area_struct *, struct prio_tree_root *);
-struct vm_area_struct *vma_prio_tree_next(
- struct vm_area_struct *, struct prio_tree_root *,
- struct prio_tree_iter *, pgoff_t begin, pgoff_t end);
+struct vm_area_struct *vma_prio_tree_next(struct vm_area_struct *vma,
+ struct prio_tree_iter *iter);
+
+#define vma_prio_tree_foreach(vma, iter, root, begin, end) \
+ for (prio_tree_iter_init(iter, root, begin, end), vma = NULL; \
+ (vma = vma_prio_tree_next(vma, iter)); )
static inline void vma_nonlinear_insert(struct vm_area_struct *vma,
struct list_head *list)
diff --git a/include/linux/prio_tree.h b/include/linux/prio_tree.h
index 4ac5c62693ec..6356a511f9ee 100644
--- a/include/linux/prio_tree.h
+++ b/include/linux/prio_tree.h
@@ -17,8 +17,20 @@ struct prio_tree_iter {
unsigned long mask;
unsigned long value;
int size_level;
+
+ struct prio_tree_root *root;
+ pgoff_t r_index;
+ pgoff_t h_index;
};
+static inline void prio_tree_iter_init(struct prio_tree_iter *iter,
+ struct prio_tree_root *root, pgoff_t r_index, pgoff_t h_index)
+{
+ iter->root = root;
+ iter->r_index = r_index;
+ iter->h_index = h_index;
+}
+
#define INIT_PRIO_TREE_ROOT(ptr) \
do { \
(ptr)->prio_tree_node = NULL; \