diff options
author | Frederic Weisbecker <fweisbec@gmail.com> | 2009-08-08 22:19:15 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-08-09 07:07:46 -0400 |
commit | c0a8865e32c8d1a562db38e06ef31ef23282f646 (patch) | |
tree | 8cf7a402e4012998166287135204c201c6a83acd /tools | |
parent | 183f3b0887083d36c8a25cd5e3518906415d1889 (diff) |
perf tools: callchain: Fix bad rounding of minimum rate
Sometimes we get callchain branches that have a rate under the
limit given by the user.
Say you launched:
perf record -f -g -a ./hackbench 10
perf report -g fractal,10.0
And you got:
2.33% hackbench [kernel] [k] _spin_lock_irqsave
|
|--78.57%-- remove_wait_queue
| poll_freewait
| do_sys_poll
| sys_poll
| sysenter_dispatch
| 0xf7ffa430
| 0x1ffadea3c
|
|--7.14%-- __up_read
| up_read
| do_page_fault
| page_fault
| 0xf7ffa430
| 0xa0df710000000a
...
It is abnormal to get a 7.14% branch whereas we passed a 10%
filter.
The problem is that we round down the minimum threshold. This
happens mostly when we have very low number of events. If the
total amount of your branch is 4 and you have a subranch of 3
events, filtering to 90% will be computed like follows:
limit = 4 * 0.9;
The result is about 3.6, but the cast to integer will round
down to 3. It means that our filter is actually of 75%
We must then explicitly round up the minimum threshold.
Reported-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: acme@redhat.com
Cc: peterz@infradead.org
Cc: efault@gmx.de
LKML-Reference: <20090809024235.GA10146@nowhere>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/callchain.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index a8e67aa9ef49..011473411642 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
@@ -13,6 +13,7 @@ | |||
13 | #include <stdio.h> | 13 | #include <stdio.h> |
14 | #include <stdbool.h> | 14 | #include <stdbool.h> |
15 | #include <errno.h> | 15 | #include <errno.h> |
16 | #include <math.h> | ||
16 | 17 | ||
17 | #include "callchain.h" | 18 | #include "callchain.h" |
18 | 19 | ||
@@ -112,7 +113,7 @@ static void __sort_chain_graph_rel(struct callchain_node *node, | |||
112 | u64 min_hit; | 113 | u64 min_hit; |
113 | 114 | ||
114 | node->rb_root = RB_ROOT; | 115 | node->rb_root = RB_ROOT; |
115 | min_hit = node->children_hit * min_percent / 100.0; | 116 | min_hit = ceil(node->children_hit * min_percent); |
116 | 117 | ||
117 | chain_for_each_child(child, node) { | 118 | chain_for_each_child(child, node) { |
118 | __sort_chain_graph_rel(child, min_percent); | 119 | __sort_chain_graph_rel(child, min_percent); |
@@ -126,7 +127,7 @@ static void | |||
126 | sort_chain_graph_rel(struct rb_root *rb_root, struct callchain_node *chain_root, | 127 | sort_chain_graph_rel(struct rb_root *rb_root, struct callchain_node *chain_root, |
127 | u64 min_hit __used, struct callchain_param *param) | 128 | u64 min_hit __used, struct callchain_param *param) |
128 | { | 129 | { |
129 | __sort_chain_graph_rel(chain_root, param->min_percent); | 130 | __sort_chain_graph_rel(chain_root, param->min_percent / 100.0); |
130 | rb_root->rb_node = chain_root->rb_root.rb_node; | 131 | rb_root->rb_node = chain_root->rb_root.rb_node; |
131 | } | 132 | } |
132 | 133 | ||