aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2019-05-20 07:37:13 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-06-05 08:47:56 -0400
commit5b1dc0fd1da06d6e89f1ca8736cfe0ee84e34cc7 (patch)
treef26b54691badf4c122837377ac317bb267362eff /tools/perf
parent61d276f428a11f0e4ce5203462fa488e6570684f (diff)
perf intel-pt: Add support for samples to contain IPC ratio
Copy the incremental instruction count and cycle count onto 'instructions' and 'branches' samples. Because Intel PT does not update the cycle count on every branch or instruction, the incremental values will often be zero. When there are values, they will be the number of instructions and number of cycles since the last update, and thus represent the average IPC since the last IPC value. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@redhat.com> Link: http://lkml.kernel.org/r/20190520113728.14389-8-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/intel-pt.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c
index 7a70693c1b91..3cff8fe2eaa0 100644
--- a/tools/perf/util/intel-pt.c
+++ b/tools/perf/util/intel-pt.c
@@ -157,6 +157,12 @@ struct intel_pt_queue {
157 u32 flags; 157 u32 flags;
158 u16 insn_len; 158 u16 insn_len;
159 u64 last_insn_cnt; 159 u64 last_insn_cnt;
160 u64 ipc_insn_cnt;
161 u64 ipc_cyc_cnt;
162 u64 last_in_insn_cnt;
163 u64 last_in_cyc_cnt;
164 u64 last_br_insn_cnt;
165 u64 last_br_cyc_cnt;
160 char insn[INTEL_PT_INSN_BUF_SZ]; 166 char insn[INTEL_PT_INSN_BUF_SZ];
161}; 167};
162 168
@@ -1162,6 +1168,13 @@ static int intel_pt_synth_branch_sample(struct intel_pt_queue *ptq)
1162 sample.branch_stack = (struct branch_stack *)&dummy_bs; 1168 sample.branch_stack = (struct branch_stack *)&dummy_bs;
1163 } 1169 }
1164 1170
1171 sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_br_cyc_cnt;
1172 if (sample.cyc_cnt) {
1173 sample.insn_cnt = ptq->ipc_insn_cnt - ptq->last_br_insn_cnt;
1174 ptq->last_br_insn_cnt = ptq->ipc_insn_cnt;
1175 ptq->last_br_cyc_cnt = ptq->ipc_cyc_cnt;
1176 }
1177
1165 return intel_pt_deliver_synth_b_event(pt, event, &sample, 1178 return intel_pt_deliver_synth_b_event(pt, event, &sample,
1166 pt->branches_sample_type); 1179 pt->branches_sample_type);
1167} 1180}
@@ -1217,6 +1230,13 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq)
1217 sample.stream_id = ptq->pt->instructions_id; 1230 sample.stream_id = ptq->pt->instructions_id;
1218 sample.period = ptq->state->tot_insn_cnt - ptq->last_insn_cnt; 1231 sample.period = ptq->state->tot_insn_cnt - ptq->last_insn_cnt;
1219 1232
1233 sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_in_cyc_cnt;
1234 if (sample.cyc_cnt) {
1235 sample.insn_cnt = ptq->ipc_insn_cnt - ptq->last_in_insn_cnt;
1236 ptq->last_in_insn_cnt = ptq->ipc_insn_cnt;
1237 ptq->last_in_cyc_cnt = ptq->ipc_cyc_cnt;
1238 }
1239
1220 ptq->last_insn_cnt = ptq->state->tot_insn_cnt; 1240 ptq->last_insn_cnt = ptq->state->tot_insn_cnt;
1221 1241
1222 return intel_pt_deliver_synth_event(pt, ptq, event, &sample, 1242 return intel_pt_deliver_synth_event(pt, ptq, event, &sample,
@@ -1488,6 +1508,15 @@ static int intel_pt_sample(struct intel_pt_queue *ptq)
1488 1508
1489 ptq->have_sample = false; 1509 ptq->have_sample = false;
1490 1510
1511 if (ptq->state->tot_cyc_cnt > ptq->ipc_cyc_cnt) {
1512 /*
1513 * Cycle count and instruction count only go together to create
1514 * a valid IPC ratio when the cycle count changes.
1515 */
1516 ptq->ipc_insn_cnt = ptq->state->tot_insn_cnt;
1517 ptq->ipc_cyc_cnt = ptq->state->tot_cyc_cnt;
1518 }
1519
1491 if (pt->sample_pwr_events && (state->type & INTEL_PT_PWR_EVT)) { 1520 if (pt->sample_pwr_events && (state->type & INTEL_PT_PWR_EVT)) {
1492 if (state->type & INTEL_PT_CBR_CHG) { 1521 if (state->type & INTEL_PT_CBR_CHG) {
1493 err = intel_pt_synth_cbr_sample(ptq); 1522 err = intel_pt_synth_cbr_sample(ptq);