TRACE-CMD-SET(1)

๐Ÿ’… trace-cmd-set โ€” the libtracefs manual, but make it make sense

okay so bestie, welcome to trace-cmd-set(1) โ€” yes that's a real manpage name and yes we're gonna get through it together ๐Ÿซถ. This is the one where you poke the Ftrace Linux internal tracer and tell it how to behave. It's giving "settings menu but for kernel tracing" energy and honestly? iconic.


โœจ NAME โœจ

trace-cmd-set โ€” set a configuration parameter of the Ftrace Linux internal tracer. no cap, that's literally the whole job ๐Ÿ’…


๐ŸŒธ SYNOPSIS ๐ŸŒธ

trace-cmd set [OPTIONS] [command]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so here's the tea, bestie: the trace-cmd(1) set command sets a configuration parameter of the Ftrace Linux kernel tracer. that's the main character move here ๐Ÿ‘‘

and the fun part? the specified command gets run after the ftrace state is set. so you configure the vibe, then your command hops in and does its thing.

the configured ftrace state can be restored to default using the trace-cmd-reset(1) command โ€” so like, there's a "undo my whole personality" button and it's that one ๐Ÿ”ฅ


๐Ÿ’– OPTIONS ๐Ÿ’–

  • -p tracer โ€” specify a tracer. tracers usually do more than just trace an event, they've got layers okay. the common ones are: function, function_graph, preemptirqsoff, irqsoff, preemptoff and wakeup. a tracer must be supported by the running kernel (rude but true). to see a list of available tracers, see trace-cmd-list(1) โœจ
  • -e event โ€” specify an event to trace. various static trace points have been added to the Linux kernel, grouped by subsystem, where you can enable all events of a given subsystem or specify specific events to be enabled. the event is of the format "subsystem:event-name". you can also just specify the subsystem without the :event-name, or the event-name without the "subsystem:". using -e sched_switch will enable the "sched_switch" event, whereas -e sched will enable all events under the "sched" subsystem ๐ŸŽ€

the event can also contain glob expressions. that is, "*stat*" will select all events (or subsystems) that have the characters "stat" in their names. and the keyword all can be used to enable all events ๐Ÿ‘‘

  • -T โ€” enable a stacktrace on each event. for example:
          <idle>-0     [003] 58549.289091: sched_switch:         kworker/0:1:0 [120] R ==> trace-cmd:2603 [120]
          <idle>-0     [003] 58549.289092: kernel_stack:         <stack trace>
=> schedule (ffffffff814b260e)
=> cpu_idle (ffffffff8100a38c)
=> start_secondary (ffffffff814ab828)
  • --func-stack โ€” enable a stack trace on all functions. heads up bestie, this is only applicable for the "function" plugin tracer, and will only take effect if the -l option is used and succeeds in limiting functions.
โš ๏ธ if the function tracer is not filtered, and the stack trace is enabled, you can live lock the machine. not a cute look. deadass, be careful ๐Ÿ’€
  • -f filter โ€” specify a filter for the previous event. this must come after a -e. it filters what events get recorded based on the content of the event. filtering is passed to the kernel directly so what filtering is allowed may depend on what version of the kernel you have. basically, it lets you use C notation to check if an event should be processed or not ๐Ÿงš

these are usually safe to use to compare fields:

==, >=, <=, >, <, &, |, && and ||
  • -R trigger โ€” specify a trigger for the previous event. this must come after a -e. it adds a given trigger to the given event. if you want to only enable the trigger and not the event itself, then place the event after the -v option ๐ŸŒˆ

see Documentation/trace/events.txt in the Linux kernel source for more information on triggers.

  • -v โ€” this will negate options specified after it on the command line. it affects:
    • -e: causes all specified events to not be traced. this is useful for selecting a subsystem to be traced but to leave out various events. for example: "-e sched -v -e "*stat*"" will enable all events in the sched subsystem except those that have "stat" in their names.
    • -B: deletes the specified ftrace instance. there must be no configuration options related to this instance in the command line. for example: "-v -B bar -B foo" will delete instance bar and create a new instance foo.

note: the -v option was taken from the way grep(1) inverts the following matches. iykyk ๐Ÿ˜Œ

  • -P pid โ€” this will filter only the specified process IDs. using -P will let you trace only events that are caused by the process ๐Ÿ“
  • -c โ€” used with -P to trace the process' children too (if the kernel supports it).
  • --user โ€” execute the specified command as given user.
  • -C clock โ€” set the trace clock to "clock".

use trace-cmd(1) list -C to see what clocks are available โญ

  • -l function-name โ€” this will limit the function and function_graph tracers to only trace the given function name. more than one -l may be specified on the command line to trace more than one function. the limited use of glob expressions is also allowed ๐Ÿ’œ:
    • match* to only filter functions that start with match
    • *match to only filter functions that end with match
    • *match\* to only filter on functions that contain match
  • -g function-name โ€” this option is for the function_graph plugin. it will graph the given function. that is, it will only trace the function and all functions that it calls. you can have more than one -g on the command line ๐Ÿฆ‹
  • -n function-name โ€” this has the opposite effect of -l. the function given with the -n option will not be traced. and it takes precedence โ€” that is, if you include the same function for both -n and -l, it will not be traced. sorry babe, -n wins ๐Ÿ‘‘
  • -d โ€” some tracer plugins enable the function tracer by default. like the latency tracers. this option prevents the function tracer from being enabled at start up ๐Ÿ™ˆ
  • -D โ€” the option -d will try to use the function-trace option to disable the function tracer (if available), otherwise it defaults to the proc file: /proc/sys/kernel/ftrace_enabled, but will not touch it if the function-trace option is available. the -D option will disable both the ftrace_enabled proc file as well as the function-trace option if it exists.
โš ๏ธ note, this disables function tracing for all users, which includes users outside of ftrace tracers (stack_tracer, perf, etc). it's giving "main character energy but it affects everyone in the group chat" ๐Ÿ˜ญ
  • -O option โ€” Ftrace has various options that can be enabled or disabled. this allows you to set them. appending the text no to an option disables it. for example: "-O nograph-time" will disable the "graph-time" Ftrace option โœจ
  • -b size โ€” this sets the ring buffer size to size kilobytes. because the Ftrace ring buffer is per CPU, this size is the size of each per CPU ring buffer inside the kernel. using "-b 10000" on a machine with 4 CPUs will make Ftrace have a total buffer size of 40 Megs ๐Ÿ”ฅ
  • -B buffer-name โ€” if the kernel supports multiple buffers, this will add a buffer with the given name. if the buffer name already exists, that buffer is just reset ๐ŸŽ€

after a buffer name is stated, all events added after that will be associated with that buffer. if no buffer is specified, or an event is specified before a buffer name, it will be associated with the main (toplevel) buffer.

trace-cmd set -e sched -B block -e block -B time -e timer sleep 1

the above will enable all sched events in the main buffer. it will then create a 'block' buffer instance and enable all block events within that buffer. a 'time' buffer instance is created and all timer events will be enabled for that event. literally so organized of them ๐Ÿ’…

  • -m size โ€” the max size in kilobytes that a per cpu buffer should be. note, due to rounding to page size, the number may not be totally correct. also, this is performed by switching between two buffers that are half the given size โ€” thus the output may not be of the given size even if much more was written ๐Ÿ˜ฌ

use this to prevent running out of diskspace for long runs. bestie your disk will thank you ๐Ÿซถ

  • -M cpumask โ€” set the cpumask for to trace. it only affects the last buffer instance given. if supplied before any buffer instance, then it affects the main buffer. the value supplied must be a hex number โญ
trace-cmd set -p function -M c -B events13 -e all -M 5

if the -M is left out, then the mask stays the same. to enable all CPUs, pass in a value of '-1'.

  • -i โ€” by default, if an event is listed that trace-cmd does not find, it will exit with an error. this option will just ignore events that are listed on the command line but are not found on the system. we love a forgiving queen ๐Ÿ™ˆ
  • -q | --quiet โ€” suppresses normal output, except for errors. silence is golden ๐Ÿ’…
  • --max-graph-depth depth โ€” set the maximum depth the function_graph tracer will trace into a function. a value of one will only show where userspace enters the kernel but not any functions called in the kernel. the default is zero, which means no limit ๐ŸŒˆ
  • --cmdlines-size size โ€” set the number of entries the kernel tracing file "saved_cmdlines" can contain. this file is a circular buffer which stores the mapping between cmdlines and PIDs. if full, it leads to unresolved cmdlines ("<...>") within the trace. the kernel default value is 128 ๐Ÿ“
  • --module module โ€” filter a module's name in function tracing. it is equivalent to adding :mod:module after all other functions being filtered. if no other function filter is listed, then all modules functions will be filtered in the filter ๐Ÿงš
    • '--module snd' is equivalent to '-l :mod:snd'
    • '--module snd -l "*jack*"' is equivalent to '-l "*jack*:mod:snd"'
    • '--module snd -n "*"' is equivalent to '-n :mod:snd'
  • --stderr โ€” have output go to stderr instead of stdout, but the output of the command executed will not be changed. this is useful if you want to monitor the output of the command being executed, but not see the output from trace-cmd. separation queen ๐Ÿ‘‘
  • --fork โ€” if a command is listed, then trace-cmd will wait for that command to finish, unless the --fork option is specified. then it will fork the command and return immediately. no waiting around, we're busy ๐Ÿ’…
  • --verbose[=level] โ€” set the log level. supported log levels are "none", "critical", "error", "warning", "info", "debug", "all" or their identifiers "0", "1", "2", "3", "4", "5", "6". setting the log level to specific value enables all logs from that and all previous levels. the level will default to "info" if one is not specified โœจ

example: enable all critical, error and warning logs

trace-cmd set --verbose=warning

๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

enable all events for tracing:

# trace-cmd set -e all

set the function tracer:

# trace-cmd set -p function

๐ŸŒŸ SEE ALSO ๐ŸŒŸ

trace-cmd(1), trace-cmd-report(1), trace-cmd-start(1), trace-cmd-stop(1), trace-cmd-extract(1), trace-cmd-reset(1), trace-cmd-split(1), trace-cmd-list(1), trace-cmd-listen(1), trace-cmd-profile(1)


okay and that's not even the end bestie โ€” there's more coming, don't go anywhere ๐Ÿ’–

๐ŸŒธ AUTHOR ๐ŸŒธ

Ok so this page was written by Tzvetomir Stoyanov (VMware)</> โ€” yes bestie, an actual human, and you can reach him at tz.stoyanov@gmail.com ๐Ÿซถ


๐Ÿฆ‹ RESOURCES ๐Ÿฆ‹

Wanna go stare at the source code like it's a celebrity? It lives right here, no cap:

https://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/

Click it, clone it, obsess over it. It's giving open source main character energy โœจ


๐ŸŽ€ COPYING ๐ŸŽ€

Copyright (C) 2010 Red Hat, Inc. โ€” free use of this software is granted under the terms of the GNU Public License (GPL). ๐Ÿ’…

So yeah, it's free to use, but the GPL is the vibe check you gotta respect fr fr. Read the license, bestie โ€” it's not optional, it's a whole lifestyle.</> ๐Ÿ‘‘


โญ NOTES โญ

  1. tz.stoyanov@gmail.com mailto:tz.stoyanov@gmail.com

That's the footnote from the AUTHOR bit โ€” same email, just clickable this time. iykyk ๐Ÿงš


And that's the whole page, bestie! ๐ŸŽ‰ You ate that. ๐ŸŒˆ

This gem is from libtracefs, dated 03/09/2026, and it's the TRACE-CMD-SET(1) manual page โ€” go forth and set your traces like the icon you are. ๐Ÿ’– โœจ ๐ŸŽ€</>

๐Ÿ“ฆ where this page comes from