From 1290ac2584d79af0cea38d84ba76e915fa294728 Mon Sep 17 00:00:00 2001 From: Samuel Wu Date: Thu, 14 Nov 2024 13:22:48 -0800 Subject: [PATCH] wattson: Fix estimates when entire CPU track missing When an entire CPU freq or idle track is missing, then some other CPU estimates won't be calculated. Add a NULL but defined time range for CPUs that are physically present on the device but don't have a single freq/idle event triggered. This is so that interval_intersect() operates on a valid time range. Test: tools/diff_test_trace_processor.py out/linux/trace_processor_shell --name-filter '.*wattson.*' Bug: 379160886 Change-Id: I3b3fa24a61c2e348802b064e17d7dc93000f32b2 Signed-off-by: Samuel Wu --- .../perfetto_sql/stdlib/wattson/cpu_freq.sql | 14 +++++++++++++- .../perfetto_sql/stdlib/wattson/cpu_idle.sql | 13 ++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq.sql b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq.sql index 94f8fd76a0..1256f3bca0 100644 --- a/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq.sql +++ b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq.sql @@ -51,4 +51,16 @@ SELECT freq, cpu, policy -FROM _cpu_freq; +FROM _cpu_freq +UNION ALL +-- Add empty cpu freq counters for CPUs that are physically present, but did not +-- have a single freq event register. The time region needs to be defined so +-- that interval_intersect doesn't remove the undefined time region. +SELECT + trace_start() as ts, + trace_dur() as dur, + NULL as freq, + cpu, + NULL as policy +FROM _dev_cpu_policy_map +WHERE cpu NOT IN (SELECT cpu FROM first_cpu_freq_slices); diff --git a/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_idle.sql b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_idle.sql index 5c8c6b54d2..c2170b705a 100644 --- a/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_idle.sql +++ b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_idle.sql @@ -91,4 +91,15 @@ SELECT idle FROM _cpu_idle -- Some durations are 0 post-adjustment and won't work with interval intersect -WHERE dur > 0; +WHERE dur > 0 +UNION ALL +-- Add empty cpu idle counters for CPUs that are physically present, but did not +-- have a single idle event register. The time region needs to be defined so +-- that interval_intersect doesn't remove the undefined time region. +SELECT + trace_start() as ts, + trace_dur() as dur, + cpu, + NULL as idle +FROM _dev_cpu_policy_map +WHERE cpu NOT IN (SELECT cpu FROM first_cpu_idle_slices);