perf session: Add perf_session__deliver_synth_event()
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 27 Oct 2014 13:49:23 +0000 (15:49 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 29 Oct 2014 13:36:15 +0000 (11:36 -0200)
Add a function to deliver synthesized events from within a session.

Intel PT decoding works by synthesizing events (primarily branch events)
that can then be consumed by existing tools.  This function will be used
to deliver those events.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/1414417770-18602-3-git-send-email-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/session.c
tools/perf/util/session.h

index 58dd5ceb8bef3c553e796de0ba5e8fbc006c3eb5..f4478ce72fdb298aba4638dae0425003e1ca1522 100644 (file)
@@ -907,6 +907,19 @@ static s64 perf_session__process_user_event(struct perf_session *session,
        }
 }
 
+int perf_session__deliver_synth_event(struct perf_session *session,
+                                     union perf_event *event,
+                                     struct perf_sample *sample,
+                                     struct perf_tool *tool)
+{
+       events_stats__inc(&session->stats, event->header.type);
+
+       if (event->header.type >= PERF_RECORD_USER_TYPE_START)
+               return perf_session__process_user_event(session, event, tool, 0);
+
+       return perf_session__deliver_event(session, event, sample, tool, 0);
+}
+
 static void event_swap(union perf_event *event, bool sample_id_all)
 {
        perf_event__swap_op swap;
index d8521ac73a106472f8e95963af98f7d14772f9b4..dc26ebf60fe421050b58eafa9c8fb29d49fa3f0a 100644 (file)
@@ -127,6 +127,11 @@ extern volatile int session_done;
 
 #define session_done() ACCESS_ONCE(session_done)
 
+int perf_session__deliver_synth_event(struct perf_session *session,
+                                     union perf_event *event,
+                                     struct perf_sample *sample,
+                                     struct perf_tool *tool);
+
 int perf_event__process_id_index(struct perf_tool *tool,
                                 union perf_event *event,
                                 struct perf_session *session);