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

The trace-cmd utility provides a front-end to the ftrace utility.

Prerequisites

  • You have administrator privileges.

Procedure

  • Install the trace-cmd utility.

    # dnf install trace-cmd
    Copy to Clipboard Toggle word wrap

25.2. Running trace-cmd

You can use the trace-cmd utility to access all ftrace functionalities.

Prerequisites

  • You have administrator privileges.

Procedure

  • Enter trace-cmd command

    where command is an ftrace option.

    Note

    See 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

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
    Copy to Clipboard Toggle word wrap

    This records functions from all CPUs and all tasks, even those not related to myapp.

  • Display the result.

    # trace-cmd report
    Copy to Clipboard Toggle word wrap
  • Record only functions that start with sched while myapp runs.

    # trace-cmd record -p function -l 'sched*' myapp
    Copy to Clipboard Toggle word wrap
  • Enable all the IRQ events.

    # trace-cmd start -e irq
    Copy to Clipboard Toggle word wrap
  • Start the wakeup_rt tracer.

    # trace-cmd start -p wakeup_rt
    Copy to Clipboard Toggle word wrap
  • Start the preemptirqsoff tracer, while disabling function tracing.

    # trace-cmd start -p preemptirqsoff -d
    Copy to Clipboard Toggle word wrap
    Note

    The version of trace-cmd in RHEL 8 turns off ftrace_enabled instead of using the function-trace option. You can enable ftrace again with trace-cmd start -p function.

  • Restore the state in which the system was before trace-cmd started modifying it.

    # trace-cmd start -p nop
    Copy to Clipboard Toggle word wrap

    This is important if you want to use the debugfs file system after using trace-cmd, whether or not the system was restarted in the meantime.

  • Trace a single trace point.

    # trace-cmd record -e sched_wakeup ls /bin
    Copy to Clipboard Toggle word wrap
  • Stop tracing.

    # trace-cmd record stop
    Copy to Clipboard Toggle word wrap
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat