• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1libtracefs(3)
2=============
3
4NAME
5----
6tracefs_cpu_open, tracefs_cpu_close, tracefs_cpu_alloc_fd, tracefs_cpu_free_fd, tracefs_cpu_snapshot_open - Opening trace_pipe_raw data for reading
7
8SYNOPSIS
9--------
10[verse]
11--
12*#include <tracefs.h>*
13
14struct tracefs_cpu pass:[*]*tracefs_cpu_open*(struct tracefs_instance pass:[*]_instance_,
15				     int _cpu_, bool _nonblock_);
16void *tracefs_cpu_close*(struct tracefs_cpu pass:[*]_tcpu_);
17
18struct tracefs_cpu pass:[*]*tracefs_cpu_alloc_fd*(int _fd_, int _subbuf_size_, bool _nonblock_);
19void *tracefs_cpu_free_fd*(struct tracefs_cpu pass:[*]_tcpu_);
20
21struct tracefs_cpu pass:[*]*tracefs_cpu_snapshot_open*(struct tracefs_instance pass:[*]_instance_,
22					     int _cpu_, bool _nonblock_);
23--
24
25DESCRIPTION
26-----------
27This set of APIs can be used to open the raw data from the trace_pipe_raw
28files in the tracefs file system in oder to read them with the *tracefs_cpu_read*(3)
29functions.
30
31The *tracefs_cpu_open()* creates a descriptor that can read the tracefs
32trace_pipe_raw file for a given _cpu_ in a given _instance_. If _instance_ is
33NULL than the toplevel trace_pipe_raw file is used.
34
35The *tracefs_cpu_close()* closes all the file descriptors associated to the trace_pipe_raw
36opened by *tracefs_cpu_open()*.
37
38The *tracefs_cpu_alloc_fd()* will create a tracefs_cpu descriptor from an existing
39file descriptor _fd_. This is useful to use when connecting to a socket or pipe where
40the other end is feeding raw tracing data in the same format as the trace_pipe_raw
41file would (like in guest to host tracing). The caller is responsible for determining
42the _subbuf_size_ that will be used to break up the sub-buffers being read by the
43file descriptor. The _nonblock_ is treated the same as the same parameter in
44*tracefs_cpu_open()*.
45
46The *tracefs_cpu_free_fd()* is used to free the descriptor returned by *tracefs_cpu_alloc_fd()*.
47It does all the clean up that *tracefs_cpu_close()* performs, and that could also be
48used to free up the descriptor created by *tracefs_cpu_alloc_fd()* but will also close
49the file descriptor passed in. Note that *tracefs_cpu_free_fd()* should not be used
50on the descriptor returned by *tracefs_cpu_open()* as it will not close the file descriptor
51created by it.
52
53The *tracefs_cpu_snapshot_open()* is similar to *tracefs_cpu_open()* except that it
54opens the snapshot buffer (see *tracefs_snapshot_snap*(3)). The snapshot buffer
55does not have a writer to it, it is only created by a snapshot action that swaps
56the current ring buffer with the snapshot buffer. The _nonblock_, when false, acts a little
57differently here too. Reads are not affected by the "buffer_percent" file. If the
58snapshot buffer is empty, it will block until a new snapshot happens.
59
60RETURN VALUE
61------------
62The *tracefs_cpu_open()* and *tracefs_cpu_snapshot_open() both return a struct
63tracefs_cpu descriptor that can be used by the other functions or NULL on error.
64
65The *tracefs_cpu_alloc_fd()* returns a struct tracefs_cpu descriptor that can
66be used by the *tracefs_cpu_read*(3) related functions, where the descriptor
67will be reading the passed in _fd_ file descriptor.
68
69EXAMPLE
70-------
71See *tracefs_cpu_read*(3) for an example.
72
73FILES
74-----
75[verse]
76--
77*tracefs.h*
78	Header file to include in order to have access to the library APIs.
79*-ltracefs*
80	Linker switch to add when building a program that uses the library.
81--
82
83SEE ALSO
84--------
85*libtracefs*(3),
86*libtraceevent*(3),
87*trace-cmd*(1)
88
89AUTHOR
90------
91[verse]
92--
93*Steven Rostedt* <rostedt@goodmis.org>
94--
95REPORTING BUGS
96--------------
97Report bugs to  <linux-trace-devel@vger.kernel.org>
98
99LICENSE
100-------
101libtracefs is Free Software licensed under the GNU LGPL 2.1
102
103RESOURCES
104---------
105https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/
106
107COPYING
108-------
109Copyright \(C) 2022 Google, Inc. Free use of this software is granted under
110the terms of the GNU Public License (GPL).
111