LIBTRACEEVENT(3)

πŸ’– LIBTRACEEVENT πŸ’–

okay bestie, so this is the libtraceevent manual page, section 3 (that's the library-functions section, iykyk). We're talking about the little crew of functions that pull the common fields out of a trace record: tep_data_type, tep_data_pid, tep_data_preempt_count, and tep_data_flags. Four besties. One job: extract common fields from a record. Slay.


✨ NAME ✨

tep_data_type, tep_data_pid, tep_data_preempt_count, tep_data_flags β€” Extract common fields from a record. That's it, that's the whole vibe. πŸŽ€


🌸 SYNOPSIS 🌸

First thing you gotta do is include the header, no cap:

#include <event-parse.h>

Then there's this enum, right, and it's literally the whole flag menu:

enum trace_flag_type {
        TRACE_FLAG_IRQS_OFF,
        TRACE_FLAG_IRQS_NOSUPPORT,
        TRACE_FLAG_NEED_RESCHED,
        TRACE_FLAG_HARDIRQ,
        TRACE_FLAG_SOFTIRQ,
};

And here come the four functions, same exact shape every time β€” tep handle plus a record, returns an int:

int tep_data_type(struct tep_handle *tep, struct tep_record *rec);
int tep_data_pid(struct tep_handle *tep, struct tep_record *rec);
int tep_data_preempt_count(struct tep_handle *tep, struct tep_record *rec);
int tep_data_flags(struct tep_handle *tep, struct tep_record *rec);

Look at that symmetry. It's giving main character energy. πŸ’…


πŸ”₯ DESCRIPTION πŸ”₯

So this whole set of functions? Its entire purpose is extracting the common fields from a record. That's the assignment and they ate. πŸ“

Quick note on the cast: in all four of these, tep is the trace event parser context. Same tep, every time. She's the main character of this library, honestly.

πŸ¦‹ tep_data_type()

Grabs the event id from the record rec. It reads the "common_type" field. The tep argument is the trace event parser context.

πŸ¦‹ tep_data_pid()

Grabs the process id from the record rec. It reads the "common_pid" field. The tep argument is the trace event parser context.

πŸ¦‹ tep_data_preempt_count()

Grabs the preemption count from the record rec. It reads the "common_preempt_count" field. The tep argument is the trace event parser context.

πŸ¦‹ tep_data_flags()

Grabs the latency flags from the record rec. It reads the "common_flags" field. The tep argument is the trace event parser context.

And the supported latency flags are literally these five, no more no less:

  • TRACE_FLAG_IRQS_OFF β€” Interrupts are disabled.
  • TRACE_FLAG_IRQS_NOSUPPORT β€” Reading IRQ flag is not supported by the architecture.
  • TRACE_FLAG_NEED_RESCHED β€” Task needs rescheduling.
  • TRACE_FLAG_HARDIRQ β€” Hard IRQ is running.
  • TRACE_FLAG_SOFTIRQ β€” Soft IRQ is running.

πŸ’œ RETURN VALUE πŸ’œ

  • tep_data_type() returns an integer, representing the event id.
  • tep_data_pid() returns an integer, representing the process id.
  • tep_data_preempt_count() returns an integer, representing the preemption count.
  • tep_data_flags() returns an integer, representing the latency flags. Look at the trace_flag_type enum for supported flags.
⚠️ IMPORTANT bestie: all these functions, in case of an error, return a negative integer. So please, please check for < 0 before you go treating a vibe-check failure like real data. πŸ™ˆ

⭐ EXAMPLE ⭐

Here's the whole thing in action. Copy it, love it, ship it:

#include <event-parse.h>
...
struct tep_handle *tep = tep_alloc();
...
void process_record(struct tep_record *record)
{
        int data;

        data = tep_data_type(tep, record);
        if (data >= 0) {
                /* Got the ID of the event */
        }

        data = tep_data_pid(tep, record);
        if (data >= 0) {
                /* Got the process ID */
        }

        data = tep_data_preempt_count(tep, record);
        if (data >= 0) {
                /* Got the preemption count */
        }

        data = tep_data_flags(tep, record);
        if (data >= 0) {
                /* Got the latency flags */
        }
}
...

See how every single call gets guarded with data >= 0? That's the self-care. 🫢


🌈 FILES 🌈

  • event-parse.h β€” Header file to include in order to have access to the library APIs.
  • -ltraceevent β€” Linker switch to add when building a program that uses the library.

πŸŽ€ SEE ALSO πŸŽ€


πŸ‘‘ AUTHOR πŸ‘‘

  • Steven Rostedt <rostedt@goodmis.org[1]>, author of libtraceevent.
  • Tzvetomir Stoyanov <tz.stoyanov@gmail.com[2]>, author of this man page.

Legends, both of them. Periodt.


πŸ’€ REPORTING BUGS πŸ’€

Report bugs to <linux-trace-devel@vger.kernel.org[3]>. Don't be shy, they want the bug reports, that's how the library stays iconic. ✨


🧚 LICENSE 🧚

libtraceevent is Free Software licensed under the GNU LGPL 2.1. Free as in freedom, bestie. πŸ¦‹


🌸 RESOURCES 🌸

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

πŸ“ 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

and that's the whole page, bestie πŸ’… this was libtraceevent version 1.9.0, dated 06/15/2026, living its life in section LIBTRACEEVENT(3) of the libtraceevent Manual. Go extract some common fields, you've got this. πŸ«ΆπŸ’–

πŸ“¦ where this page comes from