Chapter 25. Tracing latencies with trace-cmd
The trace-cmd utility is a front end to the ftrace utility. By using trace-cmd, you can enable ftrace actions, without the need to write to the /sys/kernel/debug/tracing/ directory. trace-cmd does not add any overhead on its installation.
Prerequisites
- You have administrator privileges.
25.1. Installing trace-cmd Copy linkLink copied to clipboard!
The trace-cmd utility provides a front-end to the ftrace utility.
Prerequisites
- You have administrator privileges.
Procedure
Install the
trace-cmdutility.dnf install trace-cmd
# dnf install trace-cmdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
25.2. Running trace-cmd Copy linkLink copied to clipboard!
You can use the trace-cmd utility to access all ftrace functionalities.
Prerequisites
- You have administrator privileges.
Procedure
Enter
trace-cmd commandwhere
commandis anftraceoption.NoteSee the
trace-cmd(1)man page for a complete list of commands and options. Most of the individual commands also have their own man pages,trace-cmd-command.
25.3. trace-cmd examples Copy linkLink copied to clipboard!
The command examples show how to trace kernel functions by using the trace-cmd utility.
Examples
Enable and start recording functions executing within the kernel while myapp runs.
trace-cmd record -p function myapp
# trace-cmd record -p function myappCopy to Clipboard Copied! Toggle word wrap Toggle overflow This records functions from all CPUs and all tasks, even those not related to myapp.
Display the result.
trace-cmd report
# trace-cmd reportCopy to Clipboard Copied! Toggle word wrap Toggle overflow Record only functions that start with sched while myapp runs.
trace-cmd record -p function -l 'sched*' myapp
# trace-cmd record -p function -l 'sched*' myappCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable all the IRQ events.
trace-cmd start -e irq
# trace-cmd start -e irqCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the
wakeup_rttracer.trace-cmd start -p wakeup_rt
# trace-cmd start -p wakeup_rtCopy to Clipboard Copied! Toggle word wrap Toggle overflow Start the
preemptirqsofftracer, while disabling function tracing.trace-cmd start -p preemptirqsoff -d
# trace-cmd start -p preemptirqsoff -dCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe version of
trace-cmdin RHEL 8 turns offftrace_enabledinstead of using thefunction-traceoption. You can enableftraceagain withtrace-cmd start -pfunction.Restore the state in which the system was before
trace-cmdstarted modifying it.trace-cmd start -p nop
# trace-cmd start -p nopCopy to Clipboard Copied! Toggle word wrap Toggle overflow This is important if you want to use the
debugfsfile system after usingtrace-cmd, whether or not the system was restarted in the meantime.Trace a single trace point.
trace-cmd record -e sched_wakeup ls /bin
# trace-cmd record -e sched_wakeup ls /binCopy to Clipboard Copied! Toggle word wrap Toggle overflow Stop tracing.
trace-cmd record stop
# trace-cmd record stopCopy to Clipboard Copied! Toggle word wrap Toggle overflow