diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-12-14 10:10:39 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-12-14 10:57:18 -0500 |
commit | 4e4f06e4c8f17ea96f7dd76251cab99511026401 (patch) | |
tree | 18b7f83b664939be0a9bde8e43daf9db8ca7fccc /tools/perf/util | |
parent | b9bf089212d95746ce66482bcdbc7e77a0651088 (diff) |
perf session: Move the hist_entries rb tree to perf_session
As we'll need to sort multiple times for multiple perf sessions,
so that we can then do a diff.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
LKML-Reference: <1260803439-16783-1-git-send-email-acme@infradead.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/data_map.c | 2 | ||||
-rw-r--r-- | tools/perf/util/hist.c | 43 | ||||
-rw-r--r-- | tools/perf/util/hist.h | 43 | ||||
-rw-r--r-- | tools/perf/util/session.h | 5 |
4 files changed, 42 insertions, 51 deletions
diff --git a/tools/perf/util/data_map.c b/tools/perf/util/data_map.c index 44dea211cc65..08c4cf5e66ba 100644 --- a/tools/perf/util/data_map.c +++ b/tools/perf/util/data_map.c | |||
@@ -161,7 +161,7 @@ int perf_session__process_events(struct perf_session *self, | |||
161 | 161 | ||
162 | err = -EINVAL; | 162 | err = -EINVAL; |
163 | if (ops->sample_type_check && | 163 | if (ops->sample_type_check && |
164 | ops->sample_type_check(sample_type) < 0) | 164 | ops->sample_type_check(sample_type, self) < 0) |
165 | goto out_err; | 165 | goto out_err; |
166 | 166 | ||
167 | if (!ops->full_paths) { | 167 | if (!ops->full_paths) { |
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index b40e37ded4bf..b9828fce7bf0 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -1,7 +1,6 @@ | |||
1 | #include "hist.h" | 1 | #include "hist.h" |
2 | 2 | #include "session.h" | |
3 | struct rb_root hist; | 3 | #include "sort.h" |
4 | int callchain; | ||
5 | 4 | ||
6 | struct callchain_param callchain_param = { | 5 | struct callchain_param callchain_param = { |
7 | .mode = CHAIN_GRAPH_REL, | 6 | .mode = CHAIN_GRAPH_REL, |
@@ -12,11 +11,12 @@ struct callchain_param callchain_param = { | |||
12 | * histogram, sorted on item, collects counts | 11 | * histogram, sorted on item, collects counts |
13 | */ | 12 | */ |
14 | 13 | ||
15 | struct hist_entry *__hist_entry__add(struct addr_location *al, | 14 | struct hist_entry *__perf_session__add_hist_entry(struct perf_session *self, |
16 | struct symbol *sym_parent, | 15 | struct addr_location *al, |
17 | u64 count, bool *hit) | 16 | struct symbol *sym_parent, |
17 | u64 count, bool *hit) | ||
18 | { | 18 | { |
19 | struct rb_node **p = &hist.rb_node; | 19 | struct rb_node **p = &self->hists.rb_node; |
20 | struct rb_node *parent = NULL; | 20 | struct rb_node *parent = NULL; |
21 | struct hist_entry *he; | 21 | struct hist_entry *he; |
22 | struct hist_entry entry = { | 22 | struct hist_entry entry = { |
@@ -52,7 +52,7 @@ struct hist_entry *__hist_entry__add(struct addr_location *al, | |||
52 | return NULL; | 52 | return NULL; |
53 | *he = entry; | 53 | *he = entry; |
54 | rb_link_node(&he->rb_node, parent, p); | 54 | rb_link_node(&he->rb_node, parent, p); |
55 | rb_insert_color(&he->rb_node, &hist); | 55 | rb_insert_color(&he->rb_node, &self->hists); |
56 | *hit = false; | 56 | *hit = false; |
57 | return he; | 57 | return he; |
58 | } | 58 | } |
@@ -129,7 +129,7 @@ static void collapse__insert_entry(struct rb_root *root, struct hist_entry *he) | |||
129 | rb_insert_color(&he->rb_node, root); | 129 | rb_insert_color(&he->rb_node, root); |
130 | } | 130 | } |
131 | 131 | ||
132 | void collapse__resort(void) | 132 | void perf_session__collapse_resort(struct perf_session *self) |
133 | { | 133 | { |
134 | struct rb_root tmp; | 134 | struct rb_root tmp; |
135 | struct rb_node *next; | 135 | struct rb_node *next; |
@@ -139,31 +139,33 @@ void collapse__resort(void) | |||
139 | return; | 139 | return; |
140 | 140 | ||
141 | tmp = RB_ROOT; | 141 | tmp = RB_ROOT; |
142 | next = rb_first(&hist); | 142 | next = rb_first(&self->hists); |
143 | 143 | ||
144 | while (next) { | 144 | while (next) { |
145 | n = rb_entry(next, struct hist_entry, rb_node); | 145 | n = rb_entry(next, struct hist_entry, rb_node); |
146 | next = rb_next(&n->rb_node); | 146 | next = rb_next(&n->rb_node); |
147 | 147 | ||
148 | rb_erase(&n->rb_node, &hist); | 148 | rb_erase(&n->rb_node, &self->hists); |
149 | collapse__insert_entry(&tmp, n); | 149 | collapse__insert_entry(&tmp, n); |
150 | } | 150 | } |
151 | 151 | ||
152 | hist = tmp; | 152 | self->hists = tmp; |
153 | } | 153 | } |
154 | 154 | ||
155 | /* | 155 | /* |
156 | * reverse the map, sort on count. | 156 | * reverse the map, sort on count. |
157 | */ | 157 | */ |
158 | 158 | ||
159 | static void output__insert_entry(struct rb_root *root, struct hist_entry *he, | 159 | static void perf_session__insert_output_hist_entry(struct perf_session *self, |
160 | u64 min_callchain_hits) | 160 | struct rb_root *root, |
161 | struct hist_entry *he, | ||
162 | u64 min_callchain_hits) | ||
161 | { | 163 | { |
162 | struct rb_node **p = &root->rb_node; | 164 | struct rb_node **p = &root->rb_node; |
163 | struct rb_node *parent = NULL; | 165 | struct rb_node *parent = NULL; |
164 | struct hist_entry *iter; | 166 | struct hist_entry *iter; |
165 | 167 | ||
166 | if (callchain) | 168 | if (self->use_callchain) |
167 | callchain_param.sort(&he->sorted_chain, &he->callchain, | 169 | callchain_param.sort(&he->sorted_chain, &he->callchain, |
168 | min_callchain_hits, &callchain_param); | 170 | min_callchain_hits, &callchain_param); |
169 | 171 | ||
@@ -181,7 +183,7 @@ static void output__insert_entry(struct rb_root *root, struct hist_entry *he, | |||
181 | rb_insert_color(&he->rb_node, root); | 183 | rb_insert_color(&he->rb_node, root); |
182 | } | 184 | } |
183 | 185 | ||
184 | void output__resort(u64 total_samples) | 186 | void perf_session__output_resort(struct perf_session *self, u64 total_samples) |
185 | { | 187 | { |
186 | struct rb_root tmp; | 188 | struct rb_root tmp; |
187 | struct rb_node *next; | 189 | struct rb_node *next; |
@@ -192,15 +194,16 @@ void output__resort(u64 total_samples) | |||
192 | total_samples * (callchain_param.min_percent / 100); | 194 | total_samples * (callchain_param.min_percent / 100); |
193 | 195 | ||
194 | tmp = RB_ROOT; | 196 | tmp = RB_ROOT; |
195 | next = rb_first(&hist); | 197 | next = rb_first(&self->hists); |
196 | 198 | ||
197 | while (next) { | 199 | while (next) { |
198 | n = rb_entry(next, struct hist_entry, rb_node); | 200 | n = rb_entry(next, struct hist_entry, rb_node); |
199 | next = rb_next(&n->rb_node); | 201 | next = rb_next(&n->rb_node); |
200 | 202 | ||
201 | rb_erase(&n->rb_node, &hist); | 203 | rb_erase(&n->rb_node, &self->hists); |
202 | output__insert_entry(&tmp, n, min_callchain_hits); | 204 | perf_session__insert_output_hist_entry(self, &tmp, n, |
205 | min_callchain_hits); | ||
203 | } | 206 | } |
204 | 207 | ||
205 | hist = tmp; | 208 | self->hists = tmp; |
206 | } | 209 | } |
diff --git a/tools/perf/util/hist.h b/tools/perf/util/hist.h index a6cb1485e3b9..7efdb1b6d8c8 100644 --- a/tools/perf/util/hist.h +++ b/tools/perf/util/hist.h | |||
@@ -1,40 +1,25 @@ | |||
1 | #ifndef __PERF_HIST_H | 1 | #ifndef __PERF_HIST_H |
2 | #define __PERF_HIST_H | 2 | #define __PERF_HIST_H |
3 | #include "../builtin.h" | ||
4 | 3 | ||
5 | #include "util.h" | 4 | #include <linux/types.h> |
6 | |||
7 | #include "color.h" | ||
8 | #include <linux/list.h> | ||
9 | #include "cache.h" | ||
10 | #include <linux/rbtree.h> | ||
11 | #include "symbol.h" | ||
12 | #include "string.h" | ||
13 | #include "callchain.h" | 5 | #include "callchain.h" |
14 | #include "strlist.h" | ||
15 | #include "values.h" | ||
16 | |||
17 | #include "../perf.h" | ||
18 | #include "debug.h" | ||
19 | #include "header.h" | ||
20 | |||
21 | #include "parse-options.h" | ||
22 | #include "parse-events.h" | ||
23 | 6 | ||
24 | #include "thread.h" | ||
25 | #include "sort.h" | ||
26 | |||
27 | extern struct rb_root hist; | ||
28 | extern int callchain; | ||
29 | extern struct callchain_param callchain_param; | 7 | extern struct callchain_param callchain_param; |
30 | 8 | ||
31 | struct hist_entry *__hist_entry__add(struct addr_location *al, | 9 | struct perf_session; |
32 | struct symbol *parent, | 10 | struct hist_entry; |
33 | u64 count, bool *hit); | 11 | struct addr_location; |
12 | struct symbol; | ||
13 | |||
14 | struct hist_entry *__perf_session__add_hist_entry(struct perf_session *self, | ||
15 | struct addr_location *al, | ||
16 | struct symbol *parent, | ||
17 | u64 count, bool *hit); | ||
34 | extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *); | 18 | extern int64_t hist_entry__cmp(struct hist_entry *, struct hist_entry *); |
35 | extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *); | 19 | extern int64_t hist_entry__collapse(struct hist_entry *, struct hist_entry *); |
36 | extern void hist_entry__free(struct hist_entry *); | 20 | void hist_entry__free(struct hist_entry *); |
37 | extern void collapse__resort(void); | 21 | |
38 | extern void output__resort(u64); | 22 | void perf_session__output_resort(struct perf_session *self, u64 total_samples); |
23 | void perf_session__collapse_resort(struct perf_session *self); | ||
39 | 24 | ||
40 | #endif /* __PERF_HIST_H */ | 25 | #endif /* __PERF_HIST_H */ |
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h index 20b2c9cc834b..759d96022a39 100644 --- a/tools/perf/util/session.h +++ b/tools/perf/util/session.h | |||
@@ -16,10 +16,12 @@ struct perf_session { | |||
16 | struct map_groups kmaps; | 16 | struct map_groups kmaps; |
17 | struct rb_root threads; | 17 | struct rb_root threads; |
18 | struct thread *last_match; | 18 | struct thread *last_match; |
19 | struct rb_root hists; | ||
19 | int fd; | 20 | int fd; |
20 | int cwdlen; | 21 | int cwdlen; |
21 | char *cwd; | 22 | char *cwd; |
22 | bool use_modules; | 23 | bool use_modules; |
24 | bool use_callchain; | ||
23 | char filename[0]; | 25 | char filename[0]; |
24 | }; | 26 | }; |
25 | 27 | ||
@@ -35,7 +37,8 @@ struct perf_event_ops { | |||
35 | event_op process_read_event; | 37 | event_op process_read_event; |
36 | event_op process_throttle_event; | 38 | event_op process_throttle_event; |
37 | event_op process_unthrottle_event; | 39 | event_op process_unthrottle_event; |
38 | int (*sample_type_check)(u64 sample_type); | 40 | int (*sample_type_check)(u64 sample_type, |
41 | struct perf_session *session); | ||
39 | unsigned long total_unknown; | 42 | unsigned long total_unknown; |
40 | bool full_paths; | 43 | bool full_paths; |
41 | }; | 44 | }; |