LIBTRACEFS(3)

🌸 LIBTRACEFS 🌸

okay so this is the libtracefs manual page, and today we're learning about ftrace options β€” getting them, checking them, the whole vibe check. bestie, this is the good stuff. πŸ’…


✨ NAME ✨

tracefs_options_get_supported, tracefs_option_is_supported, tracefs_options_get_enabled, tracefs_option_is_enabled, tracefs_option_mask_is_set, tracefs_option_id β€” literally all the "get and check ftrace options" girlies. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <tracefs.h>

const struct tracefs_options_mask *tracefs_options_get_supported(struct tracefs_instance *instance);
bool tracefs_option_is_supported(struct tracefs_instance *instance, enum tracefs_option_id id);
const struct tracefs_options_mask *tracefs_options_get_enabled(struct tracefs_instance *instance);
bool tracefs_option_is_enabled(struct tracefs_instance *instance, enum tracefs_option_id id);
bool tracefs_option_mask_is_set(const struct tracefs_options_mask options, enum tracefs_option_id id);
enum tracefs_option_id *tracefs_option_id(const char *name);

no cap, that's the whole cast of characters. ⭐


πŸ’– DESCRIPTION πŸ’–

so this little squad of APIs is how you get and check current ftrace options. iconic behaviour. the tea here is that which ftrace options are supported depends on your kernel version and your kernel config β€” so it's not the same everywhere, iykyk. 🫢

the getters and checkers, one by one πŸ‘‘

  • tracefs_options_get_supported() β€” gets all the ftrace options supported by the system in the given instance. if instance is NULL, you get the supported options of the top trace instance instead. heads up: the set of supported options is the same across all created trace instances, but it may be different than the top trace instance. so don't assume, bestie. πŸ’€
  • tracefs_option_is_supported() β€” checks if the option with the given id is supported by the system in the given instance. if instance is NULL, the top trace instance is used. big caveat: if an option is supported at the top trace instance, it may not be supported in a created trace instance. it's giving "different strokes for different instances". πŸ™ˆ
  • tracefs_options_get_enabled() β€” gets all the ftrace options currently enabled in the given instance. if instance is NULL, you get the enabled options of the top trace instance. slay. ✨
  • tracefs_option_is_enabled() β€” checks if the option with the given id is enabled in the given instance. if instance is NULL, the top trace instance is used. simple, clean, main character energy. πŸ’œ
  • tracefs_option_mask_is_set() β€” checks if the bit corresponding to the option with id is set in the options bitmask returned from tracefs_option_get_enabled() and tracefs_option_is_supported(). mask moment. 🎭
  • tracefs_option_id() β€” converts an option name into its corresponding id, if it's found. this is literally the glow-up translator: if you only know the name, this lets you find the option id to use in all the other functions. obsessed. 🧚

πŸ”₯ RETURN VALUE πŸ”₯

  • tracefs_options_get_supported() and tracefs_options_get_enabled() β€” on success, return a pointer to the bitmask within the instance, or a global bitmask for the top level, or NULL in case of an error. ⚠️ and listen: the returned bitmask is part of the instance structure (or a global variable) and must NOT be freed or modified. do not touch. do not free. not your bitmask, not your business. πŸ’€
  • tracefs_option_is_supported() and tracefs_option_is_enabled() β€” return true if the option is supported / enabled, or false otherwise.
  • tracefs_option_mask_is_set() β€” returns true if the corresponding option is set in the mask, or false otherwise.
  • tracefs_option_id() β€” returns the corresponding id defined by tracefs_options(3) from the given name. if the name can not be found, TRACEFS_OPTION_INVALID is returned. sad girl hours. 😭

🌈 EXAMPLE 🌈

#include <tracefs.h>
...
const struct tracefs_options_mask *options;
...
options = tracefs_options_get_supported(NULL);
if (!options) {
        /* Failed to get supported options */
} else {
        ...
}
...
options = tracefs_options_get_enabled(NULL);
if (!options) {
        /* Failed to get options, enabled in the top instance */
} else {
        ...
}
if (tracefs_options_mask_is_set(options, TRACEFS_OPTION_LATENCY_FORMAT)) {
        ...
}
...

if (tracefs_option_is_supported(NULL, TRACEFS_OPTION_LATENCY_FORMAT)) {
        /* Latency format option is supprted */
}

...

if (tracefs_option_is_enabled(NULL, TRACEFS_OPTION_STACKTRACE)) {
        /* Stacktrace option is enabled in the top instance */
}

fr fr just copy this pattern and you're golden. πŸ†


πŸ“ FILES πŸ“

  • tracefs.h β€” the header file to include in order to have access to the library APIs. yes you actually have to include it bestie. πŸŽ€
  • -ltracefs β€” the linker switch to add when building a program that uses the library. don't forget it or you'll be crying at link errors. 😭

⭐ SEE ALSO ⭐

libtracefs(3), libtraceevent(3), trace-cmd(1)

the whole friend group. go read them too. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

  • Steven Rostedt <rostedt@goodmis.org[1]>
  • Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>

legends, honestly.


πŸ’… REPORTING BUGS πŸ’…

spotted something sus? Report bugs to <linux-trace-devel@vger.kernel.org[3]> β€” they want to hear it, ngl.


🌸 LICENSE 🌸

libtracefs is Free Software licensed under the GNU LGPL 2.1. periodt.


πŸ¦‹ RESOURCES πŸ¦‹

https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/

go lurk the repo, it's giving open source excellence. ✨


πŸŽ€ COPYING πŸŽ€

Copyright (C) 2020 VMware, Inc. Free use of this software is granted under the terms of the GNU Public License (GPL).


πŸ’œ NOTES πŸ’œ

  1. rostedt@goodmis.org mailto:rostedt@goodmis.org
  2. tz.stoyanov@gmail.com mailto:tz.stoyanov@gmail.com
  3. linux-trace-devel@vger.kernel.org mailto:linux-trace-devel@vger.kernel.org

aaaand that's the page! πŸ’– this was libtracefs 1.8.4, dated 10/21/2026 β€” screenshot it, bookmark it, tell your friends. bye bestie, go check some options! πŸ¦‹πŸ’…βœ¨

πŸ“¦ where this page comes from