1-- 2-- Copyright 2025 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-- View of scheduling slices with extended information. 17-- It holds slices with kernel thread scheduling information. These slices are 18-- collected when the Linux "ftrace" data source is used with the 19-- "sched/switch" and "sched/wakeup*" events enabled. 20-- 21-- The rows in this table will always have a matching row in the |thread_state| 22-- table with |thread_state.state| = 'Running' 23CREATE PERFETTO VIEW sched_with_thread_process ( 24 -- Unique identifier for this scheduling slice (Running period). 25 id ID(sched.id), 26 -- The timestamp at the start of the Running period. 27 ts TIMESTAMP, 28 -- The duration of the Running period. 29 dur DURATION, 30 -- Unique identifier of the thread that was running. 31 utid JOINID(thread.id), 32 -- Name of the thread that was running. 33 thread_name STRING, 34 -- Unique identifier of the process that the thread belongs to. 35 upid JOINID(process.id), 36 -- Name of the process that the thread belongs to. 37 process_name STRING, 38 -- The CPU that the slice executed on (meaningful only in single machine 39 -- traces). For multi-machine, join with the `cpu` table on `ucpu` to get the 40 -- CPU identifier of each machine. 41 cpu LONG, 42 -- A string representing the scheduling state of the kernel thread at the end 43 -- of the slice. The individual characters in the string mean the following: 44 -- R (runnable), S (awaiting a wakeup), D (in an uninterruptible sleep), T 45 -- (suspended), t (being traced), X (exiting), P (parked), W (waking), I 46 -- (idle), N (not contributing to the load average), K (wakeable on fatal 47 -- signals) and Z (zombie, awaiting cleanup). 48 end_state STRING, 49 -- The kernel priority that the thread ran at. 50 priority LONG 51) AS 52SELECT 53 sched.id, 54 sched.ts, 55 sched.dur, 56 utid, 57 upid, 58 thread.name AS thread_name, 59 process.name AS process_name, 60 sched.cpu, 61 sched.end_state, 62 sched.priority 63FROM sched 64JOIN thread 65 USING (utid) 66LEFT JOIN process 67 USING (upid); 68