xref: /aosp_15_r20/external/perfetto/docs/data-sources/syscalls.md (revision 6dbdd20afdafa5e3ca9b8809fa73465d530080dc)
1# System calls
2
3On Linux and Android (userdebug builds only) Perfetto can keep track of system
4calls.
5
6Right now only the syscall number is recorded in the trace, the arguments are
7not stored to limit the trace size overhead.
8
9At import time, the Trace Processor uses an internal syscall mapping table,
10currently supporting x86, x86_64, ArmEabi, aarch32 and aarch64. These tables are
11generated through the
12[`extract_linux_syscall_tables`](/tools/extract_linux_syscall_tables) script.
13
14## UI
15
16At the UI level system calls are shown inlined with the per-thread slice tracks:
17
18![](/docs/images/syscalls.png 'System calls in the thread tracks')
19
20## SQL
21
22At the SQL level, syscalls are no different than any other userspace slice
23event. They get interleaved in the per-thread slice stack and can be easily
24filtered by looking for the 'sys\_' prefix:
25
26```sql
27select ts, dur, t.name as thread, s.name, depth from slices as s
28left join thread_track as tt on s.track_id = tt.id
29left join thread as t on tt.utid = t.utid
30where s.name like 'sys_%'
31```
32
33| ts              | dur       | thread          | name            |
34| --------------- | --------- | --------------- | --------------- |
35| 856325324372751 | 439867648 | s.nexuslauncher | sys_epoll_pwait |
36| 856325324376970 | 990       | FpsThrottlerThr | sys_recvfrom    |
37| 856325324378376 | 2657      | surfaceflinger  | sys_ioctl       |
38| 856325324419574 | 1250      | android.anim.lf | sys_recvfrom    |
39| 856325324428168 | 27344     | android.anim.lf | sys_ioctl       |
40| 856325324451345 | 573       | FpsThrottlerThr | sys_getuid      |
41
42## TraceConfig
43
44```protobuf
45data_sources: {
46    config {
47        name: "linux.ftrace"
48        ftrace_config {
49            ftrace_events: "raw_syscalls/sys_enter"
50            ftrace_events: "raw_syscalls/sys_exit"
51        }
52    }
53}
54```
55