'\" 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_cpu_open, tracefs_cpu_close, tracefs_cpu_alloc_fd, tracefs_cpu_free_fd, tracefs_cpu_snapshot_open \- Opening trace_pipe_raw data for reading .SH "SYNOPSIS" .sp .nf \fB#include \fR struct tracefs_cpu *\fBtracefs_cpu_open\fR(struct tracefs_instance *\fIinstance\fR, int \fIcpu\fR, bool \fInonblock\fR); void \fBtracefs_cpu_close\fR(struct tracefs_cpu *\fItcpu\fR); struct tracefs_cpu *\fBtracefs_cpu_alloc_fd\fR(int \fIfd\fR, int \fIsubbuf_size\fR, bool \fInonblock\fR); void \fBtracefs_cpu_free_fd\fR(struct tracefs_cpu *\fItcpu\fR); struct tracefs_cpu *\fBtracefs_cpu_snapshot_open\fR(struct tracefs_instance *\fIinstance\fR, int \fIcpu\fR, bool \fInonblock\fR); .fi .SH "DESCRIPTION" .sp This set of APIs can be used to open the raw data from the trace_pipe_raw files in the tracefs file system in oder to read them with the \fBtracefs_cpu_read\fR(3) functions\&. .sp The \fBtracefs_cpu_open()\fR creates a descriptor that can read the tracefs trace_pipe_raw file for a given \fIcpu\fR in a given \fIinstance\fR\&. If \fIinstance\fR is NULL than the toplevel trace_pipe_raw file is used\&. .sp The \fBtracefs_cpu_close()\fR closes all the file descriptors associated to the trace_pipe_raw opened by \fBtracefs_cpu_open()\fR\&. .sp The \fBtracefs_cpu_alloc_fd()\fR will create a tracefs_cpu descriptor from an existing file descriptor \fIfd\fR\&. This is useful to use when connecting to a socket or pipe where the other end is feeding raw tracing data in the same format as the trace_pipe_raw file would (like in guest to host tracing)\&. The caller is responsible for determining the \fIsubbuf_size\fR that will be used to break up the sub\-buffers being read by the file descriptor\&. The \fInonblock\fR is treated the same as the same parameter in \fBtracefs_cpu_open()\fR\&. .sp The \fBtracefs_cpu_free_fd()\fR is used to free the descriptor returned by \fBtracefs_cpu_alloc_fd()\fR\&. It does all the clean up that \fBtracefs_cpu_close()\fR performs, and that could also be used to free up the descriptor created by \fBtracefs_cpu_alloc_fd()\fR but will also close the file descriptor passed in\&. Note that \fBtracefs_cpu_free_fd()\fR should not be used on the descriptor returned by \fBtracefs_cpu_open()\fR as it will not close the file descriptor created by it\&. .sp The \fBtracefs_cpu_snapshot_open()\fR is similar to \fBtracefs_cpu_open()\fR except that it opens the snapshot buffer (see \fBtracefs_snapshot_snap\fR(3))\&. The snapshot buffer does not have a writer to it, it is only created by a snapshot action that swaps the current ring buffer with the snapshot buffer\&. The \fInonblock\fR, when false, acts a little differently here too\&. Reads are not affected by the "buffer_percent" file\&. If the snapshot buffer is empty, it will block until a new snapshot happens\&. .SH "RETURN VALUE" .sp The \fBtracefs_cpu_open()\fR and *tracefs_cpu_snapshot_open() both return a struct tracefs_cpu descriptor that can be used by the other functions or NULL on error\&. .sp The \fBtracefs_cpu_alloc_fd()\fR returns a struct tracefs_cpu descriptor that can be used by the \fBtracefs_cpu_read\fR(3) related functions, where the descriptor will be reading the passed in \fIfd\fR file descriptor\&. .SH "EXAMPLE" .sp See \fBtracefs_cpu_read\fR(3) for an example\&. .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> .fi .if n \{\ .RE .\} .SH "REPORTING BUGS" .sp Report bugs to <\m[blue]\fBlinux\-trace\-devel@vger\&.kernel\&.org\fR\m[]\&\s-2\u[2]\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) 2022 Google, 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 linux-trace-devel@vger.kernel.org .RS 4 \%mailto:linux-trace-devel@vger.kernel.org .RE