'\" t .\" Title: libtracefs .\" Author: [see the "AUTHOR" section] .\" Generator: DocBook XSL Stylesheets vsnapshot .\" Date: 01/13/2024 .\" Manual: libtracefs Manual .\" Source: libtracefs 1.8.0 .\" Language: English .\" .TH "LIBTRACEFS" "3" "01/13/2024" "libtracefs 1\&.8\&.0" "libtracefs Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" tracefs_instance_get_name, tracefs_instance_get_trace_dir, tracefs_instances_walk, tracefs_instance_exists, tracefs_instance_get_buffer_size, tracefs_instance_set_buffer_size, tracefs_instance_get_buffer_percent, tracefs_instance_set_buffer_percent \- Helper functions for working with tracing instances\&. .SH "SYNOPSIS" .sp .nf \fB#include \fR const char *\fBtracefs_instance_get_name\fR(struct tracefs_instance *\fIinstance\fR); const char *\fBtracefs_instance_get_trace_dir\fR(struct tracefs_instance *\fIinstance\fR); int \fBtracefs_instances_walk\fR(int (*\fIcallback\fR)(const char *, void *), void *\fIcontext)\fR; bool \fBtracefs_instance_exists\fR(const char *\fIname\fR); size_t \fBtracefs_instance_get_buffer_size\fR(struct tracefs_instance *\fIinstance\fR, int \fIcpu\fR); int \fBtracefs_instance_set_buffer_size\fR(struct tracefs_instance *\fIinstance\fR, size_t \fIsize\fR, int \fIcpu\fR); int \fBtracefs_instance_get_buffer_percent\fR(struct tracefs_instance *\fIinstance\fR); int \fBtracefs_instance_set_buffer_percent\fR(struct tracefs_instance *\fIinstance\fR, int \fIval\fR); .fi .SH "DESCRIPTION" .sp Helper functions for working with trace instances\&. .sp The \fBtracefs_instance_get_name()\fR function returns the name of the given \fIinstance\fR\&. Note that the top instance has no name, the function returns NULL for it\&. .sp The \fBtracefs_instance_get_trace_dir()\fR function returns the tracing directory, where the given \fIinstance\fR is configured\&. .sp The \fBtracefs_instances_walk()\fR function walks through all configured tracing instances in the system and calls \fIcallback\fR for each one of them\&. The \fIcontext\fR argument is passed to the \fIcallback\fR, together with the instance name\&. If the \fIcallback\fR returns non\-zero, the iteration stops\&. Note, the \fIcallback\fR is not called for the top top instance\&. .sp The \fBtracefs_instance_exists()\fR function checks if an instance with the given \fIname\fR exists in the system\&. .sp The \fBtracefs_instace_get_buffer_size()\fR returns the size of the ring buffer\&. If \fIcpu\fR is negative, it returns the total size of all the per CPU ring buffers, otherwise it returns the size of the per CPU ring buffer for \fIcpu\fR\&. .sp The \fBtracefs_instance_set_buffer_size()\fR function sets the size of the ring buffer\&. If \fIcpu\fR is negative, then it sets all the per CPU ring buffers to \fIsize\fR (note the total size is the number of CPUs * \fIsize\fR)\&. If \fIcpu\fR is specified, then it only sets the size of the per CPU ring buffer\&. .sp The \fBtracefs_instance_set_buffer_percent()\fR sets the buffer percent value of the tracing ring buffer for \fIinstance\fR or the top level buffer if \fIinstance\fR is NULL\&. The buffer percent decides when readers on \fBtracefs_cpu_read\fR(3), \fBtracefs_cpu_buffered_read\fR(3), \fBtracefs_cpu_write\fR(3) and \fBtracefs_cpu_pipe\fR(3) will block when O_NONBLOCK is not set\&. The value of \fIval\fR must be between 0 and 100, where: .sp .if n \{\ .RS 4 .\} .nf 0 \- block until there\(cqs any data in the ring buffer 1 \- block until 1% of the ring buffer sub\-buffers are filled 50 \- block until 50% of the ring buffer sub\-buffers are filled 100 \- block until the entire ring buffer is filled .fi .if n \{\ .RE .\} .sp Note, any number from 0 to 100 can be used where it is the percentage of the ring buffer that must be filled before a blocked reader will be notified that there\(cqs data to be retrieved\&. .sp The \fBtracefs_instance_get_buffer_percent()\fR retrieves the current buffer percent setting of the tracing ring buffer for \fIinstance\fR or the top level buffer if \fIinstance\fR is NULL\&. .SH "RETURN VALUE" .sp The \fBtracefs_instance_get_name()\fR returns a string or NULL in case of the top instance\&. The returned string must \fInot\fR be freed\&. .sp The \fBtracefs_instance_get_trace_dir()\fR returns a string or NULL in case of an error\&. The returned string must \fInot\fR be freed\&. .sp The \fBtracefs_instances_walk()\fR function returns 0, if all instances were iterated, 1 if the iteration was stopped by the \fIcallback\fR, or \-1 in case of an error\&. .sp The \fBtracefs_instance_exists()\fR returns true if an instance with the given \fIname\fR exists in the system or false otherwise\&. .sp The \fBtracefs_instance_get_buffer_size()\fR returns the size of the ring buffer depending on the \fIcpu\fR value passed in, or \-1 on error\&. .sp The \fBtracefs_instance_set_buffer_size()\fR returns zero on success and \-1 on error\&. .SH "EXAMPLE" .sp .if n \{\ .RS 4 .\} .nf #include struct tracefs_instance *inst; \&.\&.\&.\&. char *name = tracefs_instance_get_name(inst); if(name) { /* Got name of the instance */ } char *dir = tracefs_instance_get_trace_dir(inst); if(dir) { /* Got tracing directory of the instance */ } \&.\&.\&. static int instance_walk(char *name, void *context) { /* Got instance with name */ return 0; } \&.\&.\&. if (tracefs_instances_walk(instance_walk, NULL) < 0) { /* Error walking through the instances */ } \&.\&.\&. if (tracefs_instance_exists("foo")) { /* There is instance with name foo in the system */ } else { /* There is no instance with name foo in the system */ } .fi .if n \{\ .RE .\} .SH "FILES" .sp .if n \{\ .RS 4 .\} .nf \fBtracefs\&.h\fR Header file to include in order to have access to the library APIs\&. \fB\-ltracefs\fR Linker switch to add when building a program that uses the library\&. .fi .if n \{\ .RE .\} .SH "SEE ALSO" .sp \fBlibtracefs\fR(3), \fBlibtraceevent\fR(3), \fBtrace\-cmd\fR(1) .SH "AUTHOR" .sp .if n \{\ .RS 4 .\} .nf \fBSteven Rostedt\fR <\m[blue]\fBrostedt@goodmis\&.org\fR\m[]\&\s-2\u[1]\d\s+2> \fBTzvetomir Stoyanov\fR <\m[blue]\fBtz\&.stoyanov@gmail\&.com\fR\m[]\&\s-2\u[2]\d\s+2> .fi .if n \{\ .RE .\} .SH "REPORTING BUGS" .sp Report bugs to <\m[blue]\fBlinux\-trace\-devel@vger\&.kernel\&.org\fR\m[]\&\s-2\u[3]\d\s+2> .SH "LICENSE" .sp libtracefs is Free Software licensed under the GNU LGPL 2\&.1 .SH "RESOURCES" .sp \m[blue]\fBhttps://git\&.kernel\&.org/pub/scm/libs/libtrace/libtracefs\&.git/\fR\m[] .SH "COPYING" .sp Copyright (C) 2020 VMware, Inc\&. Free use of this software is granted under the terms of the GNU Public License (GPL)\&. .SH "NOTES" .IP " 1." 4 rostedt@goodmis.org .RS 4 \%mailto:rostedt@goodmis.org .RE .IP " 2." 4 tz.stoyanov@gmail.com .RS 4 \%mailto:tz.stoyanov@gmail.com .RE .IP " 3." 4 linux-trace-devel@vger.kernel.org .RS 4 \%mailto:linux-trace-devel@vger.kernel.org .RE