Post

linux系统trace

linux系统trace

linux系统trace

perfetto in linux

https://perfetto.dev/docs/getting-started/system-tracing

https://ui.perfetto.dev/

1
2
3
4
5
6
7
8
curl -LO https://get.perfetto.dev/tracebox
chmod +x tracebox

curl -LO https://raw.githubusercontent.com/google/perfetto/refs/heads/main/test/configs/scheduling.cfg

./tracebox -o trace_file.perfetto-trace --txt -c scheduling.cfg

# put trace_file.perfetto-trace to ui.perfetto.dev
# One buffer allocated within the central tracing binary for the entire trace,
# shared by the two data sources below.
buffers {
  size_kb: 20480
  fill_policy: DISCARD
}

# Ftrace data from the kernel, mainly the process scheduling events.
data_sources {
  config {
    name: "linux.ftrace"
    target_buffer: 0
    ftrace_config {
      ftrace_events: "sched_switch"
      ftrace_events: "sched_waking"
      ftrace_events: "sched_wakeup_new"

      ftrace_events: "task_newtask"
      ftrace_events: "task_rename"

      ftrace_events: "sched_process_exec"
      ftrace_events: "sched_process_exit"
      ftrace_events: "sched_process_fork"
      ftrace_events: "sched_process_free"
      ftrace_events: "sched_process_hang"
      ftrace_events: "sched_process_wait"
    }
  }
}

# Resolve process commandlines and parent/child relationships, to better
# interpret the ftrace events, which are in terms of pids.
data_sources {
  config {
    name: "linux.process_stats"
    target_buffer: 0
  }
}

# 10s trace, but can be stopped prematurely.
duration_ms: 10000
This post is licensed under CC BY 4.0 by the author.