Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
trace.c File Reference
#include <linux/ring_buffer.h>
#include <generated/utsrelease.h>
#include <linux/stacktrace.h>
#include <linux/writeback.h>
#include <linux/kallsyms.h>
#include <linux/seq_file.h>
#include <linux/notifier.h>
#include <linux/irqflags.h>
#include <linux/debugfs.h>
#include <linux/pagemap.h>
#include <linux/hardirq.h>
#include <linux/linkage.h>
#include <linux/uaccess.h>
#include <linux/kprobes.h>
#include <linux/ftrace.h>
#include <linux/module.h>
#include <linux/percpu.h>
#include <linux/splice.h>
#include <linux/kdebug.h>
#include <linux/string.h>
#include <linux/rwsem.h>
#include <linux/slab.h>
#include <linux/ctype.h>
#include <linux/init.h>
#include <linux/poll.h>
#include <linux/nmi.h>
#include <linux/fs.h>
#include "trace.h"
#include "trace_output.h"

Go to the source code of this file.

Data Structures

struct  trace_buffer_struct
 
struct  ftrace_entries_info
 
struct  ftrace_buffer_info
 
struct  buffer_ref
 
struct  trace_option_dentry
 

Macros

#define MAX_TRACER_SIZE   100
 
#define TRACE_BUF_SIZE_DEFAULT   1441792UL /* 16384 * 88 (sizeof(entry)) */
 
#define SAVED_CMDLINES   128
 
#define NO_CMDLINE_MAP   UINT_MAX
 
#define TRACE_MAX_PRINT   1000
 
#define KERN_TRACE   KERN_EMERG
 

Functions

 DEFINE_PER_CPU (int, ftrace_cpu_disabled)
 
 __setup ("ftrace=", set_cmdline_ftrace)
 
 __setup ("ftrace_dump_on_oops", set_ftrace_dump_on_oops)
 
unsigned long long ns2usecs (cycle_t nsec)
 
int filter_current_check_discard (struct ring_buffer *buffer, struct ftrace_event_call *call, void *rec, struct ring_buffer_event *event)
 
 EXPORT_SYMBOL_GPL (filter_current_check_discard)
 
cycle_t ftrace_now (int cpu)
 
int tracing_is_enabled (void)
 
void tracing_on (void)
 
 EXPORT_SYMBOL_GPL (tracing_on)
 
void tracing_off (void)
 
 EXPORT_SYMBOL_GPL (tracing_off)
 
int tracing_is_on (void)
 
 EXPORT_SYMBOL_GPL (tracing_is_on)
 
void trace_wake_up (void)
 
unsigned long nsecs_to_usecs (unsigned long nsecs)
 
int trace_parser_get_init (struct trace_parser *parser, int size)
 
void trace_parser_put (struct trace_parser *parser)
 
int trace_get_user (struct trace_parser *parser, const char __user *ubuf, size_t cnt, loff_t *ppos)
 
ssize_t trace_seq_to_user (struct trace_seq *s, char __user *ubuf, size_t cnt)
 
int register_tracer (struct tracer *type)
 
void unregister_tracer (struct tracer *type)
 
void tracing_reset (struct trace_array *tr, int cpu)
 
void tracing_reset_online_cpus (struct trace_array *tr)
 
void tracing_reset_current (int cpu)
 
void tracing_reset_current_online_cpus (void)
 
int is_tracing_stopped (void)
 
void ftrace_off_permanent (void)
 
void tracing_start (void)
 
void tracing_stop (void)
 
void trace_stop_cmdline_recording (void)
 
void trace_find_cmdline (int pid, char comm[])
 
void tracing_record_cmdline (struct task_struct *tsk)
 
void tracing_generic_entry_update (struct trace_entry *entry, unsigned long flags, int pc)
 
 EXPORT_SYMBOL_GPL (tracing_generic_entry_update)
 
struct ring_buffer_eventtrace_buffer_lock_reserve (struct ring_buffer *buffer, int type, unsigned long len, unsigned long flags, int pc)
 
void trace_buffer_unlock_commit (struct ring_buffer *buffer, struct ring_buffer_event *event, unsigned long flags, int pc)
 
struct ring_buffer_eventtrace_current_buffer_lock_reserve (struct ring_buffer **current_rb, int type, unsigned long len, unsigned long flags, int pc)
 
 EXPORT_SYMBOL_GPL (trace_current_buffer_lock_reserve)
 
void trace_current_buffer_unlock_commit (struct ring_buffer *buffer, struct ring_buffer_event *event, unsigned long flags, int pc)
 
 EXPORT_SYMBOL_GPL (trace_current_buffer_unlock_commit)
 
void trace_nowake_buffer_unlock_commit (struct ring_buffer *buffer, struct ring_buffer_event *event, unsigned long flags, int pc)
 
 EXPORT_SYMBOL_GPL (trace_nowake_buffer_unlock_commit)
 
void trace_nowake_buffer_unlock_commit_regs (struct ring_buffer *buffer, struct ring_buffer_event *event, unsigned long flags, int pc, struct pt_regs *regs)
 
 EXPORT_SYMBOL_GPL (trace_nowake_buffer_unlock_commit_regs)
 
void trace_current_buffer_discard_commit (struct ring_buffer *buffer, struct ring_buffer_event *event)
 
 EXPORT_SYMBOL_GPL (trace_current_buffer_discard_commit)
 
void trace_function (struct trace_array *tr, unsigned long ip, unsigned long parent_ip, unsigned long flags, int pc)
 
void ftrace (struct trace_array *tr, struct trace_array_cpu *data, unsigned long ip, unsigned long parent_ip, unsigned long flags, int pc)
 
void trace_printk_init_buffers (void)
 
int trace_vbprintk (unsigned long ip, const char *fmt, va_list args)
 
 EXPORT_SYMBOL_GPL (trace_vbprintk)
 
int trace_array_printk (struct trace_array *tr, unsigned long ip, const char *fmt,...)
 
int trace_array_vprintk (struct trace_array *tr, unsigned long ip, const char *fmt, va_list args)
 
int trace_vprintk (unsigned long ip, const char *fmt, va_list args)
 
 EXPORT_SYMBOL_GPL (trace_vprintk)
 
struct trace_entrytrace_find_next_entry (struct trace_iterator *iter, int *ent_cpu, u64 *ent_ts)
 
voidtrace_find_next_entry_inc (struct trace_iterator *iter)
 
void tracing_iter_reset (struct trace_iterator *iter, int cpu)
 
void print_trace_header (struct seq_file *m, struct trace_iterator *iter)
 
enum print_line_t print_trace_line (struct trace_iterator *iter)
 
void trace_latency_header (struct seq_file *m)
 
void trace_default_header (struct seq_file *m)
 
int tracing_open_generic (struct inode *inode, struct file *filp)
 
int tracer_init (struct tracer *t, struct trace_array *tr)
 
int tracing_update_buffers (void)
 
void default_wait_pipe (struct trace_iterator *iter)
 
void poll_wait_pipe (struct trace_iterator *iter)
 
struct dentrytracing_init_dentry (void)
 
struct dentrytracing_dentry_percpu (void)
 
struct dentrytrace_create_file (const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops)
 
void trace_printk_seq (struct trace_seq *s)
 
void trace_init_global_iter (struct trace_iterator *iter)
 
void ftrace_dump (enum ftrace_dump_mode oops_dump_mode)
 
 EXPORT_SYMBOL_GPL (ftrace_dump)
 
 early_initcall (tracer_alloc_buffers)
 
 fs_initcall (tracer_init_debugfs)
 
 late_initcall (clear_boot_tracer)
 
: the name chosen to select it on the available_tracers file

struct tracer - a specific tracer and its callbacks to interact with debugfs

: called when one switches to this tracer (echo name > current_tracer) : called when one switches to another tracer : called when tracing is unpaused (echo 1 > tracing_enabled) : called when tracing is paused (echo 0 > tracing_enabled) : called when the trace file is opened : called when the trace_pipe file is opened : override how the user waits for traces on trace_pipe : called when the trace file is released : called when the trace_pipe file is released : override the default read callback on trace_pipe : override the default splice_read callback on trace_pipe : selftest to run on boot (see trace_selftest.c) : override the first lines that describe your columns : callback that prints a trace : signals one of your private flags changed (trace_options file) : your private flags

int trace_empty (struct trace_iterator *iter)
 

Variables

int ring_buffer_expanded
 
bool __read_mostly tracing_selftest_disabled
 
cpumask_var_t __read_mostly tracing_buffer_mask
 
enum ftrace_dump_mode ftrace_dump_on_oops
 
unsigned long trace_flags
 
int trace_clock_id
 
unsigned long __read_mostly tracing_thresh
 

Macro Definition Documentation

#define KERN_TRACE   KERN_EMERG

Definition at line 4929 of file trace.c.

#define MAX_TRACER_SIZE   100

Definition at line 112 of file trace.c.

#define NO_CMDLINE_MAP   UINT_MAX

Definition at line 946 of file trace.c.

#define SAVED_CMDLINES   128

Definition at line 945 of file trace.c.

#define TRACE_BUF_SIZE_DEFAULT   1441792UL /* 16384 * 88 (sizeof(entry)) */

Definition at line 227 of file trace.c.

#define TRACE_MAX_PRINT   1000

Definition at line 4922 of file trace.c.

Function Documentation

__setup ( )
__setup ( "ftrace_dump_on_oops"  ,
set_ftrace_dump_on_oops   
)
void default_wait_pipe ( struct trace_iterator iter)

Definition at line 3389 of file trace.c.

DEFINE_PER_CPU ( int  ,
ftrace_cpu_disabled   
)
early_initcall ( tracer_alloc_buffers  )
EXPORT_SYMBOL_GPL ( filter_current_check_discard  )
EXPORT_SYMBOL_GPL ( tracing_on  )
EXPORT_SYMBOL_GPL ( tracing_off  )
EXPORT_SYMBOL_GPL ( tracing_is_on  )
EXPORT_SYMBOL_GPL ( tracing_generic_entry_update  )
EXPORT_SYMBOL_GPL ( trace_current_buffer_lock_reserve  )
EXPORT_SYMBOL_GPL ( trace_current_buffer_unlock_commit  )
EXPORT_SYMBOL_GPL ( trace_nowake_buffer_unlock_commit  )
EXPORT_SYMBOL_GPL ( trace_nowake_buffer_unlock_commit_regs  )
EXPORT_SYMBOL_GPL ( trace_current_buffer_discard_commit  )
EXPORT_SYMBOL_GPL ( trace_vbprintk  )
EXPORT_SYMBOL_GPL ( trace_vprintk  )
EXPORT_SYMBOL_GPL ( ftrace_dump  )
int filter_current_check_discard ( struct ring_buffer buffer,
struct ftrace_event_call call,
void rec,
struct ring_buffer_event event 
)

Definition at line 165 of file trace.c.

fs_initcall ( tracer_init_debugfs  )
void ftrace ( struct trace_array tr,
struct trace_array_cpu data,
unsigned long  ip,
unsigned long  parent_ip,
unsigned long  flags,
int  pc 
)

Definition at line 1276 of file trace.c.

void ftrace_dump ( enum ftrace_dump_mode  oops_dump_mode)

Definition at line 5070 of file trace.c.

cycle_t ftrace_now ( int  cpu)

Definition at line 173 of file trace.c.

void ftrace_off_permanent ( void  )

ftrace_off_permanent - disable all ftrace code permanently

This should only be called when a serious anomally has been detected. This will turn off the function tracing, ring buffers, and other tracing utilites. It takes no locks and can be called from any context.

Definition at line 976 of file trace.c.

int is_tracing_stopped ( void  )

Definition at line 963 of file trace.c.

late_initcall ( clear_boot_tracer  )
unsigned long long ns2usecs ( cycle_t  nsec)

Definition at line 142 of file trace.c.

unsigned long nsecs_to_usecs ( unsigned long  nsecs)

Definition at line 442 of file trace.c.

void poll_wait_pipe ( struct trace_iterator iter)

Definition at line 3413 of file trace.c.

void print_trace_header ( struct seq_file m,
struct trace_iterator iter 
)

Definition at line 2020 of file trace.c.

enum print_line_t print_trace_line ( struct trace_iterator iter)

Definition at line 2246 of file trace.c.

int register_tracer ( struct tracer type)

register_tracer - register a tracer with the ftrace system. - the plugin for the tracer

Register a new plugin tracer.

Definition at line 766 of file trace.c.

int trace_array_printk ( struct trace_array tr,
unsigned long  ip,
const char fmt,
  ... 
)

Definition at line 1637 of file trace.c.

int trace_array_vprintk ( struct trace_array tr,
unsigned long  ip,
const char fmt,
va_list  args 
)

Definition at line 1652 of file trace.c.

struct ring_buffer_event* trace_buffer_lock_reserve ( struct ring_buffer buffer,
int  type,
unsigned long  len,
unsigned long  flags,
int  pc 
)
read

Definition at line 1163 of file trace.c.

void trace_buffer_unlock_commit ( struct ring_buffer buffer,
struct ring_buffer_event event,
unsigned long  flags,
int  pc 
)

Definition at line 1196 of file trace.c.

struct dentry* trace_create_file ( const char name,
umode_t  mode,
struct dentry parent,
void data,
const struct file_operations fops 
)
read

Definition at line 4628 of file trace.c.

void trace_current_buffer_discard_commit ( struct ring_buffer buffer,
struct ring_buffer_event event 
)

Definition at line 1242 of file trace.c.

struct ring_buffer_event* trace_current_buffer_lock_reserve ( struct ring_buffer **  current_rb,
int  type,
unsigned long  len,
unsigned long  flags,
int  pc 
)
read

Definition at line 1204 of file trace.c.

void trace_current_buffer_unlock_commit ( struct ring_buffer buffer,
struct ring_buffer_event event,
unsigned long  flags,
int  pc 
)

Definition at line 1214 of file trace.c.

void trace_default_header ( struct seq_file m)

Definition at line 2298 of file trace.c.

int trace_empty ( struct trace_iterator iter)

Definition at line 2212 of file trace.c.

void trace_find_cmdline ( int  pid,
char  comm[] 
)

Definition at line 1101 of file trace.c.

struct trace_entry* trace_find_next_entry ( struct trace_iterator iter,
int ent_cpu,
u64 ent_ts 
)
read

Definition at line 1803 of file trace.c.

void* trace_find_next_entry_inc ( struct trace_iterator iter)

Definition at line 1810 of file trace.c.

void trace_function ( struct trace_array tr,
unsigned long  ip,
unsigned long  parent_ip,
unsigned long  flags,
int  pc 
)

Definition at line 1250 of file trace.c.

int trace_get_user ( struct trace_parser parser,
const char __user ubuf,
size_t  cnt,
loff_t *  ppos 
)

Definition at line 522 of file trace.c.

void trace_init_global_iter ( struct trace_iterator iter)

Definition at line 4946 of file trace.c.

void trace_latency_header ( struct seq_file m)

Definition at line 2283 of file trace.c.

void trace_nowake_buffer_unlock_commit ( struct ring_buffer buffer,
struct ring_buffer_event event,
unsigned long  flags,
int  pc 
)

Definition at line 1222 of file trace.c.

void trace_nowake_buffer_unlock_commit_regs ( struct ring_buffer buffer,
struct ring_buffer_event event,
unsigned long  flags,
int  pc,
struct pt_regs regs 
)

Definition at line 1230 of file trace.c.

int trace_parser_get_init ( struct trace_parser parser,
int  size 
)

Definition at line 491 of file trace.c.

void trace_parser_put ( struct trace_parser parser)

Definition at line 506 of file trace.c.

void trace_printk_init_buffers ( void  )

Definition at line 1562 of file trace.c.

void trace_printk_seq ( struct trace_seq s)

Definition at line 4932 of file trace.c.

ssize_t trace_seq_to_user ( struct trace_seq s,
char __user ubuf,
size_t  cnt 
)

Definition at line 594 of file trace.c.

void trace_stop_cmdline_recording ( void  )
int trace_vbprintk ( unsigned long  ip,
const char fmt,
va_list  args 
)

trace_vbprintk - write binary msg to tracing buffer

Definition at line 1581 of file trace.c.

int trace_vprintk ( unsigned long  ip,
const char fmt,
va_list  args 
)

Definition at line 1706 of file trace.c.

void trace_wake_up ( void  )

trace_wake_up - wake up tasks waiting for trace input

Schedules a delayed work to wake up any task that is blocked on the trace_wait queue. These is used with trace_poll for tasks polling the trace.

Definition at line 403 of file trace.c.

int tracer_init ( struct tracer t,
struct trace_array tr 
)

Definition at line 3009 of file trace.c.

struct dentry* tracing_dentry_percpu ( void  )
read

Definition at line 4464 of file trace.c.

void tracing_generic_entry_update ( struct trace_entry entry,
unsigned long  flags,
int  pc 
)

Definition at line 1142 of file trace.c.

struct dentry* tracing_init_dentry ( void  )
read

Definition at line 4441 of file trace.c.

int tracing_is_enabled ( void  )

tracing_is_enabled - return tracer_enabled status

This function is used by other tracers to know the status of the tracer_enabled flag. Tracers may use this function to know if it should enable their features when starting up. See irqsoff tracer for an example (start_irqsoff_tracer).

Definition at line 212 of file trace.c.

int tracing_is_on ( void  )

tracing_is_on - show state of ring buffers enabled

Definition at line 388 of file trace.c.

void tracing_iter_reset ( struct trace_iterator iter,
int  cpu 
)

Definition at line 1854 of file trace.c.

void tracing_off ( void  )

tracing_off - turn off tracing buffers

This function stops the tracing buffers from recording data. It does not disable any overhead the tracers themselves may be causing. This function simply causes all recording to the ring buffers to fail.

Definition at line 371 of file trace.c.

void tracing_on ( void  )

tracing_on - enable tracing buffers

This function enables tracing buffers that may have been disabled with tracing_off.

Definition at line 349 of file trace.c.

int tracing_open_generic ( struct inode inode,
struct file filp 
)

Definition at line 2464 of file trace.c.

void tracing_record_cmdline ( struct task_struct tsk)

Definition at line 1132 of file trace.c.

void tracing_reset ( struct trace_array tr,
int  cpu 
)

Definition at line 904 of file trace.c.

void tracing_reset_current ( int  cpu)

Definition at line 935 of file trace.c.

void tracing_reset_current_online_cpus ( void  )

Definition at line 940 of file trace.c.

void tracing_reset_online_cpus ( struct trace_array tr)

Definition at line 917 of file trace.c.

void tracing_start ( void  )

tracing_start - quick start of the tracer

If tracing is enabled but was stopped by tracing_stop, this will start the tracer back up.

Definition at line 989 of file trace.c.

void tracing_stop ( void  )

tracing_stop - quick stop of the tracer

Light weight way to stop tracing. Use in conjunction with tracing_start.

Definition at line 1031 of file trace.c.

int tracing_update_buffers ( void  )

tracing_update_buffers - used by tracing facility to expand ring buffers

To save on memory when the tracing is never used on a system with it configured in. The ring buffers are set to a minimum size. But once a user starts to use the tracing facility, then they need to grow to their default size.

This function is to be called when a tracer is about to be used.

Definition at line 3129 of file trace.c.

void unregister_tracer ( struct tracer type)

Definition at line 878 of file trace.c.

Variable Documentation

enum ftrace_dump_mode ftrace_dump_on_oops

Definition at line 108 of file trace.c.

u64(* func)(void)

Definition at line 478 of file trace.c.

const char* name

Definition at line 479 of file trace.c.

int ring_buffer_expanded

Definition at line 49 of file trace.c.

int trace_clock_id

Definition at line 486 of file trace.c.

unsigned long trace_flags
cpumask_var_t __read_mostly tracing_buffer_mask

Definition at line 90 of file trace.c.

bool __read_mostly tracing_selftest_disabled

Definition at line 63 of file trace.c.

unsigned long __read_mostly tracing_thresh

Definition at line 650 of file trace.c.