diff options
author | Peter Zijlstra <peterz@infradead.org> | 2010-05-29 09:31:43 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-07-05 08:43:50 -0400 |
commit | b945d6b2554d550fe95caadc61e521c0ad71fb9c (patch) | |
tree | 0b76cdb978bead82188de40cae6d24bd88d71b7d /include/linux/rbtree.h | |
parent | d596043d71ff0d7b3d0bead19b1d68c55f003093 (diff) |
rbtree: Undo augmented trees performance damage and regression
Reimplement augmented RB-trees without sprinkling extra branches
all over the RB-tree code (which lives in the scheduler hot path).
This approach is 'borrowed' from Fabio's BFQ implementation and
relies on traversing the rebalance path after the RB-tree-op to
correct the heap property for insertion/removal and make up for
the damage done by the tree rotations.
For insertion the rebalance path is trivially that from the new
node upwards to the root, for removal it is that from the deepest
node in the path from the to be removed node that will still
be around after the removal.
[ This patch also fixes a video driver regression reported by
Ali Gholami Rudi - the memtype->subtree_max_end was updated
incorrectly. ]
Acked-by: Suresh Siddha <suresh.b.siddha@intel.com>
Acked-by: Venkatesh Pallipadi <venki@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Tested-by: Ali Gholami Rudi <ali@rudi.ir>
Cc: Fabio Checconi <fabio@gandalf.sssup.it>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
LKML-Reference: <1275414172.27810.27961.camel@twins>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/linux/rbtree.h')
-rw-r--r-- | include/linux/rbtree.h | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h index fe1872e5b37e..7066acb2c530 100644 --- a/include/linux/rbtree.h +++ b/include/linux/rbtree.h | |||
@@ -110,7 +110,6 @@ struct rb_node | |||
110 | struct rb_root | 110 | struct rb_root |
111 | { | 111 | { |
112 | struct rb_node *rb_node; | 112 | struct rb_node *rb_node; |
113 | void (*augment_cb)(struct rb_node *node); | ||
114 | }; | 113 | }; |
115 | 114 | ||
116 | 115 | ||
@@ -130,9 +129,7 @@ static inline void rb_set_color(struct rb_node *rb, int color) | |||
130 | rb->rb_parent_color = (rb->rb_parent_color & ~1) | color; | 129 | rb->rb_parent_color = (rb->rb_parent_color & ~1) | color; |
131 | } | 130 | } |
132 | 131 | ||
133 | #define RB_ROOT (struct rb_root) { NULL, NULL, } | 132 | #define RB_ROOT (struct rb_root) { NULL, } |
134 | #define RB_AUGMENT_ROOT(x) (struct rb_root) { NULL, x} | ||
135 | |||
136 | #define rb_entry(ptr, type, member) container_of(ptr, type, member) | 133 | #define rb_entry(ptr, type, member) container_of(ptr, type, member) |
137 | 134 | ||
138 | #define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL) | 135 | #define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL) |
@@ -142,6 +139,14 @@ static inline void rb_set_color(struct rb_node *rb, int color) | |||
142 | extern void rb_insert_color(struct rb_node *, struct rb_root *); | 139 | extern void rb_insert_color(struct rb_node *, struct rb_root *); |
143 | extern void rb_erase(struct rb_node *, struct rb_root *); | 140 | extern void rb_erase(struct rb_node *, struct rb_root *); |
144 | 141 | ||
142 | typedef void (*rb_augment_f)(struct rb_node *node, void *data); | ||
143 | |||
144 | extern void rb_augment_insert(struct rb_node *node, | ||
145 | rb_augment_f func, void *data); | ||
146 | extern struct rb_node *rb_augment_erase_begin(struct rb_node *node); | ||
147 | extern void rb_augment_erase_end(struct rb_node *node, | ||
148 | rb_augment_f func, void *data); | ||
149 | |||
145 | /* Find logical next and previous nodes in a tree */ | 150 | /* Find logical next and previous nodes in a tree */ |
146 | extern struct rb_node *rb_next(const struct rb_node *); | 151 | extern struct rb_node *rb_next(const struct rb_node *); |
147 | extern struct rb_node *rb_prev(const struct rb_node *); | 152 | extern struct rb_node *rb_prev(const struct rb_node *); |