Movatterモバイル変換


[0]ホーム

URL:


man7.org > Linux >man-pages

Linux/UNIX system programming training


tracefs_instance_tracers(3) — Linux manual page

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

LIBTRACEFS(3)               libtracefs ManualLIBTRACEFS(3)

NAME        top

       tracefs_instance_tracers, tracefs_tracer_set, tracefs_tracer_clear       - Enable or disable a tracer in an instance or the top level

SYNOPSIS        top

#include <tracefs.h>       char **tracefs_instance_tracers(struct tracefs_instance *instance);       inttracefs_tracer_set(struct tracefs_instance *instance, enum tracefs_tracerstracer);       inttracefs_tracer_set(struct tracefs_instance *instance, enum tracefs_tracerstracer, const char *name);       inttracefs_tracer_clear(struct tracefs_instance *instance);

DESCRIPTION        top

tracefs_instance_tracerswill return a list of available tracers       for a giveninstance (note, an instance may not have the same set       of available tracers as the top level). Ifinstance is NULL, then       the list of available tracers returned will be for the top level.tracefs_tracer_setenables a tracer in the given instance, defined       by theinstance parameter. Ifinstance is NULL, then the top level       instance is changed. Iftracer is set toTRACFES_TRACER_CUSTOM       then aname string must be passed in as the third parameter, and       that is written into the instance to enable the tracer with that       name. This is useful for newer or custom kernels that contain       tracers that are not yet identified by the tracefs_tracers enum.tracefs_tracer_cleardisables the tracer for the given instance       defined by theinstance variable, or the top level instance if it       is NULL. This is the same as callingtracefs_tracer_setwith       TRACEFS_TRACER_NOP as thetracer parameter.

TRACEFS_TRACER ENUMS        top

       The currently defined enums that are accepted are:TRACEFS_TRACER_NOP: This is the idle tracer, which does nothing       and is used to clear any active tracer.TRACEFS_TRACER_FUNCTION: Enables most functions in the kernel to       be traced.TRACEFS_TRACER_FUNCTION_GRAPH: Enables most functions in the       kernel to be traced as well as the return of the function.TRACEFS_TRACER_IRQSOFF: Tracers the latency of interrupts       disabled.TRACEFS_TRACER_PREEMPTOFF: Tracers the latency of preemption       disabled (the time in the kernel that tasks can not be scheduled       from the CPU).TRACEFS_TRACER_PREEMPTIRQSOFF: Traces the combined total latency       of when interrupts are disabled as well as when preemption is       disabled.TRACEFS_TRACER_WAKEUP: Traces the latency of when the highest       priority task takes to wake up.TRACEFS_TRACER_WAKEUP_RT: Traces the latency of when the highest       priority real-time task takes to wake up. All other tasks are       ignored.TRACEFS_TRACER_WAKEUP_DL: Traces the latency of when the highest       priority DEADLINE task takes to wake up. All other tasks are       ignored.TRACEFS_TRACER_MMIOTRACE: Traces the interaction of devices with       the kernel.TRACEFS_TRACER_HWLAT: Detects latency caused by the hardware that       is outside the scope of the kernel.TRACEFS_TRACER_BRANCH: Traces when likely or unlikely branches       are taken.TRACEFS_TRACER_BLOCK: Special tracer for the block devices.       Note that the above tracers may not be available in the kernel andtracefs_tracer_set()will return an error with errno set to       ENODEV, if the kernel does not support thetracer option, or the       custom one if TRACEFS_TRACER_CUSTOM is used.

RETURN VALUE        top

       Returns 0 on success, or -1 on error.

ERRORS        top

tracefs_tracer_set() can fail with the following errors:EINVALThetracer parameter is outside the scope of what is       defined.ENOMEMMemory allocation error.ENOENTTracers are not supported on the running kernel.ENODEVThe specified tracer is not supported on the running       kernel.       Other errors may also happen caused by internal system calls.

EXAMPLE        top

           #include <stdlib.h>           #include <stdio.h>           #include <getopt.h>           #include <errno.h>           #include <tracefs.h>           int main(int argc, char *argv[])           {                   struct tracefs_instance *inst = NULL;                   enum tracefs_tracers t = TRACEFS_TRACER_NOP;                   const char *cust = NULL;                   const char *buf = NULL;                   char **tracers;                   int ret;                   int ch;                   int i;                   while ((ch = getopt(argc, argv, "nfgiwdc:B:")) > 0) {                           switch (ch) {                           case 'f': t = TRACEFS_TRACER_FUNCTION; break;                           case 'g': t = TRACEFS_TRACER_FUNCTION_GRAPH; break;                           case 'i': t = TRACEFS_TRACER_PREEMPTIRQSOFF; break;                           case 'w': t = TRACEFS_TRACER_WAKEUP_RT; break;                           case 'd': t = TRACEFS_TRACER_WAKEUP_DL; break;                           case 'c':                                   t = TRACEFS_TRACER_CUSTOM;                                   cust = optarg;                                   break;                           case 'B':                                   buf = optarg;                                   break;                           case 'n':                                   /* nop */                                   break;                           default:                                   printf("Unknow arg %c\n", ch);                                   exit(-1);                           }                   }                   if (buf) {                           inst = tracefs_instance_create(buf);                           if (!inst) {                                   printf("failed to create instance\n");                                   exit(-1);                           }                   }                   if (t == TRACEFS_TRACER_CUSTOM)                           ret = tracefs_tracer_set(inst, t, cust);                   else                           ret = tracefs_tracer_set(inst, t);                   if (ret < 0) {                           if (errno == ENODEV) {                                   if (cust)                                           printf("Tracer '%s' not supported by kernel\n", cust);                                   else                                           printf("Tracer not supported by kernel\n");                                   tracers = tracefs_instance_tracers(inst);                                   printf("Available tracers:");                                   for (i = 0; tracers && tracers[i]; i++)                                           printf(" %s", tracers[i]);                                   tracefs_list_free(tracers);                                   printf("\n");                           } else                                   perror("Error");                           if (inst) {                                   tracefs_instance_destroy(inst);                                   tracefs_instance_free(inst);                           }                           exit(-1);                   }                   tracefs_instance_free(inst);                   exit(0);           }

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]>Tzvetomir Stoyanov<tz.stoyanov@gmail.com[2]>sameeruddin shaik<sameeruddin.shaik8@gmail.com[3]>

REPORTING BUGS        top

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

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) 2020 VMware, 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. tz.stoyanov@gmail.com           mailto:tz.stoyanov@gmail.com        3. sameeruddin.shaik8@gmail.com           mailto:sameeruddin.shaik8@gmail.com        4. 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.7.0                12/22/2023LIBTRACEFS(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