Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1651190
| From | Adrian Hunter <adrian.hunter@intel.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH V2 05/37] perf intel-pt: Fix last_ip usage |
| Date | 2017-05-26 10:40 +0200 |
| Message-ID | <tLiWR-3x5-1@gated-at.bofh.it> (permalink) |
| References | <tLiNb-3tM-9@gated-at.bofh.it> |
| Organization | Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki |
Intel PT uses IP compression based on the last IP. For decoding purposes,
'last IP' is considered to be reset to zero whenever there is a
synchronization packet (PSB). The decoder wasn't doing that, and was
treating the zero value to mean that there was no last IP, whereas
compression can be done against the zero value. Fix by setting last_ip to
zero when a PSB is received and keep track of have_last_ip.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: stable@vger.kernel.org # prereq. e1717e0485af
---
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 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 f9cd3aaef488..62e2c2ad3f1d 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -111,6 +111,7 @@ struct intel_pt_decoder {
bool have_tma;
bool have_cyc;
bool fixup_last_mtc;
+ bool have_last_ip;
uint64_t pos;
uint64_t last_ip;
uint64_t ip;
@@ -419,6 +420,7 @@ static uint64_t intel_pt_calc_ip(const struct intel_pt_pkt *packet,
static inline void intel_pt_set_last_ip(struct intel_pt_decoder *decoder)
{
decoder->last_ip = intel_pt_calc_ip(&decoder->packet, decoder->last_ip);
+ decoder->have_last_ip = true;
}
static inline void intel_pt_set_ip(struct intel_pt_decoder *decoder)
@@ -1672,6 +1674,8 @@ static int intel_pt_walk_trace(struct intel_pt_decoder *decoder)
break;
case INTEL_PT_PSB:
+ decoder->last_ip = 0;
+ decoder->have_last_ip = true;
intel_pt_clear_stack(&decoder->stack);
err = intel_pt_walk_psbend(decoder);
if (err == -EAGAIN)
@@ -1752,7 +1756,7 @@ static int intel_pt_walk_trace(struct intel_pt_decoder *decoder)
static inline bool intel_pt_have_ip(struct intel_pt_decoder *decoder)
{
- return decoder->last_ip || decoder->packet.count == 0 ||
+ return decoder->have_last_ip || decoder->packet.count == 0 ||
decoder->packet.count == 3 || decoder->packet.count == 6;
}
@@ -1882,7 +1886,7 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
if (decoder->ip)
return 0;
}
- if (decoder->packet.count)
+ if (decoder->packet.count && decoder->have_last_ip)
intel_pt_set_last_ip(decoder);
break;
@@ -1932,6 +1936,8 @@ static int intel_pt_walk_to_ip(struct intel_pt_decoder *decoder)
break;
case INTEL_PT_PSB:
+ decoder->last_ip = 0;
+ decoder->have_last_ip = true;
intel_pt_clear_stack(&decoder->stack);
err = intel_pt_walk_psb(decoder);
if (err)
@@ -2066,6 +2072,7 @@ static int intel_pt_sync(struct intel_pt_decoder *decoder)
decoder->pge = false;
decoder->continuous_period = false;
+ decoder->have_last_ip = false;
decoder->last_ip = 0;
decoder->ip = 0;
intel_pt_clear_stack(&decoder->stack);
@@ -2074,6 +2081,7 @@ static int intel_pt_sync(struct intel_pt_decoder *decoder)
if (err)
return err;
+ decoder->have_last_ip = true;
decoder->pkt_state = INTEL_PT_STATE_NO_IP;
err = intel_pt_walk_psb(decoder);
@@ -2116,6 +2124,7 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder)
err = intel_pt_sync(decoder);
break;
case INTEL_PT_STATE_NO_IP:
+ decoder->have_last_ip = false;
decoder->last_ip = 0;
decoder->ip = 0;
/* Fall through */
--
1.9.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH V2 00/37] perf intel-pt: Power events and PTWRITE Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:30 +0200 [PATCH V2 05/37] perf intel-pt: Fix last_ip usage Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:40 +0200 [PATCH V2 02/37] perf intel-pt: Improve sample timestamp Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:40 +0200 [PATCH V2 10/37] perf intel-pt: Allow decoding with branch tracing disabled Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:40 +0200 [PATCH V2 15/37] perf intel-pt: Add decoder support for CBR events Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:40 +0200 [PATCH V2 13/37] perf intel-pt: Add decoder support for ptwrite and power event packets Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:40 +0200 [PATCH V2 04/37] perf intel-pt: Ensure IP is zero when state is INTEL_PT_STATE_NO_IP Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:40 +0200 [PATCH V2 03/37] perf intel-pt: Fix missing stack clear Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:40 +0200 [PATCH V2 22/37] tools include: Add byte-swapping macros to kernel.h Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:40 +0200 [PATCH V2 06/37] perf intel-pt: Ensure never to set 'last_ip' when packet 'count' is zero Adrian Hunter <adrian.hunter@intel.com> - 2017-05-26 10:40 +0200
csiph-web