Movatterモバイル変換


[0]ホーム

URL:


man7.org > Linux >man-pages

Linux/UNIX system programming training


tracefs_cpu_open(3) — Linux manual page

NAME |SYNOPSIS |DESCRIPTION |RETURN VALUE |EXAMPLE |FILES |SEE ALSO |AUTHOR |REPORTING BUGS |LICENSE |RESOURCES |COPYING |NOTES |COLOPHON

LIBTRACEFS(3)               libtracefs ManualLIBTRACEFS(3)

NAME        top

       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

SYNOPSIS        top

#include <tracefs.h>       struct tracefs_cpu *tracefs_cpu_open(struct tracefs_instance *instance,                                            intcpu, boolnonblock);       voidtracefs_cpu_close(struct tracefs_cpu *tcpu);       struct tracefs_cpu *tracefs_cpu_alloc_fd(intfd, intsubbuf_size, boolnonblock);       voidtracefs_cpu_free_fd(struct tracefs_cpu *tcpu);       struct tracefs_cpu *tracefs_cpu_snapshot_open(struct tracefs_instance *instance,                                                    intcpu, boolnonblock);

DESCRIPTION        top

       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 thetracefs_cpu_read(3) functions.       Thetracefs_cpu_open()creates a descriptor that can read the       tracefs trace_pipe_raw file for a givencpu in a giveninstance.       Ifinstance is NULL than the toplevel trace_pipe_raw file is used.       Thetracefs_cpu_close()closes all the file descriptors associated       to the trace_pipe_raw opened bytracefs_cpu_open().       Thetracefs_cpu_alloc_fd()will create a tracefs_cpu descriptor       from an existing file descriptorfd. 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 thesubbuf_size that will be used to break up the       sub-buffers being read by the file descriptor. Thenonblock is       treated the same as the same parameter intracefs_cpu_open().       Thetracefs_cpu_free_fd()is used to free the descriptor returned       bytracefs_cpu_alloc_fd(). It does all the clean up thattracefs_cpu_close()performs, and that could also be used to free       up the descriptor created bytracefs_cpu_alloc_fd()but will also       close the file descriptor passed in. Note thattracefs_cpu_free_fd()should not be used on the descriptor       returned bytracefs_cpu_open()as it will not close the file       descriptor created by it.       Thetracefs_cpu_snapshot_open()is similar totracefs_cpu_open()       except that it opens the snapshot buffer (seetracefs_snapshot_snap(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. Thenonblock,       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.

RETURN VALUE        top

       Thetracefs_cpu_open()and *tracefs_cpu_snapshot_open() both       return a struct tracefs_cpu descriptor that can be used by the       other functions or NULL on error.       Thetracefs_cpu_alloc_fd()returns a struct tracefs_cpu descriptor       that can be used by thetracefs_cpu_read(3) related functions,       where the descriptor will be reading the passed infd file       descriptor.

EXAMPLE        top

       Seetracefs_cpu_read(3) for an example.

FILES        top

tracefs.h                   Header file to include in order to have access to the library APIs.-ltracefs                   Linker switch to add when building a program that uses the library.

SEE ALSO        top

libtracefs(3),libtraceevent(3),trace-cmd(1)

AUTHOR        top

Steven Rostedt<rostedt@goodmis.org[1]>

REPORTING BUGS        top

       Report bugs to <linux-trace-devel@vger.kernel.org[2]>

LICENSE        top

       libtracefs is Free Software licensed under the GNU LGPL 2.1

RESOURCES        top

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

COPYING        top

       Copyright (C) 2022 Google, Inc. Free use of this software is       granted under the terms of the GNU Public License (GPL).

NOTES        top

        1. rostedt@goodmis.org           mailto:rostedt@goodmis.org        2. linux-trace-devel@vger.kernel.org           mailto:linux-trace-devel@vger.kernel.org

COLOPHON        top

       This page is part of thelibtracefs (Linux kernel trace file       system library) project.  Information about the project can be       found at ⟨https://www.trace-cmd.org/⟩.  If you have a bug report       for this manual page, see ⟨https://www.trace-cmd.org/⟩.  This page       was obtained from the project's upstream Git repository       ⟨https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git⟩ on       2025-08-11.  (At that time, the date of the most recent commit       that was found in the repository was 2025-06-02.)  If you discover       any rendering problems in this HTML version of the page, or you       believe there is a better or more up-to-date source for the page,       or you have corrections or improvements to the information in this       COLOPHON (which isnot part of the original manual page), send a       mail to man-pages@man7.orglibtracefs 1.8.1                01/02/2025LIBTRACEFS(3)

Pages that refer to this page:tracefs_cpu_open_mapped(3)tracefs_cpu_read_buf(3)tracefs_cpu_read_size(3)



HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface.

For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere.

Hosting byjambit GmbH.

Cover of TLPI


[8]ページ先頭

©2009-2025 Movatter.jp