libtracefs(3)

# libtracefs(3) Manual Page

## NAME

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

## SYNOPSIS

    #include <tracefs.h>

    char ** tracefs_instance_tracers(struct tracefs_instance *instance);
    int tracefs_tracer_set(struct tracefs_instance *instance, enum tracefs_tracers tracer);
    int tracefs_tracer_set(struct tracefs_instance *instance, enum tracefs_tracers tracer, const char *name);
    int tracefs_tracer_clear(struct tracefs_instance *instance);

## DESCRIPTION

tracefs_instance_tracers will return a list of available tracers for a given instance (note, an instance may not have the same set of available tracers as the top level). If instance is NULL, then the list of available tracers returned will be for the top level.

tracefs_tracer_set enables a tracer in the given instance, defined by the instance parameter. If instance is NULL, then the top level instance is changed. If tracer is set to TRACFES_TRACER_CUSTOM then a name 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_clear disables the tracer for the given instance defined by the instance variable, or the top level instance if it is NULL. This is the same as calling tracefs_tracer_set with TRACEFS_TRACER_NOP as the tracer parameter.

## TRACEFS_TRACER ENUMS

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 and tracefs_tracer_set() will return an error with errno set to ENODEV, if the kernel does not support the tracer option, or the custom one if TRACEFS_TRACER_CUSTOM is used.

## RETURN VALUE

Returns 0 on success, or -1 on error.

## ERRORS

tracefs_tracer_set() can fail with the following errors:

EINVAL The tracer parameter is outside the scope of what is defined.

ENOMEM Memory allocation error.

ENOENT Tracers are not supported on the running kernel.

ENODEV The specified tracer is not supported on the running kernel.

Other errors may also happen caused by internal system calls.

## EXAMPLE

## FILES

    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

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

## AUTHOR

    Steven Rostedt <rostedt@goodmis.org>
    Tzvetomir Stoyanov <tz.stoyanov@gmail.com>
    sameeruddin shaik <sameeruddin.shaik8@gmail.com>

## REPORTING BUGS

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

## LICENSE

libtracefs is Free Software licensed under the GNU LGPL 2.1

## RESOURCES

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

## COPYING

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