Skip to content

Commit bbed8b9

Browse files
acmelakpm00
authored andcommitted
tools lib rbtree: pick some improvements from the kernel rbtree code
The tools/lib/rbtree.c code came from the kernel. Remove the EXPORT_SYMBOL() that make sense only there. Unfortunately it is not being checked with tools/perf/check_headers.sh. Will try to remedy this. Until then pick the improvements from: b0687c1 ("lib/rbtree: use '+' instead of '|' for setting color.") That I noticed by doing: diff -u tools/lib/rbtree.c lib/rbtree.c diff -u tools/include/linux/rbtree_augmented.h include/linux/rbtree_augmented.h There is one other cases, but lets pick it in separate patches. Link: https://lkml.kernel.org/r/ZigZzeFoukzRKG1Q@x1 Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Noah Goldstein <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent f492fb3 commit bbed8b9

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

tools/include/linux/rbtree_augmented.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,13 @@ RB_DECLARE_CALLBACKS(RBSTATIC, RBNAME, \
158158

159159
static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
160160
{
161-
rb->__rb_parent_color = rb_color(rb) | (unsigned long)p;
161+
rb->__rb_parent_color = rb_color(rb) + (unsigned long)p;
162162
}
163163

164164
static inline void rb_set_parent_color(struct rb_node *rb,
165165
struct rb_node *p, int color)
166166
{
167-
rb->__rb_parent_color = (unsigned long)p | color;
167+
rb->__rb_parent_color = (unsigned long)p + color;
168168
}
169169

170170
static inline void

tools/lib/rbtree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
static inline void rb_set_black(struct rb_node *rb)
6060
{
61-
rb->__rb_parent_color |= RB_BLACK;
61+
rb->__rb_parent_color += RB_BLACK;
6262
}
6363

6464
static inline struct rb_node *rb_red_parent(struct rb_node *red)

0 commit comments

Comments
 (0)