perfetto icon indicating copy to clipboard operation
perfetto copied to clipboard

TriggerConfig. Trigger(STOP_TRACING) and data_stources {"Linux. perf"} are suspected to have errors when used together.

Open wuhao-1998 opened this issue 1 year ago • 10 comments

Current requirement: Only when an exception is triggered, can the previously collected memory data from perfetto be saved to disk. I carefully studied the official example code and wrote a cfg switch. I use duration_ms: 200000 as the end condition, and both perf stack data and process data can be saved. But instead of duration_ms, use trigger_made: STOP_TRACING, which only stores process data and lacks perf related stack data. Is this problem known?

Do you need me to provide anything that can quickly help solve this problem? One additional point: Calling a command is the same as using other methods

But according to the official website introduction and theory, triggers and data collectors should not be related, but I cannot explain this experimental phenomenon

wuhao-1998 avatar Nov 27 '25 13:11 wuhao-1998

Can you expand a bit with an example trace config. I am struggling to understand what you are doing from the bug.

Please:

  1. Share a full trace config
  2. Make a statement "this is what I expected to happen" vs "this is what happened"

to make this bug more understandable

primiano avatar Nov 27 '25 20:11 primiano

这是我的调用命令: tracebox traced

tracebox traced_probes

tracebox traced_perf  抓取命令: sudo perfetto -c /etc/mirobot/perfetto/scheduling_hunter_trigger.cfg --txt -o output.perfetto-trace  若是触发:sudo trigger_perfetto Hunter_trigger

cfg 配置项:

mi@tegra-ubuntu-pos:~$ cat  /etc/mirobot/perfetto/scheduling_hunter_trigger.cfg
buffers {
  size_kb: 98400
}
buffers {
  size_kb: 98400
}


data_sources {
  config {
    name: "linux.ftrace"
    target_buffer: 0
    ftrace_config {
      symbolize_ksyms: true
      ftrace_events: "sched/sched_switch"
      ftrace_events: "sched/sched_waking"
      ftrace_events: "sched/sched_wakeup_new"
      ftrace_events: "task/task_newtask"
      ftrace_events: "task/task_rename"
      ftrace_events: "power/cpu_idle"
      ftrace_events: "power/cpu_frequency"
      ftrace_events: "power/cpu_frequency_limits"
      ftrace_events: "power/suspend_resume"
      ftrace_events: "power/clock_set_rate"
      ftrace_events: "sched/sched_process_exec"
      ftrace_events: "sched/sched_process_exit"
      ftrace_events: "sched/sched_process_fork"
      ftrace_events: "sched/sched_process_free"
      ftrace_events: "sched/sched_process_hang"
      ftrace_events: "sched/sched_process_wait"
    }
  }
}

data_sources {
  config {
    name: "linux.process_stats"
    target_buffer: 0
    process_stats_config {
      proc_stats_poll_ms: 2000
    }
  }
}

data_sources {
  config {
    name: "linux.perf"
    target_buffer: 1
    perf_event_config {
      timebase {
        frequency: 5000
      }
      callstack_sampling {
        kernel_frames: true
      }
    }
  }
}



#trigger_config {
#  trigger_mode: STOP_TRACING
#  use_clone_snapshot_if_available: true
#  trigger_timeout_ms: 604800000
#  triggers {
#    name: "Hunter_trigger"
#    stop_delay_ms: 0
#  }
#}

duration_ms: 10000

wuhao-1998 avatar Nov 28 '25 03:11 wuhao-1998

Can you please share the trace (either here or send it directly to me)? Can you also share the screenshot of your trace errors (from "Overview" in the navigation side bar -> "Info and stats")? It is possible that there are other issues with your config/setup, and maybe one of them caused the data to not fetch at all.

What do you mean by missing perf data? Do you see no data? Some specific one that you were looking for?

aMayzner avatar Dec 01 '25 13:12 aMayzner

Specific data cannot be found (all perf stack related data is missing). The attachment contains files captured under two types of triggers.

Image

wuhao-1998 avatar Dec 03 '25 13:12 wuhao-1998

wuhao-1998 avatar Dec 03 '25 13:12 wuhao-1998

Hi, you didn't attach any files

aMayzner avatar Dec 04 '25 15:12 aMayzner

名称:trace.zip 地址:https://kpan.mioffice.cn/webfolder/ext/wAvVSd6v2u3%24uVm31GQvyw%40%40?n=0.5983061922895406 密码:G3WY

wuhao-1998 avatar Dec 05 '25 06:12 wuhao-1998

This is a file, can it be downloaded normally

wuhao-1998 avatar Dec 05 '25 07:12 wuhao-1998

According to my configuration file, reproducing the capture will result in this issue. I have already verified on multiple robots

wuhao-1998 avatar Dec 05 '25 07:12 wuhao-1998

Please use the "info & stats" or the "overview" page in the perfetto UI as the first step in troubleshooting. Your error is explained there, including a link to the relevant documentation.

But in essence: you're using RING_BUFFER tracing buffers and letting them wrap around, meaning that all incremental data is invalid. See https://perfetto.dev/docs/concepts/buffers#incremental-state-in-trace-packets.

PS: your original trace is full of data losses because you're asking for too high of a sampling frequency system-wide. Similarly, the errors page should provide additional clues.

rsavitski avatar Dec 08 '25 19:12 rsavitski