1-- 2-- Copyright 2024 The Android Open Source Project 3-- 4-- Licensed under the Apache License, Version 2.0 (the "License"); 5-- you may not use this file except in compliance with the License. 6-- You may obtain a copy of the License at 7-- 8-- https://www.apache.org/licenses/LICENSE-2.0 9-- 10-- Unless required by applicable law or agreed to in writing, software 11-- distributed under the License is distributed on an "AS IS" BASIS, 12-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13-- See the License for the specific language governing permissions and 14-- limitations under the License. 15 16INCLUDE PERFETTO MODULE intervals.intersect; 17 18INCLUDE PERFETTO MODULE linux.devfreq; 19 20INCLUDE PERFETTO MODULE wattson.cpu_split; 21 22INCLUDE PERFETTO MODULE wattson.curves.utils; 23 24INCLUDE PERFETTO MODULE wattson.device_infos; 25 26CREATE PERFETTO TABLE _cpu_curves AS 27SELECT 28 ts, 29 dur, 30 freq_0, 31 idle_0, 32 freq_1, 33 idle_1, 34 freq_2, 35 idle_2, 36 freq_3, 37 idle_3, 38 cpu4_curve, 39 cpu5_curve, 40 cpu6_curve, 41 cpu7_curve, 42 l3_hit_count, 43 l3_miss_count, 44 suspended, 45 no_static, 46 min( 47 no_static, 48 coalesce(idle_4, 1), 49 coalesce(idle_5, 1), 50 coalesce(idle_6, 1), 51 coalesce(idle_7, 1) 52 ) AS all_cpu_deep_idle 53FROM _w_independent_cpus_calc AS base, _use_devfreq_for_calc; 54 55-- Get nominal devfreq_dsu counter, OR use a dummy one for Pixel 9 VM traces 56-- The VM doesn't have a DSU, so the placeholder value of FMin is put in. The 57-- DSU frequency is a prerequisite for power estimation on Pixel 9. 58CREATE PERFETTO TABLE _dsu_frequency AS 59SELECT 60 * 61FROM linux_devfreq_dsu_counter 62UNION ALL 63SELECT 64 0 AS id, 65 trace_start() AS ts, 66 trace_end() - trace_start() AS dur, 67 610000 AS dsu_freq 68-- Only add this for traces from a VM on Pixel 9 where DSU values aren't present 69WHERE 70 ( 71 SELECT 72 str_value 73 FROM metadata 74 WHERE 75 name = 'android_guest_soc_model' 76 ) IN ( 77 SELECT 78 device 79 FROM _use_devfreq 80 ) 81 AND ( 82 SELECT 83 count(*) 84 FROM linux_devfreq_dsu_counter 85 ) = 0; 86 87CREATE PERFETTO TABLE _w_dsu_dependence AS 88SELECT 89 c.ts, 90 c.dur, 91 c.freq_0, 92 c.idle_0, 93 c.freq_1, 94 c.idle_1, 95 c.freq_2, 96 c.idle_2, 97 c.freq_3, 98 c.idle_3, 99 -- NULL columns needed to match columns of _get_max_vote before UNION 100 NULL AS cpu0_curve, 101 NULL AS cpu1_curve, 102 NULL AS cpu2_curve, 103 NULL AS cpu3_curve, 104 c.cpu4_curve, 105 c.cpu5_curve, 106 c.cpu6_curve, 107 c.cpu7_curve, 108 c.l3_hit_count, 109 c.l3_miss_count, 110 c.suspended, 111 c.no_static, 112 c.all_cpu_deep_idle, 113 d.dsu_freq AS dependent_freq, 114 255 AS dependent_policy 115FROM _interval_intersect!( 116 ( 117 _ii_subquery!(_cpu_curves), 118 _ii_subquery!(_dsu_frequency) 119 ), 120 () 121) AS ii 122JOIN _cpu_curves AS c 123 ON c._auto_id = id_0 124JOIN _dsu_frequency AS d 125 ON d._auto_id = id_1; 126