aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2019-05-20 07:37:19 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-06-05 08:47:57 -0400
commit003ccdc7165accee073ce261fc670f64cc98d0f7 (patch)
tree75f3a3aef6c4ea4ab0bb681a395a0dad3bb8f8fe
parent5db47f43ccbbdee8c48f76ace4c287187a28b87f (diff)
perf thread-stack: Accumulate IPC information
Cycle and instruction counts are added to the stack. The IPC of a function and all functions it calls, is also recorded. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/20190520113728.14389-14-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/thread-stack.c14
-rw-r--r--tools/perf/util/thread-stack.h4
2 files changed, 18 insertions, 0 deletions
diff --git a/tools/perf/util/thread-stack.c b/tools/perf/util/thread-stack.c
index 41942c2aaa18..8e390f78486f 100644
--- a/tools/perf/util/thread-stack.c
+++ b/tools/perf/util/thread-stack.c
@@ -49,6 +49,8 @@ enum retpoline_state_t {
49 * @timestamp: timestamp (if known) 49 * @timestamp: timestamp (if known)
50 * @ref: external reference (e.g. db_id of sample) 50 * @ref: external reference (e.g. db_id of sample)
51 * @branch_count: the branch count when the entry was created 51 * @branch_count: the branch count when the entry was created
52 * @insn_count: the instruction count when the entry was created
53 * @cyc_count the cycle count when the entry was created
52 * @db_id: id used for db-export 54 * @db_id: id used for db-export
53 * @cp: call path 55 * @cp: call path
54 * @no_call: a 'call' was not seen 56 * @no_call: a 'call' was not seen
@@ -60,6 +62,8 @@ struct thread_stack_entry {
60 u64 timestamp; 62 u64 timestamp;
61 u64 ref; 63 u64 ref;
62 u64 branch_count; 64 u64 branch_count;
65 u64 insn_count;
66 u64 cyc_count;
63 u64 db_id; 67 u64 db_id;
64 struct call_path *cp; 68 struct call_path *cp;
65 bool no_call; 69 bool no_call;
@@ -75,6 +79,8 @@ struct thread_stack_entry {
75 * @sz: current maximum stack size 79 * @sz: current maximum stack size
76 * @trace_nr: current trace number 80 * @trace_nr: current trace number
77 * @branch_count: running branch count 81 * @branch_count: running branch count
82 * @insn_count: running instruction count
83 * @cyc_count running cycle count
78 * @kernel_start: kernel start address 84 * @kernel_start: kernel start address
79 * @last_time: last timestamp 85 * @last_time: last timestamp
80 * @crp: call/return processor 86 * @crp: call/return processor
@@ -88,6 +94,8 @@ struct thread_stack {
88 size_t sz; 94 size_t sz;
89 u64 trace_nr; 95 u64 trace_nr;
90 u64 branch_count; 96 u64 branch_count;
97 u64 insn_count;
98 u64 cyc_count;
91 u64 kernel_start; 99 u64 kernel_start;
92 u64 last_time; 100 u64 last_time;
93 struct call_return_processor *crp; 101 struct call_return_processor *crp;
@@ -289,6 +297,8 @@ static int thread_stack__call_return(struct thread *thread,
289 cr.call_time = tse->timestamp; 297 cr.call_time = tse->timestamp;
290 cr.return_time = timestamp; 298 cr.return_time = timestamp;
291 cr.branch_count = ts->branch_count - tse->branch_count; 299 cr.branch_count = ts->branch_count - tse->branch_count;
300 cr.insn_count = ts->insn_count - tse->insn_count;
301 cr.cyc_count = ts->cyc_count - tse->cyc_count;
292 cr.db_id = tse->db_id; 302 cr.db_id = tse->db_id;
293 cr.call_ref = tse->ref; 303 cr.call_ref = tse->ref;
294 cr.return_ref = ref; 304 cr.return_ref = ref;
@@ -544,6 +554,8 @@ static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr,
544 tse->timestamp = timestamp; 554 tse->timestamp = timestamp;
545 tse->ref = ref; 555 tse->ref = ref;
546 tse->branch_count = ts->branch_count; 556 tse->branch_count = ts->branch_count;
557 tse->insn_count = ts->insn_count;
558 tse->cyc_count = ts->cyc_count;
547 tse->cp = cp; 559 tse->cp = cp;
548 tse->no_call = no_call; 560 tse->no_call = no_call;
549 tse->trace_end = trace_end; 561 tse->trace_end = trace_end;
@@ -874,6 +886,8 @@ int thread_stack__process(struct thread *thread, struct comm *comm,
874 } 886 }
875 887
876 ts->branch_count += 1; 888 ts->branch_count += 1;
889 ts->insn_count += sample->insn_cnt;
890 ts->cyc_count += sample->cyc_cnt;
877 ts->last_time = sample->time; 891 ts->last_time = sample->time;
878 892
879 if (sample->flags & PERF_IP_FLAG_CALL) { 893 if (sample->flags & PERF_IP_FLAG_CALL) {
diff --git a/tools/perf/util/thread-stack.h b/tools/perf/util/thread-stack.h
index 9c45f947f5a9..bddb1daf6453 100644
--- a/tools/perf/util/thread-stack.h
+++ b/tools/perf/util/thread-stack.h
@@ -52,6 +52,8 @@ enum {
52 * @call_time: timestamp of call (if known) 52 * @call_time: timestamp of call (if known)
53 * @return_time: timestamp of return (if known) 53 * @return_time: timestamp of return (if known)
54 * @branch_count: number of branches seen between call and return 54 * @branch_count: number of branches seen between call and return
55 * @insn_count: approx. number of instructions between call and return
56 * @cyc_count: approx. number of cycles between call and return
55 * @call_ref: external reference to 'call' sample (e.g. db_id) 57 * @call_ref: external reference to 'call' sample (e.g. db_id)
56 * @return_ref: external reference to 'return' sample (e.g. db_id) 58 * @return_ref: external reference to 'return' sample (e.g. db_id)
57 * @db_id: id used for db-export 59 * @db_id: id used for db-export
@@ -65,6 +67,8 @@ struct call_return {
65 u64 call_time; 67 u64 call_time;
66 u64 return_time; 68 u64 return_time;
67 u64 branch_count; 69 u64 branch_count;
70 u64 insn_count;
71 u64 cyc_count;
68 u64 call_ref; 72 u64 call_ref;
69 u64 return_ref; 73 u64 return_ref;
70 u64 db_id; 74 u64 db_id;