Skip to content

Commit 347a738

Browse files
ahunter6acmel
authored andcommitted
perf intel-pt: Add support for decoding PSB+ only
A single q option decodes ip from only FUP/TIP packets. Make it so that repeating the q option (i.e. qq) decodes only PSB+, getting ip if there is a FUP packet within PSB+ (i.e. between PSB and PSBEND). Example: $ perf record -e intel_pt//u grep -rI pudding drivers [ perf record: Woken up 52 times to write data ] [ perf record: Captured and wrote 57.870 MB perf.data ] $ time perf script --itrace=bi | wc -l 58948289 real 1m23.863s user 1m23.251s sys 0m7.452s $ time perf script --itrace=biq | wc -l 3385694 real 0m4.453s user 0m4.455s sys 0m0.328s $ time perf script --itrace=biqq | wc -l 1883 real 0m0.047s user 0m0.043s sys 0m0.009s Signed-off-by: Adrian Hunter <[email protected]> Reviewed-by: Andi Kleen <[email protected]> Tested-by: Arnaldo Carvalho de Melo <[email protected]> Cc: Jiri Olsa <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 7c1b16b commit 347a738

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

tools/perf/Documentation/perf-intel-pt.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,21 @@ What *will* be decoded with the (single) q option:
999999
Note the q option does not specify what events will be synthesized e.g. the p
10001000
option must be used also to show power events.
10011001

1002+
Repeating the q option (double-q i.e. qq) results in even faster decoding and even
1003+
less detail. The decoder decodes only extended PSB (PSB+) packets, getting the
1004+
instruction pointer if there is a FUP packet within PSB+ (i.e. between PSB and
1005+
PSBEND). Note PSB packets occur regularly in the trace based on the psb_period
1006+
config term (refer config terms section). There will be a FUP packet if the
1007+
PSB+ occurs while control flow is being traced.
1008+
1009+
What will *not* be decoded with the qq option:
1010+
1011+
- everything except instruction pointer associated with PSB packets
1012+
1013+
What *will* be decoded with the qq option:
1014+
1015+
- instruction pointer associated with PSB packets
1016+
10021017

10031018
dump option
10041019
~~~~~~~~~~~

tools/perf/util/intel-pt-decoder/intel-pt-decoder.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct intel_pt_decoder {
113113
bool in_psb;
114114
bool hop;
115115
bool hop_psb_fup;
116+
bool leap;
116117
enum intel_pt_param_flags flags;
117118
uint64_t pos;
118119
uint64_t last_ip;
@@ -240,6 +241,7 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params)
240241
decoder->return_compression = params->return_compression;
241242
decoder->branch_enable = params->branch_enable;
242243
decoder->hop = params->quick >= 1;
244+
decoder->leap = params->quick >= 2;
243245

244246
decoder->flags = params->flags;
245247

@@ -1903,9 +1905,18 @@ static int intel_pt_resample(struct intel_pt_decoder *decoder)
19031905
#define HOP_RETURN 2
19041906
#define HOP_AGAIN 3
19051907

1908+
static int intel_pt_scan_for_psb(struct intel_pt_decoder *decoder);
1909+
19061910
/* Hop mode: Ignore TNT, do not walk code, but get ip from FUPs and TIPs */
19071911
static int intel_pt_hop_trace(struct intel_pt_decoder *decoder, bool *no_tip, int *err)
19081912
{
1913+
/* Leap from PSB to PSB, getting ip from FUP within PSB+ */
1914+
if (decoder->leap && !decoder->in_psb && decoder->packet.type != INTEL_PT_PSB) {
1915+
*err = intel_pt_scan_for_psb(decoder);
1916+
if (*err)
1917+
return HOP_RETURN;
1918+
}
1919+
19091920
switch (decoder->packet.type) {
19101921
case INTEL_PT_TNT:
19111922
return HOP_IGNORE;
@@ -2681,6 +2692,7 @@ static int intel_pt_sync(struct intel_pt_decoder *decoder)
26812692
decoder->ip = 0;
26822693
intel_pt_clear_stack(&decoder->stack);
26832694

2695+
leap:
26842696
err = intel_pt_scan_for_psb(decoder);
26852697
if (err)
26862698
return err;
@@ -2702,6 +2714,12 @@ static int intel_pt_sync(struct intel_pt_decoder *decoder)
27022714
decoder->pkt_state = INTEL_PT_STATE_RESAMPLE;
27032715
else
27042716
decoder->pkt_state = INTEL_PT_STATE_IN_SYNC;
2717+
} else if (decoder->leap) {
2718+
/*
2719+
* In leap mode, only PSB+ is decoded, so keeping leaping to the
2720+
* next PSB until there is an ip.
2721+
*/
2722+
goto leap;
27052723
} else {
27062724
return intel_pt_sync_ip(decoder);
27072725
}

0 commit comments

Comments
 (0)