stdlib: Separate cpu_idle|freq|freq_idle
Create cpu_idle, cpu_freq, and cpu_freq_idle modules, which makes a
clearer distinction of what is in each file.
Test: tools/diff_test_trace_processor.py out/linux/trace_processor_shell --name-filter '.*wattson.*'
Bug: 350065024
Change-Id: I81d62578493afb7f3ecff05ae0a951d05d7dc8a9
diff --git a/Android.bp b/Android.bp
index 273b389..b05fab0 100644
--- a/Android.bp
+++ b/Android.bp
@@ -13609,6 +13609,8 @@
"src/trace_processor/perfetto_sql/stdlib/viz/summary/tracks.sql",
"src/trace_processor/perfetto_sql/stdlib/viz/threads.sql",
"src/trace_processor/perfetto_sql/stdlib/wattson/arm_dsu.sql",
+ "src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq.sql",
+ "src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq_idle.sql",
"src/trace_processor/perfetto_sql/stdlib/wattson/cpu_idle.sql",
"src/trace_processor/perfetto_sql/stdlib/wattson/cpu_split.sql",
"src/trace_processor/perfetto_sql/stdlib/wattson/curves/device.sql",
diff --git a/BUILD b/BUILD
index 787ebb5..742634b 100644
--- a/BUILD
+++ b/BUILD
@@ -2989,6 +2989,8 @@
name = "src_trace_processor_perfetto_sql_stdlib_wattson_wattson",
srcs = [
"src/trace_processor/perfetto_sql/stdlib/wattson/arm_dsu.sql",
+ "src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq.sql",
+ "src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq_idle.sql",
"src/trace_processor/perfetto_sql/stdlib/wattson/cpu_idle.sql",
"src/trace_processor/perfetto_sql/stdlib/wattson/cpu_split.sql",
"src/trace_processor/perfetto_sql/stdlib/wattson/curves/device.sql",
diff --git a/src/trace_processor/perfetto_sql/stdlib/wattson/BUILD.gn b/src/trace_processor/perfetto_sql/stdlib/wattson/BUILD.gn
index 852a839..82a8b97 100644
--- a/src/trace_processor/perfetto_sql/stdlib/wattson/BUILD.gn
+++ b/src/trace_processor/perfetto_sql/stdlib/wattson/BUILD.gn
@@ -17,6 +17,8 @@
perfetto_sql_source_set("wattson") {
sources = [
"arm_dsu.sql",
+ "cpu_freq.sql",
+ "cpu_freq_idle.sql",
"cpu_idle.sql",
"cpu_split.sql",
"curves/device.sql",
diff --git a/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq.sql b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq.sql
new file mode 100644
index 0000000..080ccf3
--- /dev/null
+++ b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq.sql
@@ -0,0 +1,29 @@
+--
+-- Copyright 2024 The Android Open Source Project
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- https://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+INCLUDE PERFETTO MODULE linux.cpu.frequency;
+INCLUDE PERFETTO MODULE wattson.device_infos;
+
+CREATE PERFETTO TABLE _cpu_freq AS
+SELECT
+ ts,
+ dur,
+ freq,
+ cf.ucpu as cpu,
+ d_map.policy
+FROM cpu_frequency_counters as cf
+JOIN _dev_cpu_policy_map as d_map
+ON cf.ucpu = d_map.cpu;
+
diff --git a/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq_idle.sql b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq_idle.sql
new file mode 100644
index 0000000..755ba0f
--- /dev/null
+++ b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_freq_idle.sql
@@ -0,0 +1,51 @@
+--
+-- Copyright 2024 The Android Open Source Project
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- https://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+
+INCLUDE PERFETTO MODULE wattson.cpu_freq;
+INCLUDE PERFETTO MODULE wattson.cpu_idle;
+INCLUDE PERFETTO MODULE wattson.curves.utils;
+
+-- Combines idle and freq tables of all CPUs to create system state.
+CREATE VIRTUAL TABLE _idle_freq
+USING
+ SPAN_OUTER_JOIN(
+ _cpu_freq partitioned cpu, _adjusted_deep_idle partitioned cpu
+ );
+
+-- Add extra column indicating that frequency info are present
+CREATE PERFETTO TABLE _valid_window
+AS
+WITH window_start AS (
+ SELECT ts as start_ts
+ FROM _idle_freq
+ WHERE cpu = 0 and freq GLOB '*[0-9]*'
+ ORDER BY ts ASC
+ LIMIT 1
+),
+window_end AS (
+ SELECT ts + dur as end_ts
+ FROM cpu_frequency_counters
+ ORDER by ts DESC
+ LIMIT 1
+)
+SELECT
+ start_ts as ts,
+ end_ts - start_ts as dur
+FROM window_start, window_end;
+
+CREATE VIRTUAL TABLE _idle_freq_filtered
+USING
+ SPAN_JOIN(_valid_window, _idle_freq);
+
diff --git a/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_split.sql b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_split.sql
index 8c496d9..e8fb380 100644
--- a/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_split.sql
+++ b/src/trace_processor/perfetto_sql/stdlib/wattson/cpu_split.sql
@@ -13,57 +13,12 @@
-- See the License for the specific language governing permissions and
-- limitations under the License.
-INCLUDE PERFETTO MODULE linux.cpu.frequency;
INCLUDE PERFETTO MODULE time.conversion;
INCLUDE PERFETTO MODULE wattson.arm_dsu;
-INCLUDE PERFETTO MODULE wattson.cpu_idle;
+INCLUDE PERFETTO MODULE wattson.cpu_freq_idle;
INCLUDE PERFETTO MODULE wattson.curves.utils;
INCLUDE PERFETTO MODULE wattson.device_infos;
-CREATE PERFETTO TABLE _cpu_freq
-AS
-SELECT
- ts,
- dur,
- freq,
- cf.cpu,
- d_map.policy
-FROM cpu_frequency_counters as cf
-JOIN _dev_cpu_policy_map as d_map
-ON cf.cpu = d_map.cpu;
-
--- Combines idle and freq tables of all CPUs to create system state.
-CREATE VIRTUAL TABLE _idle_freq
-USING
- SPAN_OUTER_JOIN(
- _cpu_freq partitioned cpu, _adjusted_deep_idle partitioned cpu
- );
-
--- Add extra column indicating that frequency info are present
-CREATE PERFETTO TABLE _valid_window
-AS
-WITH window_start AS (
- SELECT ts as start_ts
- FROM _idle_freq
- WHERE cpu = 0 and freq GLOB '*[0-9]*'
- ORDER BY ts ASC
- LIMIT 1
-),
-window_end AS (
- SELECT ts + dur as end_ts
- FROM cpu_frequency_counters
- ORDER by ts DESC
- LIMIT 1
-)
-SELECT
- start_ts as ts,
- end_ts - start_ts as dur
-FROM window_start, window_end;
-
-CREATE VIRTUAL TABLE _idle_freq_filtered
-USING
- SPAN_JOIN(_valid_window, _idle_freq);
-
-- Start matching split CPUs with curves
CREATE PERFETTO TABLE _idle_freq_materialized
AS