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
{
58 unsigned trace_current_idx
;
59 struct list_head trace_pages
;
60 unsigned long trace_idx
;
62 unsigned long saved_latency
;
63 unsigned long critical_start
;
64 unsigned long critical_end
;
65 unsigned long critical_sequence
;
68 unsigned long rt_priority
;
69 cycle_t preempt_timestamp
;
72 char comm
[TASK_COMM_LEN
];
75 struct trace_iterator
;
78 * The trace array - an array of per-CPU trace arrays. This is the
79 * highest level data structure that individual tracers deal with.
80 * They have on/off state as well:
83 unsigned long entries
;
87 struct trace_array_cpu
*data
[NR_CPUS
];
91 * A specific tracer, represented by methods that operate on a trace array:
95 void (*init
)(struct trace_array
*tr
);
96 void (*reset
)(struct trace_array
*tr
);
97 void (*open
)(struct trace_iterator
*iter
);
98 void (*close
)(struct trace_iterator
*iter
);
99 void (*start
)(struct trace_iterator
*iter
);
100 void (*stop
)(struct trace_iterator
*iter
);
101 void (*ctrl_update
)(struct trace_array
*tr
);
102 #ifdef CONFIG_FTRACE_STARTUP_TEST
103 int (*selftest
)(struct tracer
*trace
,
104 struct trace_array
*tr
);
111 * Trace iterator - used by printout routines who present trace
112 * results to users and which routines might sleep, etc:
114 struct trace_iterator
{
115 struct trace_array
*tr
;
116 struct tracer
*trace
;
117 struct trace_entry
*ent
;
118 unsigned long iter_flags
;
120 unsigned long next_idx
[NR_CPUS
];
121 struct list_head
*next_page
[NR_CPUS
];
122 unsigned next_page_idx
[NR_CPUS
];
127 void notrace
tracing_reset(struct trace_array_cpu
*data
);
128 int tracing_open_generic(struct inode
*inode
, struct file
*filp
);
129 struct dentry
*tracing_init_dentry(void);
130 void ftrace(struct trace_array
*tr
,
131 struct trace_array_cpu
*data
,
133 unsigned long parent_ip
,
134 unsigned long flags
);
135 void tracing_sched_switch_trace(struct trace_array
*tr
,
136 struct trace_array_cpu
*data
,
137 struct task_struct
*prev
,
138 struct task_struct
*next
,
139 unsigned long flags
);
140 void tracing_record_cmdline(struct task_struct
*tsk
);
142 void tracing_start_function_trace(void);
143 void tracing_stop_function_trace(void);
144 int register_tracer(struct tracer
*type
);
145 void unregister_tracer(struct tracer
*type
);
147 extern unsigned long nsecs_to_usecs(unsigned long nsecs
);
149 extern unsigned long tracing_max_latency
;
150 extern unsigned long tracing_thresh
;
152 void update_max_tr(struct trace_array
*tr
, struct task_struct
*tsk
, int cpu
);
153 void update_max_tr_single(struct trace_array
*tr
,
154 struct task_struct
*tsk
, int cpu
);
156 static inline notrace cycle_t
now(int cpu
)
158 return cpu_clock(cpu
);
161 #ifdef CONFIG_SCHED_TRACER
163 wakeup_sched_switch(struct task_struct
*prev
, struct task_struct
*next
);
166 wakeup_sched_switch(struct task_struct
*prev
, struct task_struct
*next
)
171 #ifdef CONFIG_CONTEXT_SWITCH_TRACER
173 (*tracer_switch_func_t
)(void *private,
174 struct task_struct
*prev
,
175 struct task_struct
*next
);
177 struct tracer_switch_ops
{
178 tracer_switch_func_t func
;
180 struct tracer_switch_ops
*next
;
183 extern int register_tracer_switch(struct tracer_switch_ops
*ops
);
184 extern int unregister_tracer_switch(struct tracer_switch_ops
*ops
);
186 #endif /* CONFIG_CONTEXT_SWITCH_TRACER */
188 #ifdef CONFIG_DYNAMIC_FTRACE
189 extern unsigned long ftrace_update_tot_cnt
;
192 #ifdef CONFIG_FTRACE_STARTUP_TEST
194 extern int trace_selftest_startup_function(struct tracer
*trace
,
195 struct trace_array
*tr
);
197 #ifdef CONFIG_IRQSOFF_TRACER
198 extern int trace_selftest_startup_irqsoff(struct tracer
*trace
,
199 struct trace_array
*tr
);
201 #ifdef CONFIG_PREEMPT_TRACER
202 extern int trace_selftest_startup_preemptoff(struct tracer
*trace
,
203 struct trace_array
*tr
);
205 #if defined(CONFIG_IRQSOFF_TRACER) && defined(CONFIG_PREEMPT_TRACER)
206 extern int trace_selftest_startup_preemptirqsoff(struct tracer
*trace
,
207 struct trace_array
*tr
);
209 #ifdef CONFIG_SCHED_TRACER
210 extern int trace_selftest_startup_wakeup(struct tracer
*trace
,
211 struct trace_array
*tr
);
213 #ifdef CONFIG_CONTEXT_SWITCH_TRACER
214 extern int trace_selftest_startup_sched_switch(struct tracer
*trace
,
215 struct trace_array
*tr
);
217 #endif /* CONFIG_FTRACE_STARTUP_TEST */
219 #endif /* _LINUX_KERNEL_TRACE_H */