aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-c2c.c
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2016-05-11 12:23:48 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-10-21 09:31:56 -0400
commitdd805768f7d74ba412817811cc60e2b153a43ee8 (patch)
tree4ed8a1c51578a2af300f357d63df16deeb676cd2 /tools/perf/builtin-c2c.c
parent2709b97dc2e250b5365629b99da5aa1cca7708f8 (diff)
perf c2c report: Allow to report callchains
Add --call-graph option to properly setup callchain code. Adding default settings to display callchains whenever they are stored in the perf.data. Committer Notes: Testing it: [root@jouet ~]# perf c2c record -a -g sleep 5 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 5.331 MB perf.data (4263 samples) ] [root@jouet ~]# perf evlist -v cpu/mem-loads,ldlat=30/P: type: 4, size: 112, config: 0x1cd, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ADDR|CALLCHAIN|ID|CPU|PERIOD|DATA_SRC|WEIGHT, read_format: ID, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, task: 1, precise_ip: 3, mmap_data: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, { bp_addr, config1 }: 0x1f cpu/mem-stores/P: type: 4, size: 112, config: 0x82d0, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|ADDR|CALLCHAIN|ID|CPU|PERIOD|DATA_SRC|WEIGHT, read_format: ID, disabled: 1, inherit: 1, freq: 1, precise_ip: 3, sample_id_all: 1 [root@jouet ~]# perf c2c report --stats ================================================= Trace Event Information ================================================= Total records : 4263 Locked Load/Store Operations : 220 Load Operations : 2130 Loads - uncacheable : 1 Loads - IO : 7 Loads - Miss : 86 Loads - no mapping : 5 Load Fill Buffer Hit : 609 Load L1D hit : 612 ================================================= Trace Event Information ================================================= Total records : 4263 Locked Load/Store Operations : 220 Load Operations : 2130 Loads - uncacheable : 1 Loads - IO : 7 Loads - Miss : 86 Loads - no mapping : 5 Load Fill Buffer Hit : 609 Load L1D hit : 612 Load L2D hit : 27 Load LLC hit : 607 Load Local HITM : 15 Load Remote HITM : 0 Load Remote HIT : 0 Load Local DRAM : 176 Load Remote DRAM : 0 Load MESI State Exclusive : 176 Load MESI State Shared : 0 Load LLC Misses : 176 LLC Misses to Local DRAM : 100.0% LLC Misses to Remote DRAM : 0.0% LLC Misses to Remote cache (HIT) : 0.0% LLC Misses to Remote cache (HITM) : 0.0% Store Operations : 2133 Store - uncacheable : 0 Store - no mapping : 1 Store L1D Hit : 1967 Store L1D Miss : 165 No Page Map Rejects : 145 Unable to parse data source : 0 ================================================= Global Shared Cache Line Event Information ================================================= Total Shared Cache Lines : 15 Load HITs on shared lines : 26 Fill Buffer Hits on shared lines : 7 L1D hits on shared lines : 3 L2D hits on shared lines : 0 LLC hits on shared lines : 16 Locked Access on shared lines : 2 Store HITs on shared lines : 8 Store L1D hits on shared lines : 7 Total Merged records : 23 ================================================= c2c details ================================================= Events : cpu/mem-loads,ldlat=30/P : cpu/mem-stores/P [root@jouet ~]# [root@jouet ~]# perf c2c report Shared Data Cache Line Table (2378 entries) Total --- LLC Load Hitm -- -- Store Reference - - Load Dram - LLC Total - Core Load Hit - Cacheline records %hitm Total Lcl Rmt Total L1Hit L1Miss Lcl Rmt Ld Miss Loads FB L1 L2 - 0xffff880024380c00 10 0.00% 0 0 0 6 6 0 0 0 0 4 1 3 0 - 0.13% _raw_spin_lock_irqsave - 0.07% ep_poll sys_epoll_wait do_syscall_64 return_from_SYSCALL_64 + 0x103573 - 0.05% ep_poll_callback __wake_up_common - __wake_up_sync_key - 0.02% pipe_read __vfs_read vfs_read sys_read do_syscall_64 return_from_SYSCALL_64 0xfdad + 0.02% sock_def_readable + 0.02% ep_scan_ready_list.constprop.12 + 0.00% mutex_lock + 0.00% __wake_up_common + 0xffff880024380c40 1 0.00% 0 0 0 1 1 0 0 0 0 0 0 0 0 + 0xffff880024380c80 1 0.00% 0 0 0 0 0 0 0 0 0 1 0 0 0 - 0xffff8800243e9f00 1 0.00% 0 0 0 1 1 0 0 0 0 0 0 0 0 enqueue_entity enqueue_task_fair activate_task ttwu_do_activate try_to_wake_up wake_up_process hrtimer_wakeup __hrtimer_run_queues hrtimer_interrupt local_apic_timer_interrupt smp_apic_timer_interrupt apic_timer_interrupt cpuidle_enter call_cpuidle help ------------- And when presing 'd' to see the cacheline details: Cacheline 0xffff880024380c00 ----- HITM ----- -- Store Refs -- --------- cycles ----- cpu Rmt Lcl L1 Hit L1 Miss Off Pid Tid rmt hitm lcl hitm load cnt Symbol - 0.00% 0.00% 100.00% 0.00% 0x0 1473 1474:Chrome_ChildIOT 0 0 41 2 [k] _raw_spin_lock_irqsave [kernel] - _raw_spin_lock_irqsave - 51.52% ep_poll sys_epoll_wait do_syscall_64 return_from_SYSCALL_64 - 0x103573 47.19% 0 4.33% 0xc30bd - 35.93% ep_poll_callback __wake_up_common - __wake_up_sync_key - 18.20% pipe_read __vfs_read vfs_read sys_read do_syscall_64 return_from_SYSCALL_64 0xfdad - 17.73% sock_def_readable unix_stream_sendmsg sock_sendmsg ___sys_sendmsg __sys_sendmsg sys_sendmsg do_syscall_64 return_from_SYSCALL_64 __GI___libc_sendmsg 0x12c036af1fc0 0x16a4050 0x894928ec83485354 + 12.45% ep_scan_ready_list.constprop.12 + 0.00% 0.00% 0.00% 0.00% 0x8 1473 1474:Chrome_ChildIOT 0 0 102 1 [k] mutex_lock [kernel] + 0.00% 0.00% 0.00% 0.00% 0x38 1473 1473:chrome 0 0 88 1 [k] __wake_up_common [kernel] help Signed-off-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Don Zickus <dzickus@redhat.com> Cc: Joe Mario <jmario@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/n/tip-inykbom2f19difvsu1e18avr@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-c2c.c')
-rw-r--r--tools/perf/builtin-c2c.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c
index 88d88eac53aa..950a4123ea66 100644
--- a/tools/perf/builtin-c2c.c
+++ b/tools/perf/builtin-c2c.c
@@ -17,6 +17,7 @@
17#include "evsel.h" 17#include "evsel.h"
18#include <asm/bug.h> 18#include <asm/bug.h>
19#include "ui/browsers/hists.h" 19#include "ui/browsers/hists.h"
20#include "evlist.h"
20 21
21struct c2c_hists { 22struct c2c_hists {
22 struct hists hists; 23 struct hists hists;
@@ -183,6 +184,11 @@ static int process_sample_event(struct perf_tool *tool __maybe_unused,
183 return -1; 184 return -1;
184 } 185 }
185 186
187 ret = sample__resolve_callchain(sample, &callchain_cursor, NULL,
188 evsel, &al, sysctl_perf_event_max_stack);
189 if (ret)
190 goto out;
191
186 mi = sample__resolve_mem(sample, &al); 192 mi = sample__resolve_mem(sample, &al);
187 if (mi == NULL) 193 if (mi == NULL)
188 return -ENOMEM; 194 return -ENOMEM;
@@ -2117,6 +2123,58 @@ static void ui_quirks(void)
2117 } 2123 }
2118} 2124}
2119 2125
2126#define CALLCHAIN_DEFAULT_OPT "graph,0.5,caller,function,percent"
2127
2128const char callchain_help[] = "Display call graph (stack chain/backtrace):\n\n"
2129 CALLCHAIN_REPORT_HELP
2130 "\n\t\t\t\tDefault: " CALLCHAIN_DEFAULT_OPT;
2131
2132static int
2133parse_callchain_opt(const struct option *opt, const char *arg, int unset)
2134{
2135 struct callchain_param *callchain = opt->value;
2136
2137 callchain->enabled = !unset;
2138 /*
2139 * --no-call-graph
2140 */
2141 if (unset) {
2142 symbol_conf.use_callchain = false;
2143 callchain->mode = CHAIN_NONE;
2144 return 0;
2145 }
2146
2147 return parse_callchain_report_opt(arg);
2148}
2149
2150static int setup_callchain(struct perf_evlist *evlist)
2151{
2152 u64 sample_type = perf_evlist__combined_sample_type(evlist);
2153 enum perf_call_graph_mode mode = CALLCHAIN_NONE;
2154
2155 if ((sample_type & PERF_SAMPLE_REGS_USER) &&
2156 (sample_type & PERF_SAMPLE_STACK_USER))
2157 mode = CALLCHAIN_DWARF;
2158 else if (sample_type & PERF_SAMPLE_BRANCH_STACK)
2159 mode = CALLCHAIN_LBR;
2160 else if (sample_type & PERF_SAMPLE_CALLCHAIN)
2161 mode = CALLCHAIN_FP;
2162
2163 if (!callchain_param.enabled &&
2164 callchain_param.mode != CHAIN_NONE &&
2165 mode != CALLCHAIN_NONE) {
2166 symbol_conf.use_callchain = true;
2167 if (callchain_register_param(&callchain_param) < 0) {
2168 ui__error("Can't register callchain params.\n");
2169 return -EINVAL;
2170 }
2171 }
2172
2173 callchain_param.record_mode = mode;
2174 callchain_param.min_percent = 0;
2175 return 0;
2176}
2177
2120static int perf_c2c__report(int argc, const char **argv) 2178static int perf_c2c__report(int argc, const char **argv)
2121{ 2179{
2122 struct perf_session *session; 2180 struct perf_session *session;
@@ -2124,6 +2182,7 @@ static int perf_c2c__report(int argc, const char **argv)
2124 struct perf_data_file file = { 2182 struct perf_data_file file = {
2125 .mode = PERF_DATA_MODE_READ, 2183 .mode = PERF_DATA_MODE_READ,
2126 }; 2184 };
2185 char callchain_default_opt[] = CALLCHAIN_DEFAULT_OPT;
2127 const struct option c2c_options[] = { 2186 const struct option c2c_options[] = {
2128 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name, 2187 OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
2129 "file", "vmlinux pathname"), 2188 "file", "vmlinux pathname"),
@@ -2138,6 +2197,10 @@ static int perf_c2c__report(int argc, const char **argv)
2138#endif 2197#endif
2139 OPT_BOOLEAN(0, "stats", &c2c.stats_only, 2198 OPT_BOOLEAN(0, "stats", &c2c.stats_only,
2140 "Use the stdio interface"), 2199 "Use the stdio interface"),
2200 OPT_CALLBACK_DEFAULT('g', "call-graph", &callchain_param,
2201 "print_type,threshold[,print_limit],order,sort_key[,branch],value",
2202 callchain_help, &parse_callchain_opt,
2203 callchain_default_opt),
2141 OPT_END() 2204 OPT_END()
2142 }; 2205 };
2143 int err = 0; 2206 int err = 0;
@@ -2179,6 +2242,10 @@ static int perf_c2c__report(int argc, const char **argv)
2179 goto out; 2242 goto out;
2180 } 2243 }
2181 2244
2245 err = setup_callchain(session->evlist);
2246 if (err)
2247 goto out_session;
2248
2182 if (symbol__init(&session->header.env) < 0) 2249 if (symbol__init(&session->header.env) < 0)
2183 goto out_session; 2250 goto out_session;
2184 2251