Chapter 20. Managing tracepoints by using perf collector without restarting perf
Use the control pipe interface to manage different tracepoints in a running perf collector. You can dynamically adjust what data you are collecting without having to stop or restart perf. This prevents performance data loss that occurs when you stop or restart recording processes.
20.1. Adding tracepoints to a running perf collector without stopping or restarting perf Copy linkLink copied to clipboard!
You can add tracepoints to a running perf collector by using the control pipe interface. perf adjusts the data being recorded without having to stop perf, therefore preventing the loss of performance data.
Prerequisites
-
You have the
perfuser space tool installed. For more information, see Installing perf.
Procedure
Configure the control pipe interface:
# mkfifo control ack perf.pipeRun
perf recordwith the control file configuration and events you are interested in enabling:# perf record --control=fifo:control,ack -D -1 --no-buffering -e 'sched:*' -o - > perf.pipeIn this example, declaring
'sched:*'after the-eoption startsperf recordwith scheduler events.In a second command line, start the read side of the control pipe:
# cat perf.pipe | perf --no-pager script -i -Starting the read side of the control pipe triggers the following message in the first command line:
Events disabledIn a third command line, enable a tracepoint by using the control file:
# echo 'enable sched:sched_process_fork' > controlThis command triggers
perfto scan the current event list in the control file for the declared event. If the event is present, the tracepoint is enabled and the following message appears in the first command line:event sched:sched_process_fork enabledOnce the tracepoint is enabled, the second command line displays the output from perf detecting the tracepoint:
bash 33349 [034] 149587.674295: sched:sched_process_fork: comm=bash pid=33349 child_comm=bash child_pid=34056
20.2. Removing tracepoints from a running perf collector without stopping or restarting perf Copy linkLink copied to clipboard!
You can remove tracepoints from a running perf collector by using the control pipe interface. It helps to reduce the scope of data you are collecting without having to stop perf and losing performance data.
Prerequisites
-
You have the
perfuser space tool installed. For more information, see Installing perf. -
You have added tracepoints to a running
perfcollector by using the control pipe interface. For more information, see Adding tracepoints to a running perf collector without stopping or restarting perf.
Procedure
Remove the tracepoint:
# echo 'disable sched:sched_process_fork' > controlThis example assumes you have previously loaded scheduler events into the control file and enabled the tracepoint
sched:sched_process_fork.This command triggers
perfto scan the current event list in the control file for the declared event. If found, the tracepoint is disabled and the following message appears in the command line used to configure the control pipe:# event sched:sched_process_fork disabled