aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/rbtree.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/rbtree.h')
-rw-r--r--include/linux/rbtree.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 830c4992088d..a5aa7ae671f4 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -101,13 +101,21 @@ static inline void rb_link_node_rcu(struct rb_node *node, struct rb_node *parent
101 }) 101 })
102 102
103/** 103/**
104 * rbtree_postorder_for_each_entry_safe - iterate over rb_root in post order of 104 * rbtree_postorder_for_each_entry_safe - iterate in post-order over rb_root of
105 * given type safe against removal of rb_node entry 105 * given type allowing the backing memory of @pos to be invalidated
106 * 106 *
107 * @pos: the 'type *' to use as a loop cursor. 107 * @pos: the 'type *' to use as a loop cursor.
108 * @n: another 'type *' to use as temporary storage 108 * @n: another 'type *' to use as temporary storage
109 * @root: 'rb_root *' of the rbtree. 109 * @root: 'rb_root *' of the rbtree.
110 * @field: the name of the rb_node field within 'type'. 110 * @field: the name of the rb_node field within 'type'.
111 *
112 * rbtree_postorder_for_each_entry_safe() provides a similar guarantee as
113 * list_for_each_entry_safe() and allows the iteration to continue independent
114 * of changes to @pos by the body of the loop.
115 *
116 * Note, however, that it cannot handle other modifications that re-order the
117 * rbtree it is iterating over. This includes calling rb_erase() on @pos, as
118 * rb_erase() may rebalance the tree, causing us to miss some nodes.
111 */ 119 */
112#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \ 120#define rbtree_postorder_for_each_entry_safe(pos, n, root, field) \
113 for (pos = rb_entry_safe(rb_first_postorder(root), typeof(*pos), field); \ 121 for (pos = rb_entry_safe(rb_first_postorder(root), typeof(*pos), field); \