System calls

On Linux and Android (userdebug builds only) Perfetto can keep track of system calls.

Right now only the syscall number is recorded in the trace, the arguments are not stored to limit the trace size overhead.

At import time, the Trace Processor uses an internal syscall mapping table, currently supporting x86, x86_64, ArmEabi, aarch32 and aarch64. These tables are generated through the extract_linux_syscall_tables script.

UI

At the UI level system calls are shown inlined with the per-thread slice tracks:

SQL

At the SQL level, syscalls are no different than any other userspace slice event. They get interleaved in the per-thread slice stack and can be easily filtered by looking for the ‘sys_’ prefix:

select ts, dur, t.name as thread, s.name, depth from slices as s
left join thread_track as tt on s.track_id = tt.id
left join thread as t on tt.utid = t.utid
where s.name like 'sys_%'
tsdurthreadname
856325324372751439867648s.nexuslaunchersys_epoll_pwait
856325324376970990FpsThrottlerThrsys_recvfrom
8563253243783762657surfaceflingersys_ioctl
8563253244195741250android.anim.lfsys_recvfrom
85632532442816827344android.anim.lfsys_ioctl
856325324451345573FpsThrottlerThrsys_getuid

TraceConfig

data_sources: {
    config {
        name: "linux.ftrace"
        ftrace_config {
            ftrace_events: "raw_syscalls/sys_enter"
            ftrace_events: "raw_syscalls/sys_exit"
        }
    }
}