From 89f821b4eb5928dd47269f50f51aae81bbcc03aa Mon Sep 17 00:00:00 2001 From: Jaewon Kim Date: Tue, 19 Sep 2023 21:18:35 +0900 Subject: [PATCH] to_ftrace: add samsung_tracing_mark_write Bug: 291512082 Signed-off-by: Jaewon Kim Change-Id: I1f5448a44c522c252a3d5d54f6900831ab281327 --- .../importers/ftrace/ftrace_descriptors.cc | 14 ++++++++++++- .../importers/ftrace/ftrace_parser.cc | 21 +++++++++++++++++++ .../importers/ftrace/ftrace_parser.h | 3 +++ .../intrinsics/functions/to_ftrace.cc | 15 +++++++++++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/trace_processor/importers/ftrace/ftrace_descriptors.cc b/src/trace_processor/importers/ftrace/ftrace_descriptors.cc index 27df202e28..9d7599a2b2 100644 --- a/src/trace_processor/importers/ftrace/ftrace_descriptors.cc +++ b/src/trace_processor/importers/ftrace/ftrace_descriptors.cc @@ -24,7 +24,7 @@ namespace perfetto { namespace trace_processor { namespace { -std::array descriptors{{ +std::array descriptors{{ {nullptr, 0, {}}, {nullptr, 0, {}}, {nullptr, 0, {}}, @@ -5323,6 +5323,18 @@ std::array descriptors{{ {"info_val", ProtoSchemaType::kUint64}, }, }, + { + "samsung_tracing_mark_write", + 5, + { + {}, + {"pid", ProtoSchemaType::kInt32}, + {"trace_name", ProtoSchemaType::kString}, + {"trace_begin", ProtoSchemaType::kUint32}, + {"trace_type", ProtoSchemaType::kUint32}, + {"value", ProtoSchemaType::kInt32}, + }, + }, }}; } // namespace diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.cc b/src/trace_processor/importers/ftrace/ftrace_parser.cc index 2f0be1fad0..7b6679e0b8 100644 --- a/src/trace_processor/importers/ftrace/ftrace_parser.cc +++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc @@ -66,6 +66,7 @@ #include "protos/perfetto/trace/ftrace/oom.pbzero.h" #include "protos/perfetto/trace/ftrace/power.pbzero.h" #include "protos/perfetto/trace/ftrace/raw_syscalls.pbzero.h" +#include "protos/perfetto/trace/ftrace/samsung.pbzero.h" #include "protos/perfetto/trace/ftrace/sched.pbzero.h" #include "protos/perfetto/trace/ftrace/scm.pbzero.h" #include "protos/perfetto/trace/ftrace/sde.pbzero.h" @@ -799,6 +800,10 @@ util::Status FtraceParser::ParseFtraceEvent(uint32_t cpu, ParseG2dTracingMarkWrite(ts, pid, fld_bytes); break; } + case FtraceEvent::kSamsungTracingMarkWriteFieldNumber: { + ParseSamsungTracingMarkWrite(ts, pid, fld_bytes); + break; + } case FtraceEvent::kDpuTracingMarkWriteFieldNumber: { ParseDpuTracingMarkWrite(ts, pid, fld_bytes); break; @@ -1375,6 +1380,22 @@ void FtraceParser::ParseSdeTracingMarkWrite(int64_t timestamp, evt.trace_name(), tgid, evt.value()); } +void FtraceParser::ParseSamsungTracingMarkWrite(int64_t timestamp, + uint32_t pid, + ConstBytes blob) { + protos::pbzero::SamsungTracingMarkWriteFtraceEvent::Decoder evt(blob.data, + blob.size); + if (!evt.has_trace_type()) { + context_->storage->IncrementStats(stats::systrace_parse_failure); + return; + } + + uint32_t tgid = static_cast(evt.pid()); + SystraceParser::GetOrCreate(context_)->ParseKernelTracingMarkWrite( + timestamp, pid, static_cast(evt.trace_type()), + false /*trace_begin*/, evt.trace_name(), tgid, evt.value()); +} + void FtraceParser::ParseDpuTracingMarkWrite(int64_t timestamp, uint32_t pid, ConstBytes blob) { diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.h b/src/trace_processor/importers/ftrace/ftrace_parser.h index 4125c4736c..f65f3b888f 100644 --- a/src/trace_processor/importers/ftrace/ftrace_parser.h +++ b/src/trace_processor/importers/ftrace/ftrace_parser.h @@ -84,6 +84,9 @@ class FtraceParser { void ParseG2dTracingMarkWrite(int64_t timestamp, uint32_t pid, protozero::ConstBytes); + void ParseSamsungTracingMarkWrite(int64_t timestamp, + uint32_t pid, + protozero::ConstBytes); void ParseMaliTracingMarkWrite(int64_t timestamp, uint32_t pid, protozero::ConstBytes); diff --git a/src/trace_processor/perfetto_sql/intrinsics/functions/to_ftrace.cc b/src/trace_processor/perfetto_sql/intrinsics/functions/to_ftrace.cc index 0b9a7f21bf..25dd5e63ac 100644 --- a/src/trace_processor/perfetto_sql/intrinsics/functions/to_ftrace.cc +++ b/src/trace_processor/perfetto_sql/intrinsics/functions/to_ftrace.cc @@ -39,6 +39,7 @@ #include "protos/perfetto/trace/ftrace/irq.pbzero.h" #include "protos/perfetto/trace/ftrace/mdss.pbzero.h" #include "protos/perfetto/trace/ftrace/power.pbzero.h" +#include "protos/perfetto/trace/ftrace/samsung.pbzero.h" #include "protos/perfetto/trace/ftrace/sched.pbzero.h" #include "protos/perfetto/trace/ftrace/workqueue.pbzero.h" @@ -471,6 +472,20 @@ void ArgsSerializer::SerializeArgs() { writer_->AppendString("|"); WriteValueForField(TMW::kValueFieldNumber, DVW()); return; + } else if (event_name_ == "samsung_tracing_mark_write") { + using TMW = protos::pbzero::SamsungTracingMarkWriteFtraceEvent; + WriteValueForField( + TMW::kTraceTypeFieldNumber, [this](const Variadic& value) { + PERFETTO_DCHECK(value.type == Variadic::Type::kUint); + writer_->AppendChar(static_cast(value.uint_value)); + }); + writer_->AppendString("|"); + WriteValueForField(TMW::kPidFieldNumber, DVW()); + writer_->AppendString("|"); + WriteValueForField(TMW::kTraceNameFieldNumber, DVW()); + writer_->AppendString("|"); + WriteValueForField(TMW::kValueFieldNumber, DVW()); + return; } else if (event_name_ == "cgroup_attach_task") { using CAT = protos::pbzero::CgroupAttachTaskFtraceEvent; WriteArgForField(CAT::kDstRootFieldNumber, DVW());