diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2009-10-03 09:42:45 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-10-03 10:01:59 -0400 |
commit | 9735abf11bec48bfbbb1b54772a02deb2ae0c403 (patch) | |
tree | 9bb3c292419443619311b0eedb121149d33e7f59 /tools/perf/util/hist.c | |
parent | 439d473b4777de510e1322168ac6f2f377ecd5bc (diff) |
perf tools: Move hist_entry__add common code to hist.c
Now perf report and annotate do the callgraph/hit processing in
their specialized hist_entry__add functions.
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Acked-by: Frédéric Weisbecker <fweisbec@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Mike Galbraith <efault@gmx.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools/perf/util/hist.c')
-rw-r--r-- | tools/perf/util/hist.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 82808dc4f8e3..7393a02fd8d4 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c | |||
@@ -21,6 +21,52 @@ unsigned long total_lost; | |||
21 | * histogram, sorted on item, collects counts | 21 | * histogram, sorted on item, collects counts |
22 | */ | 22 | */ |
23 | 23 | ||
24 | struct hist_entry *__hist_entry__add(struct thread *thread, struct map *map, | ||
25 | struct symbol *sym, | ||
26 | struct symbol *sym_parent, | ||
27 | u64 ip, u64 count, char level, bool *hit) | ||
28 | { | ||
29 | struct rb_node **p = &hist.rb_node; | ||
30 | struct rb_node *parent = NULL; | ||
31 | struct hist_entry *he; | ||
32 | struct hist_entry entry = { | ||
33 | .thread = thread, | ||
34 | .map = map, | ||
35 | .sym = sym, | ||
36 | .ip = ip, | ||
37 | .level = level, | ||
38 | .count = count, | ||
39 | .parent = sym_parent, | ||
40 | }; | ||
41 | int cmp; | ||
42 | |||
43 | while (*p != NULL) { | ||
44 | parent = *p; | ||
45 | he = rb_entry(parent, struct hist_entry, rb_node); | ||
46 | |||
47 | cmp = hist_entry__cmp(&entry, he); | ||
48 | |||
49 | if (!cmp) { | ||
50 | *hit = true; | ||
51 | return he; | ||
52 | } | ||
53 | |||
54 | if (cmp < 0) | ||
55 | p = &(*p)->rb_left; | ||
56 | else | ||
57 | p = &(*p)->rb_right; | ||
58 | } | ||
59 | |||
60 | he = malloc(sizeof(*he)); | ||
61 | if (!he) | ||
62 | return NULL; | ||
63 | *he = entry; | ||
64 | rb_link_node(&he->rb_node, parent, p); | ||
65 | rb_insert_color(&he->rb_node, &hist); | ||
66 | *hit = false; | ||
67 | return he; | ||
68 | } | ||
69 | |||
24 | int64_t | 70 | int64_t |
25 | hist_entry__cmp(struct hist_entry *left, struct hist_entry *right) | 71 | hist_entry__cmp(struct hist_entry *left, struct hist_entry *right) |
26 | { | 72 | { |