aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Hunter <adrian.hunter@intel.com>2017-05-26 04:17:14 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-06-21 10:35:50 -0400
commita472e65fc490ab87e30b7fecb8981f02dbb2b865 (patch)
tree4cd0a729cead7fca49b1f7cd5d8c67b2839d4f3e
parent2bc60ffd663fc706ba70e603c369ae8ba0523b25 (diff)
perf intel-pt: Add decoder support for ptwrite and power event packets
Add decoder support for PTWRITE, MWAIT, PWRE, PWRX and EXSTOP packets. This patch only affects the decoder, so the tools still do not select or consume the new information. That is added in subsequent patches. Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Andi Kleen <ak@linux.intel.com> Link: http://lkml.kernel.org/r/1495786658-18063-14-git-send-email-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.c176
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.h10
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.c108
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-pkt-decoder.h7
4 files changed, 293 insertions, 8 deletions
diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index dacb9223e743..e42804d10001 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -158,8 +158,15 @@ struct intel_pt_decoder {
158 bool continuous_period; 158 bool continuous_period;
159 bool overflow; 159 bool overflow;
160 bool set_fup_tx_flags; 160 bool set_fup_tx_flags;
161 bool set_fup_ptw;
162 bool set_fup_mwait;
163 bool set_fup_pwre;
164 bool set_fup_exstop;
161 unsigned int fup_tx_flags; 165 unsigned int fup_tx_flags;
162 unsigned int tx_flags; 166 unsigned int tx_flags;
167 uint64_t fup_ptw_payload;
168 uint64_t fup_mwait_payload;
169 uint64_t fup_pwre_payload;
163 uint64_t timestamp_insn_cnt; 170 uint64_t timestamp_insn_cnt;
164 uint64_t sample_insn_cnt; 171 uint64_t sample_insn_cnt;
165 uint64_t stuck_ip; 172 uint64_t stuck_ip;
@@ -660,6 +667,8 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info)
660 case INTEL_PT_PAD: 667 case INTEL_PT_PAD:
661 case INTEL_PT_VMCS: 668 case INTEL_PT_VMCS:
662 case INTEL_PT_MNT: 669 case INTEL_PT_MNT:
670 case INTEL_PT_PTWRITE:
671 case INTEL_PT_PTWRITE_IP:
663 return 0; 672 return 0;
664 673
665 case INTEL_PT_MTC: 674 case INTEL_PT_MTC:
@@ -758,6 +767,11 @@ static int intel_pt_calc_cyc_cb(struct intel_pt_pkt_info *pkt_info)
758 767
759 case INTEL_PT_TIP_PGD: 768 case INTEL_PT_TIP_PGD:
760 case INTEL_PT_TRACESTOP: 769 case INTEL_PT_TRACESTOP:
770 case INTEL_PT_EXSTOP:
771 case INTEL_PT_EXSTOP_IP:
772 case INTEL_PT_MWAIT:
773 case INTEL_PT_PWRE:
774 case INTEL_PT_PWRX:
761 case INTEL_PT_OVF: 775 case INTEL_PT_OVF:
762 case INTEL_PT_BAD: /* Does not happen */ 776 case INTEL_PT_BAD: /* Does not happen */
763 default: 777 default:
@@ -1016,6 +1030,57 @@ out_no_progress:
1016 return err; 1030 return err;
1017} 1031}
1018 1032
1033static bool intel_pt_fup_event(struct intel_pt_decoder *decoder)
1034{
1035 bool ret = false;
1036
1037 if (decoder->set_fup_tx_flags) {
1038 decoder->set_fup_tx_flags = false;
1039 decoder->tx_flags = decoder->fup_tx_flags;
1040 decoder->state.type = INTEL_PT_TRANSACTION;
1041 decoder->state.from_ip = decoder->ip;
1042 decoder->state.to_ip = 0;
1043 decoder->state.flags = decoder->fup_tx_flags;
1044 return true;
1045 }
1046 if (decoder->set_fup_ptw) {
1047 decoder->set_fup_ptw = false;
1048 decoder->state.type = INTEL_PT_PTW;
1049 decoder->state.flags |= INTEL_PT_FUP_IP;
1050 decoder->state.from_ip = decoder->ip;
1051 decoder->state.to_ip = 0;
1052 decoder->state.ptw_payload = decoder->fup_ptw_payload;
1053 return true;
1054 }
1055 if (decoder->set_fup_mwait) {
1056 decoder->set_fup_mwait = false;
1057 decoder->state.type = INTEL_PT_MWAIT_OP;
1058 decoder->state.from_ip = decoder->ip;
1059 decoder->state.to_ip = 0;
1060 decoder->state.mwait_payload = decoder->fup_mwait_payload;
1061 ret = true;
1062 }
1063 if (decoder->set_fup_pwre) {
1064 decoder->set_fup_pwre = false;
1065 decoder->state.type |= INTEL_PT_PWR_ENTRY;
1066 decoder->state.type &= ~INTEL_PT_BRANCH;
1067 decoder->state.from_ip = decoder->ip;
1068 decoder->state.to_ip = 0;
1069 decoder->state.pwre_payload = decoder->fup_pwre_payload;
1070 ret = true;
1071 }
1072 if (decoder->set_fup_exstop) {
1073 decoder->set_fup_exstop = false;
1074 decoder->state.type |= INTEL_PT_EX_STOP;
1075 decoder->state.type &= ~INTEL_PT_BRANCH;
1076 decoder->state.flags |= INTEL_PT_FUP_IP;
1077 decoder->state.from_ip = decoder->ip;
1078 decoder->state.to_ip = 0;
1079 ret = true;
1080 }
1081 return ret;
1082}
1083
1019static int intel_pt_walk_fup(struct intel_pt_decoder *decoder) 1084static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
1020{ 1085{
1021 struct intel_pt_insn intel_pt_insn; 1086 struct intel_pt_insn intel_pt_insn;
@@ -1029,15 +1094,8 @@ static int intel_pt_walk_fup(struct intel_pt_decoder *decoder)
1029 if (err == INTEL_PT_RETURN) 1094 if (err == INTEL_PT_RETURN)
1030 return 0; 1095 return 0;
1031 if (err == -EAGAIN) { 1096 if (err == -EAGAIN) {
1032 if (decoder->set_fup_tx_flags) { 1097 if (intel_pt_fup_event(decoder))
1033 decoder->set_fup_tx_flags = false;
1034 decoder->tx_flags = decoder->fup_tx_flags;
1035 decoder->state.type = INTEL_PT_TRANSACTION;
1036 decoder->state.from_ip = decoder->ip;
1037 decoder->state.to_ip = 0;
1038 decoder->state.flags = decoder->fup_tx_flags;
1039 return 0; 1098 return 0;
1040 }
1041 return err; 1099 return err;
1042 } 1100 }
1043 decoder->set_fup_tx_flags = false; 1101 decoder->set_fup_tx_flags = false;
@@ -1443,6 +1501,13 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
1443 case INTEL_PT_TRACESTOP: 1501 case INTEL_PT_TRACESTOP:
1444 case INTEL_PT_BAD: 1502 case INTEL_PT_BAD:
1445 case INTEL_PT_PSB: 1503 case INTEL_PT_PSB:
1504 case INTEL_PT_PTWRITE:
1505 case INTEL_PT_PTWRITE_IP:
1506 case INTEL_PT_EXSTOP:
1507 case INTEL_PT_EXSTOP_IP:
1508 case INTEL_PT_MWAIT:
1509 case INTEL_PT_PWRE:
1510 case INTEL_PT_PWRX:
1446 decoder->have_tma = false; 1511 decoder->have_tma = false;
1447 intel_pt_log("ERROR: Unexpected packet\n"); 1512 intel_pt_log("ERROR: Unexpected packet\n");
1448 return -EAGAIN; 1513 return -EAGAIN;
@@ -1524,6 +1589,13 @@ static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
1524 case INTEL_PT_MODE_TSX: 1589 case INTEL_PT_MODE_TSX:
1525 case INTEL_PT_BAD: 1590 case INTEL_PT_BAD:
1526 case INTEL_PT_PSBEND: 1591 case INTEL_PT_PSBEND:
1592 case INTEL_PT_PTWRITE:
1593 case INTEL_PT_PTWRITE_IP:
1594 case INTEL_PT_EXSTOP:
1595 case INTEL_PT_EXSTOP_IP:
1596 case INTEL_PT_MWAIT:
1597 case INTEL_PT_PWRE:
1598 case INTEL_PT_PWRX:
1527 intel_pt_log("ERROR: Missing TIP after FUP\n"); 1599 intel_pt_log("ERROR: Missing TIP after FUP\n");
1528 decoder->pkt_state = INTEL_PT_STATE_ERR3; 1600 decoder->pkt_state = INTEL_PT_STATE_ERR3;
1529 return -ENOENT; 1601 return -ENOENT;
@@ -1654,8 +1726,13 @@ next:
1654 intel_pt_set_last_ip(decoder); 1726 intel_pt_set_last_ip(decoder);
1655 if (!decoder->branch_enable) { 1727 if (!decoder->branch_enable) {
1656 decoder->ip = decoder->last_ip; 1728 decoder->ip = decoder->last_ip;
1729 if (intel_pt_fup_event(decoder))
1730 return 0;
1731 no_tip = false;
1657 break; 1732 break;
1658 } 1733 }
1734 if (decoder->set_fup_mwait)
1735 no_tip = true;
1659 err = intel_pt_walk_fup(decoder); 1736 err = intel_pt_walk_fup(decoder);
1660 if (err != -EAGAIN) { 1737 if (err != -EAGAIN) {
1661 if (err) 1738 if (err)
@@ -1755,6 +1832,71 @@ next: