1 #ifndef _LINUX_KERNEL_TRACE_H
2 #define _LINUX_KERNEL_TRACE_H
5 #include <asm/atomic.h>
6 #include <linux/sched.h>
7 #include <linux/clocksource.h>
10 * Function trace entry - function address and parent function addres:
14 unsigned long parent_ip
;
18 * Context switch trace entry - which task (and prio) we switched from/to:
20 struct ctx_switch_entry
{
21 unsigned int prev_pid
;
22 unsigned char prev_prio
;
23 unsigned char prev_state
;
24 unsigned int next_pid
;
25 unsigned char next_prio
;
29 * The trace entry - the most basic unit of tracing. This is what
30 * is printed in the end as a single line in the trace output, such as:
32 * bash-15816 [01] 235.197585: idle_cpu <- irq_enter
43 struct ftrace_entry fn
;
44 struct ctx_switch_entry ctx
;
48 #define TRACE_ENTRY_SIZE sizeof(struct trace_entry)
51 * The CPU trace array - it consists of thousands of trace entries
52 * plus some other descriptor data: (for example which task started
55 struct trace_array_cpu
{
57 unsigned long trace_idx
;
60 unsigned long saved_latency
;
61 unsigned long critical_start
;
62 unsigned long critical_end
;
63 unsigned long critical_sequence
;
66 unsigned long rt_priority
;
67 cycle_t preempt_timestamp
;
70 char comm
[TASK_COMM_LEN
];
73 struct trace_iterator
;
76 * The trace array - an array of per-CPU trace arrays. This is the
77 * highest level data structure that individual tracers deal with.
78 * They have on/off state as well:
81 unsigned long entries
;
85 struct trace_array_cpu
*data
[NR_CPUS
];
89 * A specific tracer, represented by methods that operate on a trace array:
93 void (*init
)(struct trace_array
*tr
);
94 void (*reset
)(struct trace_array
*tr
);
95 void (*open
)(struct trace_iterator
*iter
);
96 void (*close
)(struct trace_iterator
*iter
);
97 void (*start
)(struct trace_iterator
*iter
);
98 void (*stop
)(struct trace_iterator
*iter
);
99 void (*ctrl_update
)(struct trace_array
*tr
);
105 * Trace iterator - used by printout routines who present trace
106 * results to users and which routines might sleep, etc:
108 struct trace_iterator
{
109 struct trace_array
*tr
;
110 struct tracer
*trace
;
111 struct trace_entry
*ent
;
112 unsigned long iter_flags
;
114 unsigned long next_idx
[NR_CPUS
];
119 void notrace
tracing_reset(struct trace_array_cpu
*data
);
120 int tracing_open_generic(struct inode
*inode
, struct file
*filp
);
121 struct dentry
*tracing_init_dentry(void);
122 void ftrace(struct trace_array
*tr
,
123 struct trace_array_cpu
*data
,
125 unsigned long parent_ip
,
126 unsigned long flags
);
127 void tracing_sched_switch_trace(struct trace_array
*tr
,
128 struct trace_array_cpu
*data
,
129 struct task_struct
*prev
,
130 struct task_struct
*next
,
131 unsigned long flags
);
132 void tracing_record_cmdline(struct task_struct
*tsk
);
134 void tracing_start_function_trace(void);
135 void tracing_stop_function_trace(void);
136 int register_tracer(struct tracer
*type
);
137 void unregister_tracer(struct tracer
*type
);
139 extern unsigned long nsecs_to_usecs(unsigned long nsecs
);
141 extern unsigned long tracing_max_latency
;
142 extern unsigned long tracing_thresh
;
144 void update_max_tr(struct trace_array
*tr
, struct task_struct
*tsk
, int cpu
);
145 void update_max_tr_single(struct trace_array
*tr
,
146 struct task_struct
*tsk
, int cpu
);
148 static inline notrace cycle_t
now(int cpu
)
150 return cpu_clock(cpu
);
153 #ifdef CONFIG_SCHED_TRACER
155 wakeup_sched_switch(struct task_struct
*prev
, struct task_struct
*next
);
158 wakeup_sched_switch(struct task_struct
*prev
, struct task_struct
*next
)
163 #ifdef CONFIG_CONTEXT_SWITCH_TRACER
165 (*tracer_switch_func_t
)(void *private,
166 struct task_struct
*prev
,
167 struct task_struct
*next
);
169 struct tracer_switch_ops
{
170 tracer_switch_func_t func
;
172 struct tracer_switch_ops
*next
;
175 extern int register_tracer_switch(struct tracer_switch_ops
*ops
);
176 extern int unregister_tracer_switch(struct tracer_switch_ops
*ops
);
178 #endif /* CONFIG_CONTEXT_SWITCH_TRACER */
180 #ifdef CONFIG_DYNAMIC_FTRACE
181 extern unsigned long ftrace_update_tot_cnt
;
184 #endif /* _LINUX_KERNEL_TRACE_H */