Skip to content

Commit d4575f5

Browse files
ahunter6acmel
authored andcommitted
perf intel-pt: Time filter logged perf events
Change the debug logging (when used with the --time option) to time filter logged perf events, but allow that to be overridden by using "d+a" instead of plain "d". That can reduce the size of the log file. Signed-off-by: Adrian Hunter <[email protected]> Reviewed-by: Andi Kleen <[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 8b83fcc commit d4575f5

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,9 @@ and that the resulting file may be very large. The "d" option may be followed
886886
by flags which affect what debug messages will or will not be logged. Each flag
887887
must be preceded by either '+' or '-'. The flags support by Intel PT are:
888888
-a Suppress logging of perf events
889+
+a Log all perf events
890+
By default, logged perf events are filtered by any specified time ranges, but
891+
flag +a overrides that.
889892

890893
In addition, the period of the "instructions" event can be specified. e.g.
891894

tools/perf/util/intel-pt.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,22 @@ static void intel_pt_dump_sample(struct perf_session *session,
249249
intel_pt_dump(pt, sample->aux_sample.data, sample->aux_sample.size);
250250
}
251251

252-
static bool intel_pt_log_events(struct intel_pt *pt)
252+
static bool intel_pt_log_events(struct intel_pt *pt, u64 tm)
253253
{
254-
return !(pt->synth_opts.log_minus_flags & AUXTRACE_LOG_FLG_ALL_PERF_EVTS);
254+
struct perf_time_interval *range = pt->synth_opts.ptime_range;
255+
int n = pt->synth_opts.range_num;
256+
257+
if (pt->synth_opts.log_plus_flags & AUXTRACE_LOG_FLG_ALL_PERF_EVTS)
258+
return true;
259+
260+
if (pt->synth_opts.log_minus_flags & AUXTRACE_LOG_FLG_ALL_PERF_EVTS)
261+
return false;
262+
263+
/* perf_time__ranges_skip_sample does not work if time is zero */
264+
if (!tm)
265+
tm = 1;
266+
267+
return !n || !perf_time__ranges_skip_sample(range, n, tm);
255268
}
256269

257270
static int intel_pt_do_fix_overlap(struct intel_pt *pt, struct auxtrace_buffer *a,
@@ -2747,7 +2760,7 @@ static int intel_pt_process_event(struct perf_session *session,
27472760
if (!err && event->header.type == PERF_RECORD_TEXT_POKE)
27482761
err = intel_pt_text_poke(pt, event);
27492762

2750-
if (intel_pt_enable_logging && intel_pt_log_events(pt)) {
2763+
if (intel_pt_enable_logging && intel_pt_log_events(pt, sample->time)) {
27512764
intel_pt_log("event %u: cpu %d time %"PRIu64" tsc %#"PRIx64" ",
27522765
event->header.type, sample->cpu, sample->time, timestamp);
27532766
intel_pt_log_event(event);

0 commit comments

Comments
 (0)