Commit 9bc668e3 authored by Adrian Hunter's avatar Adrian Hunter Committed by Arnaldo Carvalho de Melo

perf intel-pt: Record when decoding PSB+ packets

In preparation for using MTC packets to count cycles, record whether
decoding is between a PSB and PSBEND packets.
Signed-off-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190520113728.14389-10-adrian.hunter@intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 68fb45bf
...@@ -116,6 +116,7 @@ struct intel_pt_decoder { ...@@ -116,6 +116,7 @@ struct intel_pt_decoder {
bool have_cyc; bool have_cyc;
bool fixup_last_mtc; bool fixup_last_mtc;
bool have_last_ip; bool have_last_ip;
bool in_psb;
enum intel_pt_param_flags flags; enum intel_pt_param_flags flags;
uint64_t pos; uint64_t pos;
uint64_t last_ip; uint64_t last_ip;
...@@ -1549,14 +1550,17 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder) ...@@ -1549,14 +1550,17 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
{ {
int err; int err;
decoder->in_psb = true;
while (1) { while (1) {
err = intel_pt_get_next_packet(decoder); err = intel_pt_get_next_packet(decoder);
if (err) if (err)
return err; goto out;
switch (decoder->packet.type) { switch (decoder->packet.type) {
case INTEL_PT_PSBEND: case INTEL_PT_PSBEND:
return 0; err = 0;
goto out;
case INTEL_PT_TIP_PGD: case INTEL_PT_TIP_PGD:
case INTEL_PT_TIP_PGE: case INTEL_PT_TIP_PGE:
...@@ -1574,10 +1578,12 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder) ...@@ -1574,10 +1578,12 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
case INTEL_PT_PWRX: case INTEL_PT_PWRX:
decoder->have_tma = false; decoder->have_tma = false;
intel_pt_log("ERROR: Unexpected packet\n"); intel_pt_log("ERROR: Unexpected packet\n");
return -EAGAIN; err = -EAGAIN;
goto out;
case INTEL_PT_OVF: case INTEL_PT_OVF:
return intel_pt_overflow(decoder); err = intel_pt_overflow(decoder);
goto out;
case INTEL_PT_TSC: case INTEL_PT_TSC:
intel_pt_calc_tsc_timestamp(decoder); intel_pt_calc_tsc_timestamp(decoder);
...@@ -1623,6 +1629,10 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder) ...@@ -1623,6 +1629,10 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
break; break;
} }
} }
out:
decoder->in_psb = false;
return err;
} }
static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder) static int intel_pt_walk_fup_tip(struct intel_pt_decoder *decoder)
...@@ -1996,10 +2006,12 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder) ...@@ -1996,10 +2006,12 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
{ {
int err; int err;
decoder->in_psb = true;
while (1) { while (1) {
err = intel_pt_get_next_packet(decoder); err = intel_pt_get_next_packet(decoder);
if (err) if (err)
return err; goto out;
switch (decoder->packet.type) { switch (decoder->packet.type) {
case INTEL_PT_TIP_PGD: case INTEL_PT_TIP_PGD:
...@@ -2015,7 +2027,8 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder) ...@@ -2015,7 +2027,8 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
case INTEL_PT_PWRE: case INTEL_PT_PWRE:
case INTEL_PT_PWRX: case INTEL_PT_PWRX:
intel_pt_log("ERROR: Unexpected packet\n"); intel_pt_log("ERROR: Unexpected packet\n");
return -ENOENT; err = -ENOENT;
goto out;
case INTEL_PT_FUP: case INTEL_PT_FUP:
decoder->pge = true; decoder->pge = true;
...@@ -2074,16 +2087,20 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder) ...@@ -2074,16 +2087,20 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
decoder->pkt_state = INTEL_PT_STATE_ERR4; decoder->pkt_state = INTEL_PT_STATE_ERR4;
else else
decoder->pkt_state = INTEL_PT_STATE_ERR3; decoder->pkt_state = INTEL_PT_STATE_ERR3;
return -ENOENT; err = -ENOENT;
goto out;
case INTEL_PT_BAD: /* Does not happen */ case INTEL_PT_BAD: /* Does not happen */
return intel_pt_bug(decoder); err = intel_pt_bug(decoder);
goto out;
case INTEL_PT_OVF: case INTEL_PT_OVF:
return intel_pt_overflow(decoder); err = intel_pt_overflow(decoder);
goto out;
case INTEL_PT_PSBEND: case INTEL_PT_PSBEND:
return 0; err = 0;
goto out;
case INTEL_PT_PSB: case INTEL_PT_PSB:
case INTEL_PT_VMCS: case INTEL_PT_VMCS:
...@@ -2093,6 +2110,10 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder) ...@@ -2093,6 +2110,10 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
break; break;
} }
} }
out:
decoder->in_psb = false;
return err;
} }
static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder) static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
......
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