• 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-- Contains information of CPUs seen during the trace.
16CREATE PERFETTO VIEW cpu (
17  -- Unique identifier for this CPU. Identical to |ucpu|, prefer using |ucpu|
18  -- instead.
19  id UINT,
20  -- Unique identifier for this CPU. Isn't equal to |cpu| for remote machines
21  -- and is equal to |cpu| for the host machine.
22  ucpu UINT,
23  -- The 0-based CPU core identifier.
24  cpu UINT,
25  -- The name of the "most-specific" child table containing this row.
26  type STRING,
27  -- The cluster id is shared by CPUs in the same cluster.
28  cluster_id UINT,
29  -- A string describing this core.
30  processor STRING,
31  -- Machine identifier, non-null for CPUs on a remote machine.
32  machine_id UINT
33) AS
34SELECT
35  id,
36  id AS ucpu,
37  cpu,
38  type AS type,
39  cluster_id,
40  processor,
41  machine_id
42FROM
43  __intrinsic_cpu
44WHERE
45  cpu IS NOT NULL;
46
47-- Contains information of available frequencies of CPUs.
48CREATE PERFETTO VIEW cpu_frequencies (
49  -- Unique identifier for this cpu frequency.
50  id UINT,
51  -- The CPU for this frequency, meaningful only in single machine traces.
52  -- For multi-machine, join with the `cpu` table on `ucpu` to get the CPU
53  -- identifier of each machine.
54  cpu UINT,
55  -- CPU frequency in KHz.
56  freq UINT,
57  -- The CPU that the slice executed on (meaningful only in single machine
58  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
59  -- CPU identifier of each machine.
60  ucpu UINT
61) AS
62SELECT id, ucpu AS cpu, freq, ucpu
63FROM __intrinsic_cpu_freq;
64
65-- This table holds slices with kernel thread scheduling information. These
66-- slices are collected when the Linux "ftrace" data source is used with the
67-- "sched/switch" and "sched/wakeup*" events enabled.
68--
69-- The rows in this table will always have a matching row in the |thread_state|
70-- table with |thread_state.state| = 'Running'
71CREATE PERFETTO VIEW sched_slice (
72  --  Unique identifier for this scheduling slice.
73  id UINT,
74  -- The name of the "most-specific" child table containing this row.
75  type STRING,
76  -- The timestamp at the start of the slice (in nanoseconds).
77  ts LONG,
78  -- The duration of the slice (in nanoseconds).
79  dur LONG,
80  -- The CPU that the slice executed on (meaningful only in single machine
81  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
82  -- CPU identifier of each machine.
83  cpu UINT,
84  -- The thread's unique id in the trace.
85  utid UINT,
86  -- A string representing the scheduling state of the kernel
87  -- thread at the end of the slice.  The individual characters in
88  -- the string mean the following: R (runnable), S (awaiting a
89  -- wakeup), D (in an uninterruptible sleep), T (suspended),
90  -- t (being traced), X (exiting), P (parked), W (waking),
91  -- I (idle), N (not contributing to the load average),
92  -- K (wakeable on fatal signals) and Z (zombie, awaiting
93  -- cleanup).
94  end_state STRING,
95  -- The kernel priority that the thread ran at.
96  priority INT,
97  -- The unique CPU identifier that the slice executed on.
98  ucpu UINT
99) AS
100SELECT
101  id,
102  type,
103  ts,
104  dur,
105  ucpu AS cpu,
106  utid,
107  end_state,
108  priority,
109  ucpu
110FROM
111  __intrinsic_sched_slice;
112
113-- This table contains the scheduling state of every thread on the system during
114-- the trace.
115--
116-- The rows in this table which have |state| = 'Running', will have a
117-- corresponding row in the |sched_slice| table.
118CREATE PERFETTO VIEW thread_state (
119  -- Unique identifier for this thread state.
120  id UINT,
121  -- The name of the "most-specific" child table containing this row.
122  type STRING,
123  -- The timestamp at the start of the slice (in nanoseconds).
124  ts LONG,
125  -- The duration of the slice (in nanoseconds).
126  dur LONG,
127  -- The CPU that the thread executed on (meaningful only in single machine
128  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
129  -- CPU identifier of each machine.
130  cpu UINT,
131  -- The thread's unique id in the trace.
132  utid UINT,
133  -- The scheduling state of the thread. Can be "Running" or any of the states
134  -- described in |sched_slice.end_state|.
135  state STRING,
136  -- Indicates whether this thread was blocked on IO.
137  io_wait UINT,
138  -- The function in the kernel this thread was blocked on.
139  blocked_function STRING,
140  -- The unique thread id of the thread which caused a wakeup of this thread.
141  waker_utid UINT,
142  -- The unique thread state id which caused a wakeup of this thread.
143  waker_id UINT,
144  -- Whether the wakeup was from interrupt context or process context.
145  irq_context UINT,
146  -- The unique CPU identifier that the thread executed on.
147  ucpu UINT
148) AS
149SELECT
150  id,
151  type,
152  ts,
153  dur,
154  ucpu AS cpu,
155  utid,
156  state,
157  io_wait,
158  blocked_function,
159  waker_utid,
160  waker_id,
161  irq_context,
162  ucpu
163FROM
164  __intrinsic_thread_state;
165
166-- Contains 'raw' events from the trace for some types of events. This table
167-- only exists for debugging purposes and should not be relied on in production
168-- usecases (i.e. metrics, standard library etc.)
169CREATE PERFETTO VIEW raw (
170  -- Unique identifier for this raw event.
171  id UINT,
172  -- The name of the "most-specific" child table containing this row.
173  type STRING,
174  -- The timestamp of this event.
175  ts LONG,
176  -- The name of the event. For ftrace events, this will be the ftrace event
177  -- name.
178  name STRING,
179  -- The CPU this event was emitted on (meaningful only in single machine
180  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
181  -- CPU identifier of each machine.
182  cpu UINT,
183  -- The thread this event was emitted on.
184  utid UINT,
185  -- The set of key/value pairs associated with this event.
186  arg_set_id UINT,
187  -- Ftrace event flags for this event. Currently only emitted for sched_waking
188  -- events.
189  common_flags UINT,
190  -- The unique CPU identifier that this event was emitted on.
191  ucpu UINT
192) AS
193SELECT
194  id,
195  type,
196  ts,
197  name,
198  ucpu AS cpu,
199  utid,
200  arg_set_id,
201  common_flags,
202  ucpu
203FROM
204  __intrinsic_raw;
205
206-- Contains all the ftrace events in the trace. This table exists only for
207-- debugging purposes and should not be relied on in production usecases (i.e.
208-- metrics, standard library etc). Note also that this table might be empty if
209-- raw ftrace parsing has been disabled.
210CREATE PERFETTO VIEW ftrace_event (
211  -- Unique identifier for this ftrace event.
212  id UINT,
213  -- The name of the "most-specific" child table containing this row.
214  type STRING,
215  -- The timestamp of this event.
216  ts LONG,
217  -- The ftrace event name.
218  name STRING,
219  -- The CPU this event was emitted on (meaningful only in single machine
220  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
221  -- CPU identifier of each machine.
222  cpu UINT,
223  -- The thread this event was emitted on.
224  utid UINT,
225  -- The set of key/value pairs associated with this event.
226  arg_set_id UINT,
227  -- Ftrace event flags for this event. Currently only emitted for
228  -- sched_waking events.
229  common_flags UINT,
230  -- The unique CPU identifier that this event was emitted on.
231  ucpu UINT
232) AS
233SELECT
234  id,
235  type,
236  ts,
237  name,
238  ucpu AS cpu,
239  utid,
240  arg_set_id,
241  common_flags,
242  ucpu
243FROM
244  __intrinsic_ftrace_event;
245
246-- The sched_slice table with the upid column.
247CREATE PERFETTO VIEW experimental_sched_upid (
248  --  Unique identifier for this scheduling slice.
249  id UINT,
250  -- The name of the "most-specific" child table containing this row.
251  type STRING,
252  -- The timestamp at the start of the slice (in nanoseconds).
253  ts LONG,
254  -- The duration of the slice (in nanoseconds).
255  dur LONG,
256  -- The CPU that the slice executed on (meaningful only in single machine
257  -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the
258  -- CPU identifier of each machine.
259  cpu UINT,
260  -- The thread's unique id in the trace.
261  utid UINT,
262  -- A string representing the scheduling state of the kernel thread at the end
263  -- of the slice. The individual characters in the string mean the following: R
264  -- (runnable), S (awaiting a wakeup), D (in an uninterruptible sleep), T
265  -- (suspended), t (being traced), X (exiting), P (parked), W (waking), I
266  -- (idle), N (not contributing to the load average), K (wakeable on fatal
267  -- signals) and Z (zombie, awaiting cleanup).
268  end_state STRING,
269  -- The kernel priority that the thread ran at.
270  priority INT,
271  -- The unique CPU identifier that the slice executed on.
272  ucpu UINT,
273  -- The process's unique id in the trace.
274  upid UINT
275) AS
276SELECT
277  id,
278  type,
279  ts,
280  dur,
281  ucpu AS cpu,
282  utid,
283  end_state,
284  priority,
285  ucpu,
286  upid
287FROM
288  __intrinsic_sched_upid;