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,tepis the trace event parser context. Sametep, 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 thetrace_flag_typeenum 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 π
rostedt@goodmis.orgmailto:rostedt@goodmis.orgtz.stoyanov@gmail.commailto:tz.stoyanov@gmail.comlinux-trace-devel@vger.kernel.orgmailto: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
- ubuntu stonking: libtraceevent-doc 1:1.9.0-2 Β· LGPL-2.1-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms