perf intel-pt: Record when decoding PSB+ packets
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 20 May 2019 11:37:15 +0000 (14:37 +0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 5 Jun 2019 12:47:56 +0000 (09:47 -0300)
In preparation for using MTC packets to count cycles, record whether
decoding is between a PSB and PSBEND packets.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lkml.kernel.org/r/20190520113728.14389-10-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c

index ef3a1c1cd25094a8cb5ee0124552788fec72217c..a2384a3149904bbf07c1406251785a9913a3132c 100644 (file)
@@ -116,6 +116,7 @@ struct intel_pt_decoder {
        bool have_cyc;
        bool fixup_last_mtc;
        bool have_last_ip;
+       bool in_psb;
        enum intel_pt_param_flags flags;
        uint64_t pos;
        uint64_t last_ip;
@@ -1549,14 +1550,17 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
 {
        int err;
 
+       decoder->in_psb = true;
+
        while (1) {
                err = intel_pt_get_next_packet(decoder);
                if (err)
-                       return err;
+                       goto out;
 
                switch (decoder->packet.type) {
                case INTEL_PT_PSBEND:
-                       return 0;
+                       err = 0;
+                       goto out;
 
                case INTEL_PT_TIP_PGD:
                case INTEL_PT_TIP_PGE:
@@ -1574,10 +1578,12 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
                case INTEL_PT_PWRX:
                        decoder->have_tma = false;
                        intel_pt_log("ERROR: Unexpected packet\n");
-                       return -EAGAIN;
+                       err = -EAGAIN;
+                       goto out;
 
                case INTEL_PT_OVF:
-                       return intel_pt_overflow(decoder);
+                       err = intel_pt_overflow(decoder);
+                       goto out;
 
                case INTEL_PT_TSC:
                        intel_pt_calc_tsc_timestamp(decoder);
@@ -1623,6 +1629,10 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder)
                        break;
                }
        }
+out:
+       decoder->in_psb = false;
+
+       return err;
 }
 
 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)
 {
        int err;
 
+       decoder->in_psb = true;
+
        while (1) {
                err = intel_pt_get_next_packet(decoder);
                if (err)
-                       return err;
+                       goto out;
 
                switch (decoder->packet.type) {
                case INTEL_PT_TIP_PGD:
@@ -2015,7 +2027,8 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
                case INTEL_PT_PWRE:
                case INTEL_PT_PWRX:
                        intel_pt_log("ERROR: Unexpected packet\n");
-                       return -ENOENT;
+                       err = -ENOENT;
+                       goto out;
 
                case INTEL_PT_FUP:
                        decoder->pge = true;
@@ -2074,16 +2087,20 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
                                decoder->pkt_state = INTEL_PT_STATE_ERR4;
                        else
                                decoder->pkt_state = INTEL_PT_STATE_ERR3;
-                       return -ENOENT;
+                       err = -ENOENT;
+                       goto out;
 
                case INTEL_PT_BAD: /* Does not happen */
-                       return intel_pt_bug(decoder);
+                       err = intel_pt_bug(decoder);
+                       goto out;
 
                case INTEL_PT_OVF:
-                       return intel_pt_overflow(decoder);
+                       err = intel_pt_overflow(decoder);
+                       goto out;
 
                case INTEL_PT_PSBEND:
-                       return 0;
+                       err = 0;
+                       goto out;
 
                case INTEL_PT_PSB:
                case INTEL_PT_VMCS:
@@ -2093,6 +2110,10 @@ static int intel_pt_walk_psb(struct intel_pt_decoder *decoder)
                        break;
                }
        }
+out:
+       decoder->in_psb = false;
+
+       return err;
 }
 
 static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)