tp: parse tracing_started event and drop ftrace packets before it
ftrace can occasionally be buggy and may lead to events being included
in the trace from well before the tracing started. Until now we've just
included these events in the trace even though they really shouldn't be.
This CL introduces parsing of the tracing_started TraceServiceEvent
which gives the timestamp where tracing started (before any producer
is informed of tracing being ready).
We then use this timestamp and filter out all events before it. This
filtering is restricted to ftrace only as it's the only data source
fully under our control - if other producers want to write data from
before trace start, that's their choice.
Bug: 154156099
Change-Id: I8be103d091cd13c85a695688ae7e13c852b93e25
diff --git a/src/trace_processor/storage/stats.h b/src/trace_processor/storage/stats.h
index a163ac9..4656953 100644
--- a/src/trace_processor/storage/stats.h
+++ b/src/trace_processor/storage/stats.h
@@ -151,7 +151,12 @@
F(perf_samples_skipped_dataloss, kSingle, kDataLoss, kTrace, ""), \
F(thread_time_in_state_out_of_order, kSingle, kError, kAnalysis, ""), \
F(thread_time_in_state_unknown_cpu_freq, \
- kSingle, kError, kAnalysis, "")
+ kSingle, kError, kAnalysis, ""), \
+ F(ftrace_packet_before_tracing_start, kSingle, kInfo, kAnalysis, \
+ "An ftrace packet was seen before the tracing start timestamp from " \
+ "the tracing service. This happens if the ftrace buffers were not " \
+ "cleared properly. These packets are silently dropped by trace " \
+ "processor.")
// clang-format on
enum Type {