• 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
16-- All kernel threads of the trace. As kernel threads are processes, provides
17-- also process data.
18CREATE PERFETTO TABLE linux_kernel_threads (
19  -- Upid of kernel thread. Alias of |process.upid|.
20  upid JOINID(process.id),
21  -- Utid of kernel thread. Alias of |thread.utid|.
22  utid JOINID(thread.id),
23  -- Pid of kernel thread. Alias of |process.pid|.
24  pid LONG,
25  -- Tid of kernel thread. Alias of |process.pid|.
26  tid LONG,
27  -- Name of kernel process. Alias of |process.name|.
28  process_name STRING,
29  -- Name of kernel thread. Alias of |thread.name|.
30  thread_name STRING,
31  -- Machine id of kernel thread. If NULL then it's a single machine trace.
32  -- Alias of |process.machine_id|.
33  machine_id LONG
34) AS
35WITH
36  pid_2 AS (
37    SELECT
38      upid,
39      pid,
40      name,
41      machine_id
42    FROM process
43    WHERE
44      pid = 2
45  ),
46  parent_pid_2 AS (
47    SELECT
48      p.upid,
49      p.pid,
50      p.name,
51      p.machine_id
52    FROM process AS p
53    JOIN pid_2
54      ON p.parent_upid = pid_2.upid
55  )
56SELECT
57  upid,
58  utid,
59  pid,
60  tid,
61  p.name AS process_name,
62  t.name AS thread_name,
63  p.machine_id
64FROM (
65  SELECT
66    *
67  FROM parent_pid_2
68  UNION
69  SELECT
70    *
71  FROM pid_2
72) AS p
73JOIN thread AS t
74  USING (upid);
75