• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-- Gets devfreq frequency counter based on device queried. These counters will
19-- only be available if the "devfreq/devfreq_frequency" ftrace event is enabled.
20CREATE PERFETTO FUNCTION _get_devfreq_counters(
21    -- Devfreq name to query for.
22    device_name STRING
23)
24RETURNS TABLE (
25  -- Unique identifier for this counter.
26  id LONG,
27  -- Starting timestamp of the counter.
28  ts TIMESTAMP,
29  -- Duration in which counter is constant and frequency doesn't chamge.
30  dur DURATION,
31  -- Frequency in kHz of the device that corresponds to the counter.
32  freq LONG
33) AS
34SELECT
35  count_w_dur.id,
36  count_w_dur.ts,
37  count_w_dur.dur,
38  cast_int!(count_w_dur.value) AS freq
39FROM counter_leading_intervals!((
40  SELECT c.*
41  FROM counter c
42  JOIN track t ON t.id = c.track_id
43  WHERE t.type = 'linux_device_frequency'
44    AND EXTRACT_ARG(t.dimension_arg_set_id, 'linux_device') GLOB $device_name
45)) AS count_w_dur;
46
47-- ARM DSU device frequency counters. This table will only be populated on
48-- traces collected with "devfreq/devfreq_frequency" ftrace event enabled,
49-- and from ARM devices with the DSU (DynamIQ Shared Unit) hardware.
50CREATE PERFETTO TABLE linux_devfreq_dsu_counter (
51  -- Unique identifier for this counter.
52  id LONG,
53  -- Starting timestamp of the counter.
54  ts TIMESTAMP,
55  -- Duration in which counter is constant and frequency doesn't chamge.
56  dur DURATION,
57  -- Frequency in kHz of the device that corresponds to the counter.
58  dsu_freq LONG
59) AS
60SELECT
61  id,
62  ts,
63  dur,
64  freq AS dsu_freq
65FROM _get_devfreq_counters("*devfreq_dsu");
66