aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2015-07-18 11:24:52 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-08-06 15:39:22 -0400
commita18b027efe1a2a502d98a8d0ea0391a72bf3f696 (patch)
treefc538f8bc5ecd0c89473fb0b234c2aa2890ae6dc
parentf8f4aaead579c947fb8fc051c9d242037025caf3 (diff)
perf top: Add branch annotation code to top
Now that we can process branch data in annotate it makes sense to support enabling branch recording from top too. Most of the code needed for this is already in shared code with report. But we need to add: - The option parsing code (using shared code from the previous patch) - Document the options - Set up the IPC/cycles accounting state in the top session - Call the accounting code in the hist iter callback Signed-off-by: Andi Kleen <ak@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1437233094-12844-8-git-send-email-andi@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/Documentation/perf-top.txt21
-rw-r--r--tools/perf/builtin-top.c9
2 files changed, 30 insertions, 0 deletions
diff --git a/tools/perf/Documentation/perf-top.txt b/tools/perf/Documentation/perf-top.txt
index 776aec4d0927..f6a23eb294e7 100644
--- a/tools/perf/Documentation/perf-top.txt
+++ b/tools/perf/Documentation/perf-top.txt
@@ -208,6 +208,27 @@ Default is to monitor all CPUS.
208 This option sets the time out limit. The default value is 500 ms. 208 This option sets the time out limit. The default value is 500 ms.
209 209
210 210
211-b::
212--branch-any::
213 Enable taken branch stack sampling. Any type of taken branch may be sampled.
214 This is a shortcut for --branch-filter any. See --branch-filter for more infos.
215
216-j::
217--branch-filter::
218 Enable taken branch stack sampling. Each sample captures a series of consecutive
219 taken branches. The number of branches captured with each sample depends on the
220 underlying hardware, the type of branches of interest, and the executed code.
221 It is possible to select the types of branches captured by enabling filters.
222 For a full list of modifiers please see the perf record manpage.
223
224 The option requires at least one branch type among any, any_call, any_ret, ind_call, cond.
225 The privilege levels may be omitted, in which case, the privilege levels of the associated
226 event are applied to the branch filter. Both kernel (k) and hypervisor (hv) privilege
227 levels are subject to permissions. When sampling on multiple events, branch stack sampling
228 is enabled for all the sampling events. The sampled branch type is the same for all events.
229 The various filters must be specified as a comma separated list: --branch-filter any_ret,u,k
230 Note that this feature may not be available on all processors.
231
211INTERACTIVE PROMPTING KEYS 232INTERACTIVE PROMPTING KEYS
212-------------------------- 233--------------------------
213 234
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index ecf319728f25..bfe24f1e362f 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -40,6 +40,7 @@
40#include "util/xyarray.h" 40#include "util/xyarray.h"
41#include "util/sort.h" 41#include "util/sort.h"
42#include "util/intlist.h" 42#include "util/intlist.h"
43#include "util/parse-branch-options.h"
43#include "arch/common.h" 44#include "arch/common.h"
44 45
45#include "util/debug.h" 46#include "util/debug.h"
@@ -695,6 +696,8 @@ static int hist_iter__top_callback(struct hist_entry_iter *iter,
695 perf_top__record_precise_ip(top, he, evsel->idx, ip); 696 perf_top__record_precise_ip(top, he, evsel->idx, ip);
696 } 697 }
697 698
699 hist__account_cycles(iter->sample->branch_stack, al, iter->sample,
700 !(top->record_opts.branch_stack & PERF_SAMPLE_BRANCH_ANY));
698 return 0; 701 return 0;
699} 702}
700 703
@@ -1171,6 +1174,12 @@ int cmd_top(int argc, const char **argv, const char *prefix __maybe_unused)
1171 "don't try to adjust column width, use these fixed values"), 1174 "don't try to adjust column width, use these fixed values"),
1172 OPT_UINTEGER(0, "proc-map-timeout", &opts->proc_map_timeout, 1175 OPT_UINTEGER(0, "proc-map-timeout", &opts->proc_map_timeout,
1173 "per thread proc mmap processing timeout in ms"), 1176 "per thread proc mmap processing timeout in ms"),
1177 OPT_CALLBACK_NOOPT('b', "branch-any", &opts->branch_stack,
1178 "branch any", "sample any taken branches",
1179 parse_branch_stack),
1180 OPT_CALLBACK('j', "branch-filter", &opts->branch_stack,
1181 "branch filter mask", "branch stack filter modes",
1182 parse_branch_stack),
1174 OPT_END() 1183 OPT_END()
1175 }; 1184 };
1176 const char * const top_usage[] = { 1185 const char * const top_usage[] = {