Commit 9cd804ac1f39e10510bf93700f1f7ea66b2e1b38
Committed by
Steven Rostedt
1 parent
29ad23b004
Exists in
master
and in
16 other branches
trace/trace_stat: use rbtree postorder iteration helper instead of opencoding
Use rbtree_postorder_for_each_entry_safe() to destroy the rbtree instead of opencoding an alternate postorder iteration that modifies the tree Link: http://lkml.kernel.org/r/1383345566-25087-2-git-send-email-cody@linux.vnet.ibm.com Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Showing 1 changed file with 5 additions and 36 deletions Side-by-side Diff
kernel/trace/trace_stat.c
... | ... | @@ -43,46 +43,15 @@ |
43 | 43 | /* The root directory for all stat files */ |
44 | 44 | static struct dentry *stat_dir; |
45 | 45 | |
46 | -/* | |
47 | - * Iterate through the rbtree using a post order traversal path | |
48 | - * to release the next node. | |
49 | - * It won't necessary release one at each iteration | |
50 | - * but it will at least advance closer to the next one | |
51 | - * to be released. | |
52 | - */ | |
53 | -static struct rb_node *release_next(struct tracer_stat *ts, | |
54 | - struct rb_node *node) | |
46 | +static void __reset_stat_session(struct stat_session *session) | |
55 | 47 | { |
56 | - struct stat_node *snode; | |
57 | - struct rb_node *parent = rb_parent(node); | |
48 | + struct stat_node *snode, *n; | |
58 | 49 | |
59 | - if (node->rb_left) | |
60 | - return node->rb_left; | |
61 | - else if (node->rb_right) | |
62 | - return node->rb_right; | |
63 | - else { | |
64 | - if (!parent) | |
65 | - ; | |
66 | - else if (parent->rb_left == node) | |
67 | - parent->rb_left = NULL; | |
68 | - else | |
69 | - parent->rb_right = NULL; | |
70 | - | |
71 | - snode = container_of(node, struct stat_node, node); | |
72 | - if (ts->stat_release) | |
73 | - ts->stat_release(snode->stat); | |
50 | + rbtree_postorder_for_each_entry_safe(snode, n, &session->stat_root, node) { | |
51 | + if (session->ts->stat_release) | |
52 | + session->ts->stat_release(snode->stat); | |
74 | 53 | kfree(snode); |
75 | - | |
76 | - return parent; | |
77 | 54 | } |
78 | -} | |
79 | - | |
80 | -static void __reset_stat_session(struct stat_session *session) | |
81 | -{ | |
82 | - struct rb_node *node = session->stat_root.rb_node; | |
83 | - | |
84 | - while (node) | |
85 | - node = release_next(session->ts, node); | |
86 | 55 | |
87 | 56 | session->stat_root = RB_ROOT; |
88 | 57 | } |