I have tried looking at the documentation for perf script, perf trace, and trace-cmd, including the list of commands in "SEE ALSO".

I can trace e.g. sched:sched_process_exec "live" using perf trace -a --no-syscalls -e sched:sched_process_exec. However, it only shows the process name (e.g. ls). It does not show the PID, unless the tracepoint has a specific parameter for it. perf script always shows the PID, but it does not show live output; it shows the contents of a perf.data file.

I don't need this to be a single command, like btrace is for blktrace. I am happy to use a pipeline, analogous to blktrace -d /dev/sda -o - | blkparse -i -.

(Both of the above commands show PIDs :-). It is frustrating to see the blktrace family of commands, which also use trace events, can print live output in the same format as they can print recorded traces. I can't find such power in the general-purpose tracing tools!)

1 Answer 1

perf record -a --no-syscalls -e sched:sched_process_exec sh -c read | perf script

(sh -c read provides a way to stop this trace, just hit Enter. If I omit this command and try to interrupt the pipeline with ctrl+C, my output is lost, probably because it also interrupts perf script).

However this output is not "live", due to buffering. E.g. running the above command shows nothing, but hitting enter causes it to stop and show a line for the exec() of sh. blktrace has special-case code to handle output to a pipe, including disabling the default C stdio buffering. Attempting to run perf record under the unbuffer command gives the error "incompatible file format"; I presume the error comes from perf script.

man perf-report



-i, --input= Input file name. (default: perf.data unless stdin is a fifo)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .