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 counters.intervals; 17 18-- Counter information for each frequency change for each CPU. Finds each time 19-- region where a CPU frequency is constant. 20CREATE PERFETTO TABLE cpu_frequency_counters ( 21 -- Counter id. 22 id LONG, 23 -- Joinable with 'counter_track.id'. 24 track_id JOINID(track.id), 25 -- Starting timestamp of the counter 26 ts TIMESTAMP, 27 -- Duration in which counter is constant and frequency doesn't change. 28 dur DURATION, 29 -- Frequency in kHz of the CPU that corresponds to this counter. NULL if not 30 -- found or undefined. 31 freq LONG, 32 -- Unique CPU id. 33 ucpu LONG, 34 -- CPU that corresponds to this counter. 35 cpu LONG 36) AS 37SELECT 38 count_w_dur.id, 39 count_w_dur.track_id, 40 count_w_dur.ts, 41 count_w_dur.dur, 42 cast_int!(count_w_dur.value) AS freq, 43 cpu.ucpu, 44 cct.cpu 45FROM counter_leading_intervals!(( 46 SELECT c.* 47 FROM counter c 48 JOIN cpu_counter_track cct 49 ON cct.id = c.track_id AND cct.name = 'cpufreq' 50)) AS count_w_dur 51JOIN cpu_counter_track AS cct 52 ON track_id = cct.id 53JOIN cpu 54 ON cct.machine_id IS cpu.machine_id AND cct.cpu = cpu.cpu; 55