Commit 003ccdc7 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

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: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190520113728.14389-14-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 5db47f43
...@@ -49,6 +49,8 @@ enum retpoline_state_t { ...@@ -49,6 +49,8 @@ enum retpoline_state_t {
* @timestamp: timestamp (if known) * @timestamp: timestamp (if known)
* @ref: external reference (e.g. db_id of sample) * @ref: external reference (e.g. db_id of sample)
* @branch_count: the branch count when the entry was created * @branch_count: the branch count when the entry was created
* @insn_count: the instruction count when the entry was created
* @cyc_count the cycle count when the entry was created
* @db_id: id used for db-export * @db_id: id used for db-export
* @cp: call path * @cp: call path
* @no_call: a 'call' was not seen * @no_call: a 'call' was not seen
...@@ -60,6 +62,8 @@ struct thread_stack_entry { ...@@ -60,6 +62,8 @@ struct thread_stack_entry {
u64 timestamp; u64 timestamp;
u64 ref; u64 ref;
u64 branch_count; u64 branch_count;
u64 insn_count;
u64 cyc_count;
u64 db_id; u64 db_id;
struct call_path *cp; struct call_path *cp;
bool no_call; bool no_call;
...@@ -75,6 +79,8 @@ struct thread_stack_entry { ...@@ -75,6 +79,8 @@ struct thread_stack_entry {
* @sz: current maximum stack size * @sz: current maximum stack size
* @trace_nr: current trace number * @trace_nr: current trace number
* @branch_count: running branch count * @branch_count: running branch count
* @insn_count: running instruction count
* @cyc_count running cycle count
* @kernel_start: kernel start address * @kernel_start: kernel start address
* @last_time: last timestamp * @last_time: last timestamp
* @crp: call/return processor * @crp: call/return processor
...@@ -88,6 +94,8 @@ struct thread_stack { ...@@ -88,6 +94,8 @@ struct thread_stack {
size_t sz; size_t sz;
u64 trace_nr; u64 trace_nr;
u64 branch_count; u64 branch_count;
u64 insn_count;
u64 cyc_count;
u64 kernel_start; u64 kernel_start;
u64 last_time; u64 last_time;
struct call_return_processor *crp; struct call_return_processor *crp;
...@@ -289,6 +297,8 @@ static int thread_stack__call_return(struct thread *thread, ...@@ -289,6 +297,8 @@ static int thread_stack__call_return(struct thread *thread,
cr.call_time = tse->timestamp; cr.call_time = tse->timestamp;
cr.return_time = timestamp; cr.return_time = timestamp;
cr.branch_count = ts->branch_count - tse->branch_count; cr.branch_count = ts->branch_count - tse->branch_count;
cr.insn_count = ts->insn_count - tse->insn_count;
cr.cyc_count = ts->cyc_count - tse->cyc_count;
cr.db_id = tse->db_id; cr.db_id = tse->db_id;
cr.call_ref = tse->ref; cr.call_ref = tse->ref;
cr.return_ref = ref; cr.return_ref = ref;
...@@ -544,6 +554,8 @@ static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr, ...@@ -544,6 +554,8 @@ static int thread_stack__push_cp(struct thread_stack *ts, u64 ret_addr,
tse->timestamp = timestamp; tse->timestamp = timestamp;
tse->ref = ref; tse->ref = ref;
tse->branch_count = ts->branch_count; tse->branch_count = ts->branch_count;
tse->insn_count = ts->insn_count;
tse->cyc_count = ts->cyc_count;
tse->cp = cp; tse->cp = cp;
tse->no_call = no_call; tse->no_call = no_call;
tse->trace_end = trace_end; tse->trace_end = trace_end;
...@@ -874,6 +886,8 @@ int thread_stack__process(struct thread *thread, struct comm *comm, ...@@ -874,6 +886,8 @@ int thread_stack__process(struct thread *thread, struct comm *comm,
} }
ts->branch_count += 1; ts->branch_count += 1;
ts->insn_count += sample->insn_cnt;
ts->cyc_count += sample->cyc_cnt;
ts->last_time = sample->time; ts->last_time = sample->time;
if (sample->flags & PERF_IP_FLAG_CALL) { if (sample->flags & PERF_IP_FLAG_CALL) {
......
...@@ -52,6 +52,8 @@ enum { ...@@ -52,6 +52,8 @@ enum {
* @call_time: timestamp of call (if known) * @call_time: timestamp of call (if known)
* @return_time: timestamp of return (if known) * @return_time: timestamp of return (if known)
* @branch_count: number of branches seen between call and return * @branch_count: number of branches seen between call and return
* @insn_count: approx. number of instructions between call and return
* @cyc_count: approx. number of cycles between call and return
* @call_ref: external reference to 'call' sample (e.g. db_id) * @call_ref: external reference to 'call' sample (e.g. db_id)
* @return_ref: external reference to 'return' sample (e.g. db_id) * @return_ref: external reference to 'return' sample (e.g. db_id)
* @db_id: id used for db-export * @db_id: id used for db-export
...@@ -65,6 +67,8 @@ struct call_return { ...@@ -65,6 +67,8 @@ struct call_return {
u64 call_time; u64 call_time;
u64 return_time; u64 return_time;
u64 branch_count; u64 branch_count;
u64 insn_count;
u64 cyc_count;
u64 call_ref; u64 call_ref;
u64 return_ref; u64 return_ref;
u64 db_id; u64 db_id;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment