From f647ebbb5b0a0376b6a5b928ff4b4210e5f75e4c Mon Sep 17 00:00:00 2001 From: Lalit Maganti Date: Mon, 21 Oct 2024 05:19:57 -0700 Subject: [PATCH 1/4] tp: remove dependency of devfreq parsing on name Since this was just added, it's very unlikely anyone will query it, just remove it and replace with classification/dimension filtering. Change-Id: Ibe62245163fd6770893b88c209a81dbbefa917b7 --- .../common/async_track_set_tracker.cc | 1 - .../importers/ftrace/ftrace_parser.cc | 41 ++++++++++--------- .../perfetto_sql/stdlib/linux/devfreq.sql | 9 ++-- .../diff_tests/stdlib/wattson/tests.py | 2 +- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/src/trace_processor/importers/common/async_track_set_tracker.cc b/src/trace_processor/importers/common/async_track_set_tracker.cc index 2da4d85d75..0f77db6d52 100644 --- a/src/trace_processor/importers/common/async_track_set_tracker.cc +++ b/src/trace_processor/importers/common/async_track_set_tracker.cc @@ -187,7 +187,6 @@ TrackId AsyncTrackSetTracker::CreateTrackForSet(const TrackSet& set) { TrackTracker::DimensionsBuilder builder = context_->track_tracker->CreateDimensionsBuilder(); builder.AppendName(set.global_track_name); - return context_->track_tracker->CreateTrack(TrackClassification::kAsync, std::move(builder).Build(), set.global_track_name); diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.cc b/src/trace_processor/importers/ftrace/ftrace_parser.cc index 642cf37634..9ca2037697 100644 --- a/src/trace_processor/importers/ftrace/ftrace_parser.cc +++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc @@ -3761,28 +3761,29 @@ StringId FtraceParser::InternedKernelSymbolOrFallback( void FtraceParser::ParseDeviceFrequency(int64_t ts, protozero::ConstBytes blob) { protos::pbzero::DevfreqFrequencyFtraceEvent::Decoder event(blob); - constexpr char delimiter[] = "devfreq_"; std::string dev_name = event.dev_name().ToStdString(); - auto position = dev_name.find(delimiter); - - if (position != std::string::npos) { - // Get device name by getting substring after delimiter and keep existing - // naming convention (e.g. cpufreq, gpufreq) consistent by adding a suffix - // to the devfreq name (e.g. dsufreq, bcifreq) - StringId device_name = context_->storage->InternString( - (dev_name.substr(position + sizeof(delimiter) - 1) + "freq").c_str()); - - TrackTracker::DimensionsBuilder dims_builder = - context_->track_tracker->CreateDimensionsBuilder(); - dims_builder.AppendDimension(device_name_id_, - Variadic::String(device_name)); - TrackTracker::Dimensions dims_id = std::move(dims_builder).Build(); - - TrackId track_id = context_->track_tracker->InternCounterTrack( - TrackClassification::kLinuxDeviceFrequency, dims_id, device_name); - context_->event_tracker->PushCounter(ts, static_cast(event.freq()), - track_id); + + constexpr char kDelimiter[] = "devfreq_"; + auto position = dev_name.find(kDelimiter); + if (position == std::string::npos) { + return; } + + // Get device name by getting substring after delimiter and keep existing + // naming convention (e.g. cpufreq, gpufreq) consistent by adding a suffix + // to the devfreq name (e.g. dsufreq, bcifreq) + StringId device_name = context_->storage->InternString( + (dev_name.substr(position + sizeof(kDelimiter) - 1) + "freq").c_str()); + + TrackTracker::DimensionsBuilder dims_builder = + context_->track_tracker->CreateDimensionsBuilder(); + dims_builder.AppendDimension(device_name_id_, Variadic::String(device_name)); + TrackTracker::Dimensions dims_id = std::move(dims_builder).Build(); + + TrackId track_id = context_->track_tracker->InternCounterTrack( + TrackClassification::kLinuxDeviceFrequency, dims_id); + context_->event_tracker->PushCounter(ts, static_cast(event.freq()), + track_id); } } // namespace perfetto::trace_processor diff --git a/src/trace_processor/perfetto_sql/stdlib/linux/devfreq.sql b/src/trace_processor/perfetto_sql/stdlib/linux/devfreq.sql index a8e1e3c780..7b20cb22a3 100644 --- a/src/trace_processor/perfetto_sql/stdlib/linux/devfreq.sql +++ b/src/trace_processor/perfetto_sql/stdlib/linux/devfreq.sql @@ -17,7 +17,7 @@ INCLUDE PERFETTO MODULE counters.intervals; -- Gets devfreq frequency counter based on device queried. These counters will -- only be available if the "devfreq/devfreq_frequency" ftrace event is enabled. -CREATE PERFETTO FUNCTION linux_get_devfreq_counters( +CREATE PERFETTO FUNCTION _get_devfreq_counters( -- Devfreq name to query for. device_name STRING ) @@ -39,7 +39,9 @@ SELECT FROM counter_leading_intervals!(( SELECT c.* FROM counter c - JOIN counter_track ct ON ct.id = c.track_id AND ct.name = $device_name + JOIN counter_track ct ON ct.id = c.track_id + WHERE ct.classification = 'linux_device_frequency' + AND EXTRACT_ARG(ct.dimension_arg_set_id, 'device_name') = $device_name )) AS count_w_dur JOIN counter_track AS ct ON track_id = ct.id; @@ -58,5 +60,4 @@ CREATE PERFETTO TABLE linux_devfreq_dsu_counter( ) AS SELECT id, ts, dur, freq as dsu_freq -FROM linux_get_devfreq_counters("dsufreq"); - +FROM _get_devfreq_counters("dsufreq"); diff --git a/test/trace_processor/diff_tests/stdlib/wattson/tests.py b/test/trace_processor/diff_tests/stdlib/wattson/tests.py index 663b5aaf21..d00a3059fa 100644 --- a/test/trace_processor/diff_tests/stdlib/wattson/tests.py +++ b/test/trace_processor/diff_tests/stdlib/wattson/tests.py @@ -378,7 +378,7 @@ def test_wattson_dsu_devfreq(self): """)) # Tests that DSU devfreq calculations are merged correctly - def test_wattson_dsu_devfreq(self): + def test_wattson_dsu_devfreq_system_state(self): return DiffTestBlueprint( trace=DataPath('wattson_tk4_pcmark.pb'), query=(""" From c9ee4baf3b14cbb5ac7efda69b46e0b444561d35 Mon Sep 17 00:00:00 2001 From: Lalit Maganti Date: Mon, 21 Oct 2024 05:20:09 -0700 Subject: [PATCH 2/4] tp: improve track name specification and migrate global tracks to it Instead of putting names inside the TrackTracker class which makes it very hard to make sure classifications are in sync with names, instead have a variant which can be passed in. Still have a central place where we verify that only allowed tracks can be passed in. Change-Id: Iddabcfa00c3f96247bcaa09ba12f3e5240b4c5a0 --- src/trace_processor/export_json_unittest.cc | 7 +- .../common/async_track_set_tracker.cc | 15 +- .../importers/common/track_classification.h | 3 - .../importers/common/track_tracker.cc | 152 +++++++++++------- .../importers/common/track_tracker.h | 96 ++++++++--- .../importers/ftrace/ftrace_parser.cc | 11 +- .../ftrace/gpu_work_period_tracker.cc | 2 +- .../importers/json/json_trace_parser_impl.cc | 8 +- .../importers/proto/android_probes_parser.cc | 6 +- .../proto/memory_tracker_snapshot_parser.cc | 8 +- .../importers/proto/metadata_module.cc | 5 +- .../importers/proto/metadata_module.h | 5 +- .../importers/proto/system_probes_parser.cc | 5 +- .../importers/proto/track_event_parser.cc | 9 +- .../importers/proto/track_event_tracker.cc | 26 +-- 15 files changed, 240 insertions(+), 118 deletions(-) diff --git a/src/trace_processor/export_json_unittest.cc b/src/trace_processor/export_json_unittest.cc index f4567cc04f..818c360831 100644 --- a/src/trace_processor/export_json_unittest.cc +++ b/src/trace_processor/export_json_unittest.cc @@ -770,7 +770,12 @@ TEST_F(ExportJsonTest, InstantEvent) { // Global legacy track. TrackId track = context_.track_tracker->InternGlobalTrack( - TrackClassification::kChromeLegacyGlobalInstant); + TrackClassification::kChromeLegacyGlobalInstant, TrackTracker::AutoName(), + [this](ArgsTracker::BoundInserter& inserter) { + inserter.AddArg( + context_.storage->InternString("source"), + Variadic::String(context_.storage->InternString("chrome"))); + }); context_.args_tracker->Flush(); // Flush track args. StringId cat_id = context_.storage->InternString(base::StringView(kCategory)); StringId name_id = context_.storage->InternString(base::StringView(kName)); diff --git a/src/trace_processor/importers/common/async_track_set_tracker.cc b/src/trace_processor/importers/common/async_track_set_tracker.cc index 0f77db6d52..513d092c2c 100644 --- a/src/trace_processor/importers/common/async_track_set_tracker.cc +++ b/src/trace_processor/importers/common/async_track_set_tracker.cc @@ -21,8 +21,7 @@ #include "src/trace_processor/storage/trace_storage.h" #include "src/trace_processor/types/trace_processor_context.h" -namespace perfetto { -namespace trace_processor { +namespace perfetto::trace_processor { AsyncTrackSetTracker::AsyncTrackSetTracker(TraceProcessorContext* context) : android_source_(context->storage->InternString("android")), @@ -187,9 +186,9 @@ TrackId AsyncTrackSetTracker::CreateTrackForSet(const TrackSet& set) { TrackTracker::DimensionsBuilder builder = context_->track_tracker->CreateDimensionsBuilder(); builder.AppendName(set.global_track_name); - return context_->track_tracker->CreateTrack(TrackClassification::kAsync, - std::move(builder).Build(), - set.global_track_name); + return context_->track_tracker->CreateTrack( + TrackClassification::kUnknown, std::move(builder).Build(), + TrackTracker::LegacyStringIdName{set.global_track_name}); } case TrackSetScope::kProcess: // TODO(lalitm): propogate source from callers rather than just passing @@ -209,7 +208,8 @@ TrackId AsyncTrackSetTracker::CreateTrackForSet(const TrackSet& set) { TrackTracker::Dimensions dims_id = std::move(dims_builder).Build(); TrackId id = context_->track_tracker->CreateProcessTrack( - TrackClassification::kAsync, set.process_tuple.upid, dims_id, name); + TrackClassification::kUnknown, set.process_tuple.upid, dims_id, + TrackTracker::LegacyStringIdName{name}); if (!source.is_null()) { context_->args_tracker->AddArgsTo(id).AddArg(source, @@ -221,5 +221,4 @@ TrackId AsyncTrackSetTracker::CreateTrackForSet(const TrackSet& set) { PERFETTO_FATAL("For GCC"); } -} // namespace trace_processor -} // namespace perfetto +} // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/track_classification.h b/src/trace_processor/importers/common/track_classification.h index 45be263087..d101934706 100644 --- a/src/trace_processor/importers/common/track_classification.h +++ b/src/trace_processor/importers/common/track_classification.h @@ -38,7 +38,6 @@ enum class TrackClassification : size_t { // General tracks. kThread, kChromeProcessInstant, - kAsync, kTrackEvent, // Gpu tracks. @@ -118,8 +117,6 @@ static inline const char* TrackClassificationToString( return "linux_rpm"; case TrackClassification::kLinuxDeviceFrequency: return "linux_device_frequency"; - case TrackClassification::kAsync: - return "async"; case TrackClassification::kTrackEvent: return "track_event"; case TrackClassification::kIrqCounter: diff --git a/src/trace_processor/importers/common/track_tracker.cc b/src/trace_processor/importers/common/track_tracker.cc index 1f912106d5..deb30e7b2d 100644 --- a/src/trace_processor/importers/common/track_tracker.cc +++ b/src/trace_processor/importers/common/track_tracker.cc @@ -22,6 +22,7 @@ #include #include +#include "perfetto/base/compiler.h" #include "perfetto/base/logging.h" #include "perfetto/ext/base/string_utils.h" #include "perfetto/ext/base/string_view.h" @@ -127,6 +128,22 @@ inline std::optional GetCpuCounterTrackName( return std::nullopt; } +bool IsLegacyStringIdNameAllowed(TrackClassification classification) { + // **DO NOT** add new values here. Use TrackTracker::AutoName instead. + return classification == + TrackClassification::kAndroidEnergyEstimationBreakdown || + classification == + TrackClassification::kAndroidEnergyEstimationBreakdownPerUid || + classification == TrackClassification::kUnknown; +} + +bool IsLegacyCharArrayNameAllowed(TrackClassification classification) { + // **DO NOT** add new values here. Use TrackTracker::AutoName instead. + return classification == TrackClassification::kTrigger || + classification == TrackClassification::kInterconnect || + classification == TrackClassification::kLinuxRuntimePowerManagement; +} + } // namespace TrackTracker::TrackTracker(TraceProcessorContext* context) @@ -150,30 +167,29 @@ TrackTracker::TrackTracker(TraceProcessorContext* context) TrackId TrackTracker::CreateTrack(TrackClassification classification, std::optional dimensions, - StringId name) { - tables::TrackTable::Row row; + const TrackName& name) { + tables::TrackTable::Row row(StringIdFromTrackName(classification, name)); row.classification = context_->storage->InternString( TrackClassificationToString(classification)); if (dimensions) { row.dimension_arg_set_id = dimensions->arg_set_id; } row.machine_id = context_->machine_id(); - row.name = name; return context_->storage->mutable_track_table()->Insert(row).id; } TrackId TrackTracker::CreateCounterTrack(TrackClassification classification, std::optional dimensions, - StringId name) { - tables::CounterTrackTable::Row row; + const TrackName& name) { + tables::CounterTrackTable::Row row( + StringIdFromTrackName(classification, name)); row.classification = context_->storage->InternString( TrackClassificationToString(classification)); if (dimensions) { row.dimension_arg_set_id = dimensions->arg_set_id; } row.machine_id = context_->machine_id(); - row.name = name; return context_->storage->mutable_counter_track_table()->Insert(row).id; } @@ -181,11 +197,12 @@ TrackId TrackTracker::CreateCounterTrack(TrackClassification classification, TrackId TrackTracker::CreateProcessTrack(TrackClassification classification, UniquePid upid, std::optional dims, - StringId name) { + const TrackName& name) { Dimensions dims_id = dims ? *dims : SingleDimension(upid_id_, Variadic::Integer(upid)); - tables::ProcessTrackTable::Row row(name); + tables::ProcessTrackTable::Row row( + StringIdFromTrackName(classification, name)); row.upid = upid; row.dimension_arg_set_id = dims_id.arg_set_id; row.classification = context_->storage->InternString( @@ -198,11 +215,13 @@ TrackId TrackTracker::CreateProcessTrack(TrackClassification classification, TrackId TrackTracker::CreateProcessCounterTrack( TrackClassification classification, UniquePid upid, - std::optional dims) { + std::optional dims, + const TrackName& name) { Dimensions dims_id = dims ? *dims : SingleDimension(upid_id_, Variadic::Integer(upid)); - tables::ProcessCounterTrackTable::Row row; + tables::ProcessCounterTrackTable::Row row( + StringIdFromTrackName(classification, name)); row.upid = upid; row.machine_id = context_->machine_id(); row.dimension_arg_set_id = dims_id.arg_set_id; @@ -215,10 +234,12 @@ TrackId TrackTracker::CreateProcessCounterTrack( } TrackId TrackTracker::CreateThreadTrack(TrackClassification classification, - UniqueTid utid) { + UniqueTid utid, + const TrackName& name) { Dimensions dims_id = SingleDimension(utid_id_, Variadic::Integer(utid)); - tables::ThreadTrackTable::Row row; + tables::ThreadTrackTable::Row row( + StringIdFromTrackName(classification, name)); row.utid = utid; row.classification = context_->storage->InternString( TrackClassificationToString(classification)); @@ -230,11 +251,12 @@ TrackId TrackTracker::CreateThreadTrack(TrackClassification classification, TrackId TrackTracker::CreateThreadCounterTrack( TrackClassification classification, - StringId name, - UniqueTid utid) { + UniqueTid utid, + const TrackName& name) { Dimensions dims_id = SingleDimension(utid_id_, Variadic::Integer(utid)); - tables::ThreadCounterTrackTable::Row row(name); + tables::ThreadCounterTrackTable::Row row( + StringIdFromTrackName(classification, name)); row.utid = utid; row.machine_id = context_->machine_id(); row.dimension_arg_set_id = dims_id.arg_set_id; @@ -248,7 +270,7 @@ TrackId TrackTracker::CreateThreadCounterTrack( TrackId TrackTracker::InternTrack(TrackClassification classification, std::optional dimensions, - StringId name, + const TrackName& name, const SetArgsCallback& callback) { auto* it = tracks_.Find({classification, dimensions}); if (it) @@ -265,7 +287,7 @@ TrackId TrackTracker::InternTrack(TrackClassification classification, TrackId TrackTracker::InternCounterTrack(TrackClassification classification, std::optional dimensions, - StringId name) { + const TrackName& name) { auto* it = tracks_.Find({classification, dimensions}); if (it) return *it; @@ -277,7 +299,7 @@ TrackId TrackTracker::InternCounterTrack(TrackClassification classification, TrackId TrackTracker::InternProcessTrack(TrackClassification classification, UniquePid upid, - StringId name) { + const TrackName& name) { Dimensions dims_id = SingleDimension(upid_id_, Variadic::Integer(upid)); auto* it = tracks_.Find({classification, dims_id}); @@ -325,13 +347,14 @@ TrackId TrackTracker::LegacyInternProcessCounterTrack(StringId raw_name, return track_id; } -TrackId TrackTracker::InternThreadTrack(UniqueTid utid) { +TrackId TrackTracker::InternThreadTrack(UniqueTid utid, const TrackName& name) { Dimensions dims = SingleDimension(utid_id_, Variadic::Integer(utid)); auto* it = tracks_.Find({TrackClassification::kThread, dims}); if (it) return *it; - TrackId track_id = CreateThreadTrack(TrackClassification::kThread, utid); + TrackId track_id = + CreateThreadTrack(TrackClassification::kThread, utid, name); tracks_[{TrackClassification::kThread, dims}] = track_id; return track_id; } @@ -351,57 +374,44 @@ TrackId TrackTracker::LegacyInternThreadCounterTrack(StringId name, return *it; } - TrackId track_id = - CreateThreadCounterTrack(TrackClassification::kUnknown, name, utid); + TrackId track_id = CreateThreadCounterTrack(TrackClassification::kUnknown, + utid, LegacyStringIdName{name}); tracks_[key] = track_id; return track_id; } -TrackId TrackTracker::InternCpuTrack(TrackClassification type, uint32_t cpu) { +TrackId TrackTracker::InternCpuTrack(TrackClassification classification, + uint32_t cpu, + const TrackName& name) { auto ucpu = context_->cpu_tracker->GetOrCreateCpu(cpu); Dimensions dims_id = SingleDimension(ucpu_id_, Variadic::Integer(ucpu.value)); - auto* it = tracks_.Find({type, dims_id}); + auto* it = tracks_.Find({classification, dims_id}); if (it) { return *it; } - tables::CpuTrackTable::Row row; + tables::CpuTrackTable::Row row(StringIdFromTrackName(classification, name)); row.ucpu = ucpu; row.machine_id = context_->machine_id(); - row.classification = - context_->storage->InternString(TrackClassificationToString(type)); + row.classification = context_->storage->InternString( + TrackClassificationToString(classification)); row.dimension_arg_set_id = dims_id.arg_set_id; - if (std::optional track_name = GetCpuTrackName(type, cpu)) { + if (std::optional track_name = + GetCpuTrackName(classification, cpu)) { row.name = context_->storage->InternString(track_name.value().c_str()); } TrackId track_id = context_->storage->mutable_cpu_track_table()->Insert(row).id; - tracks_[{type, dims_id}] = track_id; + tracks_[{classification, dims_id}] = track_id; return track_id; } -TrackId TrackTracker::InternGlobalTrack(TrackClassification type) { - auto* it = tracks_.Find({type, std::nullopt}); - if (it) - return *it; - - StringId name = kNullStringId; - if (type == TrackClassification::kTrigger) - name = context_->storage->InternString("Trace Triggers"); - if (type == TrackClassification::kInterconnect) - name = context_->storage->InternString("Interconnect Events"); - - TrackId track_id = InternTrack(type, std::nullopt, name); - tracks_[{type, std::nullopt}] = track_id; - - if (type == TrackClassification::kChromeLegacyGlobalInstant) { - context_->args_tracker->AddArgsTo(track_id).AddArg( - source_key_, Variadic::String(chrome_source_)); - } - - return track_id; +TrackId TrackTracker::InternGlobalTrack(TrackClassification classification, + const TrackName& name, + const SetArgsCallback& callback) { + return InternTrack(classification, std::nullopt, name, callback); } TrackId TrackTracker::LegacyInternGpuTrack( @@ -469,7 +479,8 @@ TrackId TrackTracker::LegacyInternGlobalCounterTrack(TrackTracker::Group group, } TrackId TrackTracker::InternCpuCounterTrack(TrackClassification type, - uint32_t cpu) { + uint32_t cpu, + const TrackName&) { auto ucpu = context_->cpu_tracker->GetOrCreateCpu(cpu); TrackMapKey key; @@ -538,28 +549,30 @@ TrackId TrackTracker::LegacyInternCpuIdleStateTrack(uint32_t cpu, return track_id; } -TrackId TrackTracker::InternGpuCounterTrack(TrackClassification type, - uint32_t gpu_id) { +TrackId TrackTracker::InternGpuCounterTrack(TrackClassification classification, + uint32_t gpu_id, + const TrackName& name) { Dimensions dims_id = SingleDimension(gpu_id_, Variadic::Integer(gpu_id)); - auto* it = tracks_.Find({type, dims_id}); + auto* it = tracks_.Find({classification, dims_id}); if (it) { return *it; } - tables::GpuCounterTrackTable::Row row; + tables::GpuCounterTrackTable::Row row( + StringIdFromTrackName(classification, name)); row.gpu_id = gpu_id; row.machine_id = context_->machine_id(); row.dimension_arg_set_id = dims_id.arg_set_id; - row.classification = - context_->storage->InternString(TrackClassificationToString(type)); - if (type == TrackClassification::kGpuFrequency) + row.classification = context_->storage->InternString( + TrackClassificationToString(classification)); + if (classification == TrackClassification::kGpuFrequency) row.name = context_->storage->InternString("gpufreq"); TrackId track_id = context_->storage->mutable_gpu_counter_track_table()->Insert(row).id; - tracks_[{type, dims_id}] = track_id; + tracks_[{classification, dims_id}] = track_id; return track_id; } @@ -612,8 +625,8 @@ TrackId TrackTracker::InternTrackForGroup(TrackTracker::Group group) { } StringId name_id = context_->storage->InternString(GetNameForGroup(group)); - TrackId track_id = - InternTrack(TrackClassification::kUnknown, std::nullopt, name_id); + TrackId track_id = InternTrack(TrackClassification::kUnknown, std::nullopt, + LegacyStringIdName{name_id}); group_track_ids_[group_idx] = track_id; return track_id; } @@ -675,4 +688,23 @@ TrackId TrackTracker::LegacyInternLegacyChromeAsyncTrack( return id; } +StringId TrackTracker::StringIdFromTrackName( + TrackClassification classification, + const TrackTracker::TrackName& name) { + switch (name.index()) { + case base::variant_index(): + return kNullStringId; + case base::variant_index(): + PERFETTO_DCHECK(IsLegacyStringIdNameAllowed(classification)); + return std::get(name).id; + case base::variant_index(): + PERFETTO_DCHECK(IsLegacyCharArrayNameAllowed(classification)); + return context_->storage->InternString( + std::get(name).name); + case base::variant_index(): + return std::get(name).id; + } + PERFETTO_FATAL("For GCC"); +} + } // namespace perfetto::trace_processor diff --git a/src/trace_processor/importers/common/track_tracker.h b/src/trace_processor/importers/common/track_tracker.h index ffb53041c9..3f3571f7f0 100644 --- a/src/trace_processor/importers/common/track_tracker.h +++ b/src/trace_processor/importers/common/track_tracker.h @@ -24,11 +24,12 @@ #include #include #include +#include #include "perfetto/ext/base/flat_hash_map.h" #include "perfetto/ext/base/hash.h" +#include "perfetto/ext/base/string_utils.h" #include "src/trace_processor/importers/common/args_tracker.h" -#include "src/trace_processor/importers/common/cpu_tracker.h" #include "src/trace_processor/importers/common/global_args_tracker.h" #include "src/trace_processor/importers/common/track_classification.h" #include "src/trace_processor/storage/trace_storage.h" @@ -134,6 +135,47 @@ class TrackTracker { kSizeSentinel, }; + // Indicates that the track name will be automatically generated by the trace + // processor. + // All tracks *MUST* use this option unless it is explicitly approved by a + // trace processor maintainer. + struct AutoName {}; + // Indicates that the track name comes from the trace directly with no + // modification. + // *MUST NOT* be used without explicit appoval from a trace processor + // maintainer. + struct FromTraceName { + StringId id; + }; + // Indicates that the track name is synthesied in trace processor as a + // StringId and works this way due to legacy reasons. + // + // Tracks *MUST NOT* use this method: this only exists for legacy tracks which + // we named before the introduction of classification/dimension system. + struct LegacyStringIdName { + StringId id; + }; + // Indicates that the track name is synthesied in trace processor as a + // StackString and works this way due to legacy reasons. + // + // Tracks *MUST NOT* use this method: this only exists for legacy tracks which + // we named before the introduction of classification/dimension system. + struct LegacyCharArrayName { + template + explicit LegacyCharArrayName(const char (&_name)[N]) { + static_assert(N > 0 && N <= 512); + base::StringCopy(name, _name, N); + } + template + explicit LegacyCharArrayName(const base::StackString& _name) { + static_assert(N > 0 && N <= 512); + base::StringCopy(name, _name.c_str(), N); + } + char name[512]; + }; + using TrackName = std:: + variant; + explicit TrackTracker(TraceProcessorContext*); DimensionsBuilder CreateDimensionsBuilder() { @@ -142,21 +184,21 @@ class TrackTracker { // Interns track into TrackTable. If the track created with below arguments // already exists, returns the TrackTable::Id of the track. + // + // `name` is the display name of the track in trace processor and should + // always be `AutoName()` unless approved by a trace processor maintainer. TrackId InternTrack(TrackClassification, std::optional, - StringId name = kNullStringId, + const TrackName& name = AutoName(), const SetArgsCallback& callback = {}); // Interns a track with the given classification and one dimension into the // `track` table. This is useful when interning global tracks which have a // single uncommon dimension attached to them. - // - // Note: name is *not* used relevant for interning: it's used purely as a - // display name. TrackId InternSingleDimensionTrack(TrackClassification classification, StringId key, const Variadic& value, - StringId name = kNullStringId, + const TrackName& name = AutoName(), const SetArgsCallback& callback = {}) { return InternTrack(classification, SingleDimension(key, value), name, callback); @@ -166,27 +208,35 @@ class TrackTracker { // arguments already exists, returns the TrackTable::Id of the track. TrackId InternCounterTrack(TrackClassification, std::optional, - StringId name = kNullStringId); + const TrackName& = AutoName()); // Interns a unique track into the storage. - TrackId InternGlobalTrack(TrackClassification); + TrackId InternGlobalTrack(TrackClassification, + const TrackName& = AutoName(), + const SetArgsCallback& callback = {}); // Interns a thread track into the storage. - TrackId InternThreadTrack(UniqueTid); + TrackId InternThreadTrack(UniqueTid, const TrackName& = AutoName()); // Interns a process track into the storage. TrackId InternProcessTrack(TrackClassification, UniquePid, - StringId name = kNullStringId); + const TrackName& = AutoName()); // Interns a global track keyed by track type + CPU into the storage. - TrackId InternCpuTrack(TrackClassification, uint32_t cpu); + TrackId InternCpuTrack(TrackClassification, + uint32_t cpu, + const TrackName& = AutoName()); // Interns a counter track associated with a cpu into the storage. - TrackId InternCpuCounterTrack(TrackClassification, uint32_t cpu); + TrackId InternCpuCounterTrack(TrackClassification, + uint32_t cpu, + const TrackName& = AutoName()); // Interns a counter track associated with a GPU into the storage. - TrackId InternGpuCounterTrack(TrackClassification, uint32_t gpu_id); + TrackId InternGpuCounterTrack(TrackClassification, + uint32_t gpu_id, + const TrackName& = AutoName()); // Everything below this point are legacy functions and should no longer be // used. @@ -252,29 +302,33 @@ class TrackTracker { TrackId CreateTrack(TrackClassification, std::optional, - StringId name); + const TrackName&); TrackId CreateCounterTrack(TrackClassification, std::optional, - StringId name); + const TrackName&); - TrackId CreateThreadTrack(TrackClassification, UniqueTid); + TrackId CreateThreadTrack(TrackClassification, UniqueTid, const TrackName&); TrackId CreateThreadCounterTrack(TrackClassification, - StringId name, - UniqueTid); + UniqueTid, + const TrackName&); TrackId CreateProcessTrack(TrackClassification, UniquePid, - std::optional = std::nullopt, - StringId name = kNullStringId); + std::optional, + const TrackName&); TrackId CreateProcessCounterTrack(TrackClassification, UniquePid, - std::optional = std::nullopt); + std::optional, + const TrackName&); TrackId InternTrackForGroup(Group); + StringId StringIdFromTrackName(TrackClassification classification, + const TrackTracker::TrackName& name); + Dimensions SingleDimension(StringId key, const Variadic& val) { std::array args{GlobalArgsTracker::CompactArg{key, key, val}}; return Dimensions{ diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.cc b/src/trace_processor/importers/ftrace/ftrace_parser.cc index 9ca2037697..b93cb5f6fd 100644 --- a/src/trace_processor/importers/ftrace/ftrace_parser.cc +++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc @@ -127,6 +127,8 @@ using protos::pbzero::perfetto_pbzero_enum_KprobeEvent::KprobeType; using protozero::ConstBytes; using protozero::ProtoDecoder; +constexpr char kInternconnectTrackName[] = "Interconnect Events"; + struct FtraceEventAndFieldId { uint32_t event_id; uint32_t field_id; @@ -1871,7 +1873,8 @@ void FtraceParser::ParseLwisTracingMarkWrite(int64_t timestamp, void FtraceParser::ParseGoogleIccEvent(int64_t timestamp, ConstBytes blob) { protos::pbzero::GoogleIccEventFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternGlobalTrack( - TrackClassification::kInterconnect); + TrackClassification::kInterconnect, + TrackTracker::LegacyCharArrayName(kInternconnectTrackName)); StringId slice_name_id = context_->storage->InternString(base::StringView(evt.event())); context_->slice_tracker->Scoped(timestamp, track_id, google_icc_event_id_, @@ -1881,7 +1884,8 @@ void FtraceParser::ParseGoogleIccEvent(int64_t timestamp, ConstBytes blob) { void FtraceParser::ParseGoogleIrmEvent(int64_t timestamp, ConstBytes blob) { protos::pbzero::GoogleIrmEventFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternGlobalTrack( - TrackClassification::kInterconnect); + TrackClassification::kInterconnect, + TrackTracker::LegacyCharArrayName{kInternconnectTrackName}); StringId slice_name_id = context_->storage->InternString(base::StringView(evt.event())); context_->slice_tracker->Scoped(timestamp, track_id, google_irm_event_id_, @@ -3629,7 +3633,8 @@ void FtraceParser::ParseRpmStatus(int64_t ts, protozero::ConstBytes blob) { StringId device_name_string_id = context_->storage->InternString(device_name); TrackId track_id = context_->track_tracker->InternSingleDimensionTrack( TrackClassification::kLinuxRuntimePowerManagement, linux_device_name_id_, - Variadic::String(device_name_string_id), device_name_string_id); + Variadic::String(device_name_string_id), + TrackTracker::LegacyStringIdName{device_name_string_id}); // A `runtime_status` event implies a potential change in state. Hence, if an // active slice exists for this device, end that slice. diff --git a/src/trace_processor/importers/ftrace/gpu_work_period_tracker.cc b/src/trace_processor/importers/ftrace/gpu_work_period_tracker.cc index 69159e5656..ac294d3ae0 100644 --- a/src/trace_processor/importers/ftrace/gpu_work_period_tracker.cc +++ b/src/trace_processor/importers/ftrace/gpu_work_period_tracker.cc @@ -45,7 +45,7 @@ void GpuWorkPeriodTracker::ParseGpuWorkPeriodEvent(int64_t timestamp, dims_builder.AppendUid(static_cast(evt.uid())); TrackId track_id = context_->track_tracker->InternTrack( TrackClassification::kAndroidGpuWorkPeriod, - std::move(dims_builder).Build(), kNullStringId); + std::move(dims_builder).Build()); const auto duration = static_cast(evt.end_time_ns() - evt.start_time_ns()); diff --git a/src/trace_processor/importers/json/json_trace_parser_impl.cc b/src/trace_processor/importers/json/json_trace_parser_impl.cc index e32d2b2683..601008b0b2 100644 --- a/src/trace_processor/importers/json/json_trace_parser_impl.cc +++ b/src/trace_processor/importers/json/json_trace_parser_impl.cc @@ -289,7 +289,13 @@ void JsonTraceParserImpl::ParseJsonPacket(int64_t timestamp, TrackId track_id; if (scope == "g") { track_id = context_->track_tracker->InternGlobalTrack( - TrackClassification::kChromeLegacyGlobalInstant); + TrackClassification::kChromeLegacyGlobalInstant, + TrackTracker::AutoName(), + [this](ArgsTracker::BoundInserter& inserter) { + inserter.AddArg( + context_->storage->InternString("source"), + Variadic::String(context_->storage->InternString("chrome"))); + }); } else if (scope == "p") { if (!opt_pid) { context_->storage->IncrementStats(stats::json_parser_failure); diff --git a/src/trace_processor/importers/proto/android_probes_parser.cc b/src/trace_processor/importers/proto/android_probes_parser.cc index 4fb0e90963..4209003032 100644 --- a/src/trace_processor/importers/proto/android_probes_parser.cc +++ b/src/trace_processor/importers/proto/android_probes_parser.cc @@ -214,7 +214,8 @@ void AndroidProbesParser::ParseEnergyBreakdown(int64_t ts, ConstBytes blob) { TrackId energy_track = context_->track_tracker->InternSingleDimensionTrack( TrackClassification::kAndroidEnergyEstimationBreakdown, - energy_consumer_id_, Variadic::Integer(consumer_id), consumer_name, + energy_consumer_id_, Variadic::Integer(consumer_id), + TrackTracker::LegacyStringIdName{consumer_name}, [&](ArgsTracker::BoundInserter& inserter) { inserter.AddArg(consumer_type_id_, Variadic::String(consumer_type)); inserter.AddArg(ordinal_id_, Variadic::Integer(ordinal)); @@ -238,7 +239,8 @@ void AndroidProbesParser::ParseEnergyBreakdown(int64_t ts, ConstBytes blob) { Variadic::Integer(consumer_id)); TrackId energy_uid_track = context_->track_tracker->InternTrack( TrackClassification::kAndroidEnergyEstimationBreakdownPerUid, - std::move(builder).Build(), consumer_name); + std::move(builder).Build(), + TrackTracker::LegacyStringIdName{consumer_name}); context_->event_tracker->PushCounter( ts, static_cast(breakdown.energy_uws()), energy_uid_track); } diff --git a/src/trace_processor/importers/proto/memory_tracker_snapshot_parser.cc b/src/trace_processor/importers/proto/memory_tracker_snapshot_parser.cc index 31badaf9fd..f2e98b9cc8 100644 --- a/src/trace_processor/importers/proto/memory_tracker_snapshot_parser.cc +++ b/src/trace_processor/importers/proto/memory_tracker_snapshot_parser.cc @@ -20,6 +20,7 @@ #include "protos/perfetto/trace/memory_graph.pbzero.h" #include "src/trace_processor/containers/string_pool.h" #include "src/trace_processor/importers/common/args_tracker.h" +#include "src/trace_processor/importers/common/track_tracker.h" #include "src/trace_processor/tables/memory_tables_py.h" namespace perfetto { @@ -170,7 +171,12 @@ void MemoryTrackerSnapshotParser::EmitRows(int64_t ts, // For now, we use the existing global instant event track for chrome events, // since memory dumps are global. TrackId track_id = context_->track_tracker->InternGlobalTrack( - TrackClassification::kChromeLegacyGlobalInstant); + TrackClassification::kChromeLegacyGlobalInstant, TrackTracker::AutoName(), + [this](ArgsTracker::BoundInserter& inserter) { + inserter.AddArg( + context_->storage->InternString("source"), + Variadic::String(context_->storage->InternString("chrome"))); + }); tables::MemorySnapshotTable::Row snapshot_row( ts, track_id, level_of_detail_ids_[static_cast(level_of_detail)]); diff --git a/src/trace_processor/importers/proto/metadata_module.cc b/src/trace_processor/importers/proto/metadata_module.cc index d9a156bd18..f2b1837178 100644 --- a/src/trace_processor/importers/proto/metadata_module.cc +++ b/src/trace_processor/importers/proto/metadata_module.cc @@ -104,8 +104,9 @@ void MetadataModule::ParseTracePacketData( void MetadataModule::ParseTrigger(int64_t ts, ConstBytes blob) { protos::pbzero::Trigger::Decoder trigger(blob.data, blob.size); StringId cat_id = kNullStringId; - TrackId track_id = - context_->track_tracker->InternGlobalTrack(TrackClassification::kTrigger); + TrackId track_id = context_->track_tracker->InternGlobalTrack( + TrackClassification::kTrigger, + TrackTracker::LegacyCharArrayName("Trace Triggers")); StringId name_id = context_->storage->InternString(trigger.trigger_name()); context_->slice_tracker->Scoped( ts, track_id, cat_id, name_id, diff --git a/src/trace_processor/importers/proto/metadata_module.h b/src/trace_processor/importers/proto/metadata_module.h index 0014936730..ca9b97e239 100644 --- a/src/trace_processor/importers/proto/metadata_module.h +++ b/src/trace_processor/importers/proto/metadata_module.h @@ -52,8 +52,9 @@ class MetadataModule : public ProtoImporterModule { void ParseTraceUuid(ConstBytes); TraceProcessorContext* context_; - StringId producer_name_key_id_ = kNullStringId; - StringId trusted_producer_uid_key_id_ = kNullStringId; + + const StringId producer_name_key_id_; + const StringId trusted_producer_uid_key_id_; }; } // namespace trace_processor diff --git a/src/trace_processor/importers/proto/system_probes_parser.cc b/src/trace_processor/importers/proto/system_probes_parser.cc index 191e8fc90d..ca5e1db062 100644 --- a/src/trace_processor/importers/proto/system_probes_parser.cc +++ b/src/trace_processor/importers/proto/system_probes_parser.cc @@ -415,8 +415,7 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { for (auto it = sys_stats.num_irq(); it; ++it) { protos::pbzero::SysStats::InterruptCount::Decoder ic(*it); TrackId track = context_->track_tracker->InternSingleDimensionTrack( - TrackClassification::kIrqCounter, irq_id_, Variadic::Integer(ic.irq()), - kNullStringId); + TrackClassification::kIrqCounter, irq_id_, Variadic::Integer(ic.irq())); context_->event_tracker->PushCounter(ts, static_cast(ic.count()), track); } @@ -425,7 +424,7 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { protos::pbzero::SysStats::InterruptCount::Decoder ic(*it); TrackId track = context_->track_tracker->InternSingleDimensionTrack( TrackClassification::kSoftirqCounter, irq_id_, - Variadic::Integer(ic.irq()), kNullStringId); + Variadic::Integer(ic.irq())); context_->event_tracker->PushCounter(ts, static_cast(ic.count()), track); } diff --git a/src/trace_processor/importers/proto/track_event_parser.cc b/src/trace_processor/importers/proto/track_event_parser.cc index 40e0e19a3b..802854a3f5 100644 --- a/src/trace_processor/importers/proto/track_event_parser.cc +++ b/src/trace_processor/importers/proto/track_event_parser.cc @@ -516,7 +516,14 @@ class TrackEventParser::EventImporter { break; case LegacyEvent::SCOPE_GLOBAL: track_id_ = context_->track_tracker->InternGlobalTrack( - TrackClassification::kChromeLegacyGlobalInstant); + TrackClassification::kChromeLegacyGlobalInstant, + TrackTracker::AutoName(), + [this](ArgsTracker::BoundInserter& inserter) { + inserter.AddArg( + context_->storage->InternString("source"), + Variadic::String( + context_->storage->InternString("chrome"))); + }); legacy_passthrough_utid_ = utid_; utid_ = std::nullopt; break; diff --git a/src/trace_processor/importers/proto/track_event_tracker.cc b/src/trace_processor/importers/proto/track_event_tracker.cc index 88977159ce..70102189ed 100644 --- a/src/trace_processor/importers/proto/track_event_tracker.cc +++ b/src/trace_processor/importers/proto/track_event_tracker.cc @@ -171,9 +171,11 @@ TrackId TrackEventTracker::CreateTrackFromResolved( if (it != thread_tracks_.end()) { return it->second; } - return thread_tracks_[track.utid()] = - context_->track_tracker->CreateThreadTrack( - TrackClassification::kTrackEvent, track.utid()); + TrackId id = context_->track_tracker->CreateThreadTrack( + TrackClassification::kTrackEvent, track.utid(), + TrackTracker::AutoName()); + thread_tracks_[track.utid()] = id; + return id; } return context_->track_tracker->InternThreadTrack(track.utid()); } @@ -190,28 +192,34 @@ TrackId TrackEventTracker::CreateTrackFromResolved( switch (track.scope()) { case ResolvedDescriptorTrack::Scope::kThread: return context_->track_tracker->CreateThreadCounterTrack( - TrackClassification::kTrackEvent, kNullStringId, track.utid()); + TrackClassification::kTrackEvent, track.utid(), + TrackTracker::AutoName()); case ResolvedDescriptorTrack::Scope::kProcess: return context_->track_tracker->CreateProcessCounterTrack( - TrackClassification::kTrackEvent, track.upid()); + TrackClassification::kTrackEvent, track.upid(), std::nullopt, + TrackTracker::AutoName()); case ResolvedDescriptorTrack::Scope::kGlobal: return context_->track_tracker->CreateCounterTrack( - TrackClassification::kTrackEvent, std::nullopt, kNullStringId); + TrackClassification::kTrackEvent, std::nullopt, + TrackTracker::AutoName()); } } switch (track.scope()) { case ResolvedDescriptorTrack::Scope::kThread: { return context_->track_tracker->CreateThreadTrack( - TrackClassification::kTrackEvent, track.utid()); + TrackClassification::kTrackEvent, track.utid(), + TrackTracker::AutoName()); } case ResolvedDescriptorTrack::Scope::kProcess: { return context_->track_tracker->CreateProcessTrack( - TrackClassification::kTrackEvent, track.upid()); + TrackClassification::kTrackEvent, track.upid(), std::nullopt, + TrackTracker::AutoName()); } case ResolvedDescriptorTrack::Scope::kGlobal: { return context_->track_tracker->CreateTrack( - TrackClassification::kTrackEvent, std::nullopt, kNullStringId); + TrackClassification::kTrackEvent, std::nullopt, + TrackTracker::AutoName()); } } PERFETTO_FATAL("For GCC"); From cc724c2f8a749368b2a78390d6a89b0d402d3f40 Mon Sep 17 00:00:00 2001 From: Lalit Maganti Date: Mon, 21 Oct 2024 05:20:21 -0700 Subject: [PATCH 3/4] tp: migrate all cpu tracks to new naming system Change-Id: I09b3454018b9fb4f598e6685b59c12dc7ea5dd85 --- .../importers/common/track_classification.h | 6 ---- .../importers/common/track_tracker.cc | 34 ++++--------------- .../importers/ftrace/ftrace_parser.cc | 32 ++++++++++++----- .../ftrace/mali_gpu_event_tracker.cc | 4 ++- .../importers/ftrace/pkvm_hyp_cpu_tracker.cc | 26 ++++++++------ 5 files changed, 49 insertions(+), 53 deletions(-) diff --git a/src/trace_processor/importers/common/track_classification.h b/src/trace_processor/importers/common/track_classification.h index d101934706..82818f6a69 100644 --- a/src/trace_processor/importers/common/track_classification.h +++ b/src/trace_processor/importers/common/track_classification.h @@ -48,8 +48,6 @@ enum class TrackClassification : size_t { kSoftirqCpu, kNapiGroCpu, kMaliIrqCpu, - kMinFreqCpu, - kMaxFreqCpu, kFuncgraphCpu, kPkvmHypervisor, @@ -141,10 +139,6 @@ static inline const char* TrackClassificationToString( return "cpu_softirq_time"; case TrackClassification::kPkvmHypervisor: return "pkvm_hypervisor"; - case TrackClassification::kMaxFreqCpu: - return "cpu_max_frequency"; - case TrackClassification::kMinFreqCpu: - return "cpu_min_frequency"; case TrackClassification::kCpuFrequency: return "cpu_frequency"; case TrackClassification::kCpuFrequencyThrottle: diff --git a/src/trace_processor/importers/common/track_tracker.cc b/src/trace_processor/importers/common/track_tracker.cc index deb30e7b2d..e756af4148 100644 --- a/src/trace_processor/importers/common/track_tracker.cc +++ b/src/trace_processor/importers/common/track_tracker.cc @@ -65,28 +65,6 @@ const char* GetNameForGroup(TrackTracker::Group group) { PERFETTO_FATAL("For GCC"); } -// This function is added to keep backward compatibility. Don't add new names. -inline std::optional GetCpuTrackName(TrackClassification type, - uint32_t cpu) { - if (type == TrackClassification::kIrqCpu) - return base::StackString<255>("Irq Cpu %u", cpu).ToStdString(); - if (type == TrackClassification::kSoftirqCpu) - return base::StackString<255>("SoftIrq Cpu %u", cpu).ToStdString(); - if (type == TrackClassification::kNapiGroCpu) - return base::StackString<255>("Napi Gro Cpu %u", cpu).ToStdString(); - if (type == TrackClassification::kMaxFreqCpu) - return base::StackString<255>("Cpu %u Max Freq Limit", cpu).ToStdString(); - if (type == TrackClassification::kMinFreqCpu) - return base::StackString<255>("Cpu %u Min Freq Limit", cpu).ToStdString(); - if (type == TrackClassification::kFuncgraphCpu) - return base::StackString<255>("swapper%u -funcgraph", cpu).ToStdString(); - if (type == TrackClassification::kMaliIrqCpu) - return base::StackString<255>("Mali Irq Cpu %u", cpu).ToStdString(); - if (type == TrackClassification::kPkvmHypervisor) - return base::StackString<255>("pkVM Hypervisor CPU %u", cpu).ToStdString(); - return std::nullopt; -} - // This function is added to keep backward compatibility. Don't add new names. inline std::optional GetCpuCounterTrackName( TrackClassification type, @@ -141,7 +119,13 @@ bool IsLegacyCharArrayNameAllowed(TrackClassification classification) { // **DO NOT** add new values here. Use TrackTracker::AutoName instead. return classification == TrackClassification::kTrigger || classification == TrackClassification::kInterconnect || - classification == TrackClassification::kLinuxRuntimePowerManagement; + classification == TrackClassification::kLinuxRuntimePowerManagement || + classification == TrackClassification::kIrqCpu || + classification == TrackClassification::kSoftirqCpu || + classification == TrackClassification::kNapiGroCpu || + classification == TrackClassification::kFuncgraphCpu || + classification == TrackClassification::kMaliIrqCpu || + classification == TrackClassification::kPkvmHypervisor; } } // namespace @@ -397,10 +381,6 @@ TrackId TrackTracker::InternCpuTrack(TrackClassification classification, row.classification = context_->storage->InternString( TrackClassificationToString(classification)); row.dimension_arg_set_id = dims_id.arg_set_id; - if (std::optional track_name = - GetCpuTrackName(classification, cpu)) { - row.name = context_->storage->InternString(track_name.value().c_str()); - } TrackId track_id = context_->storage->mutable_cpu_track_table()->Insert(row).id; diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.cc b/src/trace_processor/importers/ftrace/ftrace_parser.cc index b93cb5f6fd..78cf3acf91 100644 --- a/src/trace_processor/importers/ftrace/ftrace_parser.cc +++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc @@ -2586,7 +2586,9 @@ void FtraceParser::ParseIrqHandlerEntry(uint32_t cpu, StringId slice_name_id = context_->storage->InternString(slice_name.string_view()); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kIrqCpu, cpu); + TrackClassification::kIrqCpu, cpu, + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Irq Cpu %u", cpu)}); context_->slice_tracker->Begin(timestamp, track, irq_id_, slice_name_id); } @@ -2595,7 +2597,9 @@ void FtraceParser::ParseIrqHandlerExit(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::IrqHandlerExitFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kIrqCpu, cpu); + TrackClassification::kIrqCpu, cpu, + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Irq Cpu %u", cpu)}); base::StackString<255> status("%s", evt.ret() == 1 ? "handled" : "unhandled"); StringId status_id = context_->storage->InternString(status.string_view()); @@ -2618,7 +2622,9 @@ void FtraceParser::ParseSoftIrqEntry(uint32_t cpu, base::StringView slice_name = kActionNames[evt.vec()]; StringId slice_name_id = context_->storage->InternString(slice_name); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kSoftirqCpu, cpu); + TrackClassification::kSoftirqCpu, cpu, + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("SoftIrq Cpu %u", cpu)}); context_->slice_tracker->Begin(timestamp, track, irq_id_, slice_name_id); } @@ -2627,7 +2633,9 @@ void FtraceParser::ParseSoftIrqExit(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::SoftirqExitFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kSoftirqCpu, cpu); + TrackClassification::kSoftirqCpu, cpu, + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("SoftIrq Cpu %u", cpu)}); auto vec = evt.vec(); auto args_inserter = [this, vec](ArgsTracker::BoundInserter* inserter) { inserter->AddArg(vec_arg_id_, Variadic::Integer(vec)); @@ -2887,7 +2895,9 @@ void FtraceParser::ParseNapiGroReceiveEntry(uint32_t cpu, base::StringView net_device = evt.name(); StringId slice_name_id = context_->storage->InternString(net_device); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kNapiGroCpu, cpu); + TrackClassification::kNapiGroCpu, cpu, + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Napi Gro Cpu %u", cpu)}); auto len = evt.len(); auto args_inserter = [this, len](ArgsTracker::BoundInserter* inserter) { inserter->AddArg(len_arg_id_, Variadic::Integer(len)); @@ -2902,7 +2912,9 @@ void FtraceParser::ParseNapiGroReceiveExit(uint32_t cpu, protos::pbzero::NapiGroReceiveExitFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track = context_->track_tracker->InternCpuTrack( - TrackClassification::kNapiGroCpu, cpu); + TrackClassification::kNapiGroCpu, cpu, + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Napi Gro Cpu %u", cpu)}); auto ret = evt.ret(); auto args_inserter = [this, ret](ArgsTracker::BoundInserter* inserter) { inserter->AddArg(ret_arg_id_, Variadic::Integer(ret)); @@ -3521,7 +3533,9 @@ void FtraceParser::ParseFuncgraphEntry( // of swapper might be running concurrently. Fall back onto global tracks // (one per cpu). track = context_->track_tracker->InternCpuTrack( - TrackClassification::kFuncgraphCpu, cpu); + TrackClassification::kFuncgraphCpu, cpu, + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("swapper%u -funcgraph", cpu)}); } context_->slice_tracker->Begin(timestamp, track, kNullStringId, name_id); @@ -3544,7 +3558,9 @@ void FtraceParser::ParseFuncgraphExit( } else { // special case: see |ParseFuncgraphEntry| track = context_->track_tracker->InternCpuTrack( - TrackClassification::kFuncgraphCpu, cpu); + TrackClassification::kFuncgraphCpu, cpu, + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("swapper%u -funcgraph", cpu)}); } context_->slice_tracker->End(timestamp, track, kNullStringId, name_id); diff --git a/src/trace_processor/importers/ftrace/mali_gpu_event_tracker.cc b/src/trace_processor/importers/ftrace/mali_gpu_event_tracker.cc index 3c675c9115..cedd4125b8 100644 --- a/src/trace_processor/importers/ftrace/mali_gpu_event_tracker.cc +++ b/src/trace_processor/importers/ftrace/mali_gpu_event_tracker.cc @@ -155,7 +155,9 @@ void MaliGpuEventTracker::ParseMaliGpuIrqEvent(int64_t ts, // associated to a single process or thread. Add to a custom Mali Irq track // instead. TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kMaliIrqCpu, cpu); + TrackClassification::kMaliIrqCpu, cpu, + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Mali Irq Cpu %u", cpu)}); switch (field_id) { case FtraceEvent::kMaliMaliCSFINTERRUPTSTARTFieldNumber: { diff --git a/src/trace_processor/importers/ftrace/pkvm_hyp_cpu_tracker.cc b/src/trace_processor/importers/ftrace/pkvm_hyp_cpu_tracker.cc index 3ae5283930..6718b2f235 100644 --- a/src/trace_processor/importers/ftrace/pkvm_hyp_cpu_tracker.cc +++ b/src/trace_processor/importers/ftrace/pkvm_hyp_cpu_tracker.cc @@ -20,12 +20,18 @@ #include "perfetto/ext/base/string_utils.h" #include "protos/perfetto/trace/ftrace/ftrace_event.pbzero.h" #include "protos/perfetto/trace/ftrace/hyp.pbzero.h" -#include "src/trace_processor/importers/common/event_tracker.h" #include "src/trace_processor/importers/common/slice_tracker.h" #include "src/trace_processor/importers/common/track_tracker.h" -namespace perfetto { -namespace trace_processor { +namespace perfetto::trace_processor { +namespace { + +TrackTracker::LegacyCharArrayName GetTrackName(uint32_t cpu) { + return TrackTracker::LegacyCharArrayName{ + base::StackString<255>("pkVM Hypervisor CPU %u", cpu)}; +} + +} // namespace PkvmHypervisorCpuTracker::PkvmHypervisorCpuTracker( TraceProcessorContext* context) @@ -78,16 +84,15 @@ void PkvmHypervisorCpuTracker::ParseHypEvent(uint32_t cpu, void PkvmHypervisorCpuTracker::ParseHypEnter(uint32_t cpu, int64_t timestamp) { // TODO(b/249050813): handle bad events (e.g. 2 hyp_enter in a row) - TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu); + TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); context_->slice_tracker->Begin(timestamp, track_id, category_, slice_name_); } void PkvmHypervisorCpuTracker::ParseHypExit(uint32_t cpu, int64_t timestamp) { // TODO(b/249050813): handle bad events (e.g. 2 hyp_exit in a row) TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu); + TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); context_->slice_tracker->End(timestamp, track_id); } @@ -95,7 +100,7 @@ void PkvmHypervisorCpuTracker::ParseHostHcall(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::HostHcallFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu); + TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); auto args_inserter = [this, &evt](ArgsTracker::BoundInserter* inserter) { StringId host_hcall = context_->storage->InternString("host_hcall"); @@ -113,7 +118,7 @@ void PkvmHypervisorCpuTracker::ParseHostSmc(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::HostSmcFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu); + TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); auto args_inserter = [this, &evt](ArgsTracker::BoundInserter* inserter) { StringId host_smc = context_->storage->InternString("host_smc"); @@ -131,7 +136,7 @@ void PkvmHypervisorCpuTracker::ParseHostMemAbort(uint32_t cpu, protozero::ConstBytes blob) { protos::pbzero::HostMemAbortFtraceEvent::Decoder evt(blob.data, blob.size); TrackId track_id = context_->track_tracker->InternCpuTrack( - TrackClassification::kPkvmHypervisor, cpu); + TrackClassification::kPkvmHypervisor, cpu, GetTrackName(cpu)); auto args_inserter = [this, &evt](ArgsTracker::BoundInserter* inserter) { StringId host_mem_abort = context_->storage->InternString("host_mem_abort"); @@ -145,5 +150,4 @@ void PkvmHypervisorCpuTracker::ParseHostMemAbort(uint32_t cpu, args_inserter); } -} // namespace trace_processor -} // namespace perfetto +} // namespace perfetto::trace_processor From 2cf86e463dea17b98b65753c4bdd0809a9c92415 Mon Sep 17 00:00:00 2001 From: Lalit Maganti Date: Mon, 21 Oct 2024 05:20:33 -0700 Subject: [PATCH 4/4] tp: migrate all cpu counter tracks to new track name system Change-Id: I0e36ff253b8946d601061052ba10260ae8bb8e40 --- .../importers/common/track_tracker.cc | 80 ++++++------------- .../importers/ftrace/ftrace_parser.cc | 29 +++++-- .../importers/proto/system_probes_parser.cc | 30 ++++--- .../systrace/systrace_line_parser.cc | 3 +- 4 files changed, 68 insertions(+), 74 deletions(-) diff --git a/src/trace_processor/importers/common/track_tracker.cc b/src/trace_processor/importers/common/track_tracker.cc index e756af4148..253fc14d0c 100644 --- a/src/trace_processor/importers/common/track_tracker.cc +++ b/src/trace_processor/importers/common/track_tracker.cc @@ -65,47 +65,6 @@ const char* GetNameForGroup(TrackTracker::Group group) { PERFETTO_FATAL("For GCC"); } -// This function is added to keep backward compatibility. Don't add new names. -inline std::optional GetCpuCounterTrackName( - TrackClassification type, - uint32_t cpu) { - if (type == TrackClassification::kCpuFrequency) - return "cpufreq"; - if (type == TrackClassification::kCpuFrequencyThrottle) - return "cpufreq_throttle"; - if (type == TrackClassification::kCpuIdle) - return "cpuidle"; - if (type == TrackClassification::kUserTime) - return "cpu.times.user_ns"; - if (type == TrackClassification::kNiceUserTime) - return "cpu.times.user_nice_ns"; - if (type == TrackClassification::kSystemModeTime) - return "cpu.times.system_mode_ns"; - if (type == TrackClassification::kCpuIdleTime) - return "cpu.times.idle_ns"; - if (type == TrackClassification::kIoWaitTime) - return "cpu.times.io_wait_ns"; - if (type == TrackClassification::kIrqTime) - return "cpu.times.irq_ns"; - if (type == TrackClassification::kSoftIrqTime) - return "cpu.times.softirq_ns"; - if (type == TrackClassification::kIrqCounter) - return "num_irq"; - if (type == TrackClassification::kSoftirqCounter) - return "num_softirq"; - if (type == TrackClassification::kCpuUtilization) - return base::StackString<255>("Cpu %u Util", cpu).ToStdString(); - if (type == TrackClassification::kCpuCapacity) - return base::StackString<255>("Cpu %u Cap", cpu).ToStdString(); - if (type == TrackClassification::kCpuNumberRunning) - return base::StackString<255>("Cpu %u Nr Running", cpu).ToStdString(); - if (type == TrackClassification::kCpuMaxFrequencyLimit) - return base::StackString<255>("Cpu %u Max Freq Limit", cpu).ToStdString(); - if (type == TrackClassification::kCpuMinFrequencyLimit) - return base::StackString<255>("Cpu %u Min Freq Limit", cpu).ToStdString(); - return std::nullopt; -} - bool IsLegacyStringIdNameAllowed(TrackClassification classification) { // **DO NOT** add new values here. Use TrackTracker::AutoName instead. return classification == @@ -125,7 +84,23 @@ bool IsLegacyCharArrayNameAllowed(TrackClassification classification) { classification == TrackClassification::kNapiGroCpu || classification == TrackClassification::kFuncgraphCpu || classification == TrackClassification::kMaliIrqCpu || - classification == TrackClassification::kPkvmHypervisor; + classification == TrackClassification::kPkvmHypervisor || + classification == TrackClassification::kCpuFrequency || + classification == TrackClassification::kCpuFrequencyThrottle || + classification == TrackClassification::kCpuIdle || + classification == TrackClassification::kUserTime || + classification == TrackClassification::kSystemModeTime || + classification == TrackClassification::kCpuIdleTime || + classification == TrackClassification::kIoWaitTime || + classification == TrackClassification::kIrqTime || + classification == TrackClassification::kSoftIrqTime || + classification == TrackClassification::kIrqCounter || + classification == TrackClassification::kSoftirqCounter || + classification == TrackClassification::kCpuUtilization || + classification == TrackClassification::kCpuCapacity || + classification == TrackClassification::kCpuNumberRunning || + classification == TrackClassification::kCpuMaxFrequencyLimit || + classification == TrackClassification::kCpuMinFrequencyLimit; } } // namespace @@ -458,20 +433,18 @@ TrackId TrackTracker::LegacyInternGlobalCounterTrack(TrackTracker::Group group, return track; } -TrackId TrackTracker::InternCpuCounterTrack(TrackClassification type, +TrackId TrackTracker::InternCpuCounterTrack(TrackClassification classification, uint32_t cpu, - const TrackName&) { + const TrackName& name) { auto ucpu = context_->cpu_tracker->GetOrCreateCpu(cpu); + StringId name_id = StringIdFromTrackName(classification, name); TrackMapKey key; - key.classification = type; + key.classification = classification; DimensionsBuilder dims_builder = CreateDimensionsBuilder(); dims_builder.AppendUcpu(ucpu); - std::optional maybe_name = GetCpuCounterTrackName(type, cpu); - if (maybe_name) { - dims_builder.AppendName(context_->storage->InternString(*maybe_name)); - } + dims_builder.AppendName(name_id); key.dimensions = std::move(dims_builder).Build(); auto* it = tracks_.Find(key); @@ -479,15 +452,12 @@ TrackId TrackTracker::InternCpuCounterTrack(TrackClassification type, return *it; } - tables::CpuCounterTrackTable::Row row; + tables::CpuCounterTrackTable::Row row(name_id); row.ucpu = ucpu; row.machine_id = context_->machine_id(); - row.classification = - context_->storage->InternString(TrackClassificationToString(type)); + row.classification = context_->storage->InternString( + TrackClassificationToString(classification)); row.dimension_arg_set_id = key.dimensions->arg_set_id; - if (maybe_name) { - row.name = context_->storage->InternString(*maybe_name); - } TrackId track_id = context_->storage->mutable_cpu_counter_track_table()->Insert(row).id; diff --git a/src/trace_processor/importers/ftrace/ftrace_parser.cc b/src/trace_processor/importers/ftrace/ftrace_parser.cc index 78cf3acf91..69974de4ff 100644 --- a/src/trace_processor/importers/ftrace/ftrace_parser.cc +++ b/src/trace_processor/importers/ftrace/ftrace_parser.cc @@ -1680,7 +1680,8 @@ void FtraceParser::ParseCpuFreq(int64_t timestamp, ConstBytes blob) { uint32_t cpu = freq.cpu_id(); uint32_t new_freq_khz = freq.state(); TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuFrequency, cpu); + TrackClassification::kCpuFrequency, cpu, + TrackTracker::LegacyCharArrayName{"cpufreq"}); context_->event_tracker->PushCounter(timestamp, new_freq_khz, track); } @@ -1689,7 +1690,8 @@ void FtraceParser::ParseCpuFreqThrottle(int64_t timestamp, ConstBytes blob) { uint32_t cpu = static_cast(freq.cpu()); double new_freq_khz = static_cast(freq.freq()); TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuFrequencyThrottle, cpu); + TrackClassification::kCpuFrequencyThrottle, cpu, + TrackTracker::LegacyCharArrayName{"cpufreq_throttle"}); context_->event_tracker->PushCounter(timestamp, new_freq_khz, track); } @@ -1718,7 +1720,8 @@ void FtraceParser::ParseCpuIdle(int64_t timestamp, ConstBytes blob) { uint32_t cpu = idle.cpu_id(); uint32_t new_state = idle.state(); TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuIdle, cpu); + TrackClassification::kCpuIdle, cpu, + TrackTracker::LegacyCharArrayName{"cpuidle"}); context_->event_tracker->PushCounter(timestamp, new_state, track); } @@ -2929,12 +2932,16 @@ void FtraceParser::ParseCpuFrequencyLimits(int64_t timestamp, blob.size); TrackId max_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuMaxFrequencyLimit, evt.cpu_id()); + TrackClassification::kCpuMaxFrequencyLimit, evt.cpu_id(), + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Cpu %u Max Freq Limit", evt.cpu_id())}); context_->event_tracker->PushCounter( timestamp, static_cast(evt.max_freq()), max_track); TrackId min_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuMinFrequencyLimit, evt.cpu_id()); + TrackClassification::kCpuMinFrequencyLimit, evt.cpu_id(), + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Cpu %u Min Freq Limit", evt.cpu_id())}); context_->event_tracker->PushCounter( timestamp, static_cast(evt.min_freq()), min_track); } @@ -3498,17 +3505,23 @@ void FtraceParser::ParseSchedCpuUtilCfs(int64_t timestamp, protozero::ConstBytes blob) { protos::pbzero::SchedCpuUtilCfsFtraceEvent::Decoder evt(blob.data, blob.size); TrackId util_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuUtilization, evt.cpu()); + TrackClassification::kCpuUtilization, evt.cpu(), + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Cpu %u Util", evt.cpu())}); context_->event_tracker->PushCounter( timestamp, static_cast(evt.cpu_util()), util_track); TrackId cap_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuCapacity, evt.cpu()); + TrackClassification::kCpuCapacity, evt.cpu(), + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Cpu %u Cap", evt.cpu())}); context_->event_tracker->PushCounter( timestamp, static_cast(evt.capacity()), cap_track); TrackId nrr_track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuNumberRunning, evt.cpu()); + TrackClassification::kCpuNumberRunning, evt.cpu(), + TrackTracker::LegacyCharArrayName{ + base::StackString<255>("Cpu %u Nr Running", evt.cpu())}); context_->event_tracker->PushCounter( timestamp, static_cast(evt.nr_running()), nrr_track); } diff --git a/src/trace_processor/importers/proto/system_probes_parser.cc b/src/trace_processor/importers/proto/system_probes_parser.cc index ca5e1db062..f3508eac7e 100644 --- a/src/trace_processor/importers/proto/system_probes_parser.cc +++ b/src/trace_processor/importers/proto/system_probes_parser.cc @@ -350,7 +350,8 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { uint32_t c = 0; for (auto it = sys_stats.cpufreq_khz(); it; ++it, ++c) { TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuFrequency, c); + TrackClassification::kCpuFrequency, c, + TrackTracker::LegacyCharArrayName{"cpufreq"}); context_->event_tracker->PushCounter(ts, static_cast(*it), track); } @@ -377,37 +378,44 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { } TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kUserTime, ct.cpu_id()); + TrackClassification::kUserTime, ct.cpu_id(), + TrackTracker::LegacyCharArrayName{"cpu.times.user_ns"}); context_->event_tracker->PushCounter(ts, static_cast(ct.user_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kNiceUserTime, ct.cpu_id()); + TrackClassification::kNiceUserTime, ct.cpu_id(), + TrackTracker::LegacyCharArrayName{"cpu.times.user_nice_ns"}); context_->event_tracker->PushCounter( ts, static_cast(ct.user_nice_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kSystemModeTime, ct.cpu_id()); + TrackClassification::kSystemModeTime, ct.cpu_id(), + TrackTracker::LegacyCharArrayName{"cpu.times.system_mode_ns"}); context_->event_tracker->PushCounter( ts, static_cast(ct.system_mode_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuIdleTime, ct.cpu_id()); + TrackClassification::kCpuIdleTime, ct.cpu_id(), + TrackTracker::LegacyCharArrayName{"cpu.times.idle_ns"}); context_->event_tracker->PushCounter(ts, static_cast(ct.idle_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kIoWaitTime, ct.cpu_id()); + TrackClassification::kIoWaitTime, ct.cpu_id(), + TrackTracker::LegacyCharArrayName{"cpu.times.io_wait_ns"}); context_->event_tracker->PushCounter( ts, static_cast(ct.io_wait_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kIrqTime, ct.cpu_id()); + TrackClassification::kIrqTime, ct.cpu_id(), + TrackTracker::LegacyCharArrayName{"cpu.times.irq_ns"}); context_->event_tracker->PushCounter(ts, static_cast(ct.irq_ns()), track); track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kSoftIrqTime, ct.cpu_id()); + TrackClassification::kSoftIrqTime, ct.cpu_id(), + TrackTracker::LegacyCharArrayName{"cpu.times.softirq_ns"}); context_->event_tracker->PushCounter( ts, static_cast(ct.softirq_ns()), track); } @@ -415,7 +423,8 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { for (auto it = sys_stats.num_irq(); it; ++it) { protos::pbzero::SysStats::InterruptCount::Decoder ic(*it); TrackId track = context_->track_tracker->InternSingleDimensionTrack( - TrackClassification::kIrqCounter, irq_id_, Variadic::Integer(ic.irq())); + TrackClassification::kIrqCounter, irq_id_, Variadic::Integer(ic.irq()), + TrackTracker::LegacyCharArrayName{"num_irq"}); context_->event_tracker->PushCounter(ts, static_cast(ic.count()), track); } @@ -424,7 +433,8 @@ void SystemProbesParser::ParseSysStats(int64_t ts, ConstBytes blob) { protos::pbzero::SysStats::InterruptCount::Decoder ic(*it); TrackId track = context_->track_tracker->InternSingleDimensionTrack( TrackClassification::kSoftirqCounter, irq_id_, - Variadic::Integer(ic.irq())); + Variadic::Integer(ic.irq()), + TrackTracker::LegacyCharArrayName{"num_softirq"}); context_->event_tracker->PushCounter(ts, static_cast(ic.count()), track); } diff --git a/src/trace_processor/importers/systrace/systrace_line_parser.cc b/src/trace_processor/importers/systrace/systrace_line_parser.cc index a228f133cf..863cb069e2 100644 --- a/src/trace_processor/importers/systrace/systrace_line_parser.cc +++ b/src/trace_processor/importers/systrace/systrace_line_parser.cc @@ -137,7 +137,8 @@ util::Status SystraceLineParser::ParseLine(const SystraceLine& line) { } TrackId track = context_->track_tracker->InternCpuCounterTrack( - TrackClassification::kCpuFrequency, event_cpu.value()); + TrackClassification::kCpuFrequency, event_cpu.value(), + TrackTracker::LegacyCharArrayName{"cpufreq"}); context_->event_tracker->PushCounter(line.ts, new_state.value(), track); } else if (line.event_name == "cpu_idle") { std::optional event_cpu = base::StringToUInt32(args["cpu_id"]);