• 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-- Counter information for each idle state change for each CPU. Finds each time
19-- region where a CPU idle state is constant.
20CREATE PERFETTO TABLE cpu_idle_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 the counter is contant and idle state doesn't change.
28  dur DURATION,
29  -- Idle state of the CPU that corresponds to this counter. An idle state of -1
30  -- is defined to be active state for the CPU, and the larger the integer, the
31  -- deeper the idle state of the CPU. NULL if not found or undefined.
32  idle LONG,
33  -- CPU that corresponds to this counter.
34  cpu LONG
35) AS
36SELECT
37  count_w_dur.id,
38  count_w_dur.track_id,
39  count_w_dur.ts,
40  count_w_dur.dur,
41  cast_int!(IIF(count_w_dur.value = 4294967295, -1, count_w_dur.value)) AS idle,
42  cct.cpu
43FROM counter_leading_intervals!((
44  SELECT c.*
45  FROM counter c
46  JOIN cpu_counter_track cct ON cct.id = c.track_id AND cct.name = 'cpuidle'
47)) AS count_w_dur
48JOIN cpu_counter_track AS cct
49  ON track_id = cct.id;
50