perf intel-pt: Time filter logged perf events
[linux-2.6-microblaze.git] / tools / perf / util / intel-pt.c
index 9cef46c..0715d6e 100644 (file)
@@ -249,6 +249,24 @@ static void intel_pt_dump_sample(struct perf_session *session,
        intel_pt_dump(pt, sample->aux_sample.data, sample->aux_sample.size);
 }
 
+static bool intel_pt_log_events(struct intel_pt *pt, u64 tm)
+{
+       struct perf_time_interval *range = pt->synth_opts.ptime_range;
+       int n = pt->synth_opts.range_num;
+
+       if (pt->synth_opts.log_plus_flags & AUXTRACE_LOG_FLG_ALL_PERF_EVTS)
+               return true;
+
+       if (pt->synth_opts.log_minus_flags & AUXTRACE_LOG_FLG_ALL_PERF_EVTS)
+               return false;
+
+       /* perf_time__ranges_skip_sample does not work if time is zero */
+       if (!tm)
+               tm = 1;
+
+       return !n || !perf_time__ranges_skip_sample(range, n, tm);
+}
+
 static int intel_pt_do_fix_overlap(struct intel_pt *pt, struct auxtrace_buffer *a,
                                   struct auxtrace_buffer *b)
 {
@@ -1863,6 +1881,15 @@ static int intel_pt_synth_error(struct intel_pt *pt, int code, int cpu,
        char msg[MAX_AUXTRACE_ERROR_MSG];
        int err;
 
+       if (pt->synth_opts.error_minus_flags) {
+               if (code == INTEL_PT_ERR_OVR &&
+                   pt->synth_opts.error_minus_flags & AUXTRACE_ERR_FLG_OVERFLOW)
+                       return 0;
+               if (code == INTEL_PT_ERR_LOST &&
+                   pt->synth_opts.error_minus_flags & AUXTRACE_ERR_FLG_DATA_LOST)
+                       return 0;
+       }
+
        intel_pt__strerror(code, msg, MAX_AUXTRACE_ERROR_MSG);
 
        auxtrace_synth_error(&event.auxtrace_error, PERF_AUXTRACE_ERROR_ITRACE,
@@ -2577,10 +2604,6 @@ static int intel_pt_context_switch(struct intel_pt *pt, union perf_event *event,
                return -EINVAL;
        }
 
-       intel_pt_log("context_switch: cpu %d pid %d tid %d time %"PRIu64" tsc %#"PRIx64"\n",
-                    cpu, pid, tid, sample->time, perf_time_to_tsc(sample->time,
-                    &pt->tc));
-
        ret = intel_pt_sync_switch(pt, cpu, tid, sample->time);
        if (ret <= 0)
                return ret;
@@ -2737,9 +2760,11 @@ static int intel_pt_process_event(struct perf_session *session,
        if (!err && event->header.type == PERF_RECORD_TEXT_POKE)
                err = intel_pt_text_poke(pt, event);
 
-       intel_pt_log("event %u: cpu %d time %"PRIu64" tsc %#"PRIx64" ",
-                    event->header.type, sample->cpu, sample->time, timestamp);
-       intel_pt_log_event(event);
+       if (intel_pt_enable_logging && intel_pt_log_events(pt, sample->time)) {
+               intel_pt_log("event %u: cpu %d time %"PRIu64" tsc %#"PRIx64" ",
+                            event->header.type, sample->cpu, sample->time, timestamp);
+               intel_pt_log_event(event);
+       }
 
        return err;
 }