-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "stdlib: Add linux_kernel_threads" into main
- Loading branch information
Showing
7 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
-- | ||
-- Copyright 2024 The Android Open Source Project | ||
-- | ||
-- Licensed under the Apache License, Version 2.0 (the 'License'); | ||
-- you may not use this file except in compliance with the License. | ||
-- You may obtain a copy of the License at | ||
-- | ||
-- https://www.apache.org/licenses/LICENSE-2.0 | ||
-- | ||
-- Unless required by applicable law or agreed to in writing, software | ||
-- distributed under the License is distributed on an 'AS IS' BASIS, | ||
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
-- See the License for the specific language governing permissions and | ||
-- limitations under the License. | ||
|
||
-- All kernel threads of the trace. As kernel threads are processes, provides | ||
-- also process data. | ||
CREATE PERFETTO TABLE linux_kernel_threads( | ||
-- Upid of kernel thread. Alias of |process.upid|. | ||
upid INT, | ||
-- Utid of kernel thread. Alias of |thread.utid|. | ||
utid INT, | ||
-- Pid of kernel thread. Alias of |process.pid|. | ||
pid INT, | ||
-- Tid of kernel thread. Alias of |process.pid|. | ||
tid INT, | ||
-- Name of kernel process. Alias of |process.name|. | ||
process_name STRING, | ||
-- Name of kernel thread. Alias of |thread.name|. | ||
thread_name STRING, | ||
-- Machine id of kernel thread. If NULL then it's a single machine trace. | ||
-- Alias of |process.machine_id|. | ||
machine_id INT | ||
) AS | ||
WITH pid_2 AS ( | ||
SELECT upid, pid, name, machine_id | ||
FROM process | ||
WHERE pid = 2 | ||
), | ||
parent_pid_2 AS ( | ||
SELECT p.upid, p.pid, p.name, p.machine_id | ||
FROM process p | ||
JOIN pid_2 ON p.parent_upid = pid_2.upid | ||
) | ||
SELECT | ||
upid, | ||
utid, | ||
pid, | ||
tid, | ||
p.name AS process_name, | ||
t.name AS thread_name, | ||
p.machine_id | ||
FROM | ||
( | ||
SELECT * FROM parent_pid_2 | ||
UNION | ||
SELECT * FROM pid_2 | ||
) p | ||
JOIN thread t USING (upid); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright (C) 2024 The Android Open Source Project | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License a | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from python.generators.diff_tests.testing import Path, DataPath, Metric, Systrace | ||
from python.generators.diff_tests.testing import Csv, Json, TextProto, BinaryProto | ||
from python.generators.diff_tests.testing import DiffTestBlueprint | ||
from python.generators.diff_tests.testing import TestSuite | ||
from python.generators.diff_tests.testing import PrintProfileProto | ||
|
||
|
||
class LinuxTests(TestSuite): | ||
|
||
def test_kernel_threads(self): | ||
return DiffTestBlueprint( | ||
trace=DataPath('android_postboot_unlock.pftrace'), | ||
query=""" | ||
INCLUDE PERFETTO MODULE linux.threads; | ||
SELECT upid, utid, pid, tid, process_name, thread_name | ||
FROM linux_kernel_threads | ||
ORDER by utid LIMIT 10; | ||
""", | ||
out=Csv(""" | ||
"upid","utid","pid","tid","process_name","thread_name" | ||
7,14,510,510,"sugov:0","sugov:0" | ||
89,23,1365,1365,"com.google.usf.","com.google.usf." | ||
87,37,1249,1249,"irq/357-dwc3","irq/357-dwc3" | ||
31,38,6,6,"kworker/u16:0","kworker/u16:0" | ||
11,42,511,511,"sugov:4","sugov:4" | ||
83,43,1152,1152,"irq/502-fts_ts","irq/502-fts_ts" | ||
93,44,2374,2374,"csf_sync_update","csf_sync_update" | ||
18,45,2379,2379,"csf_kcpu_0","csf_kcpu_0" | ||
12,47,247,247,"decon0_kthread","decon0_kthread" | ||
65,48,159,159,"spi0","spi0" | ||
""")) |