Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_KERNEL_TRACE_H |
| 2 | #define _LINUX_KERNEL_TRACE_H |
| 3 | |
| 4 | #include <linux/fs.h> |
| 5 | #include <asm/atomic.h> |
| 6 | #include <linux/sched.h> |
| 7 | #include <linux/clocksource.h> |
Steven Rostedt | 3928a8a | 2008-09-29 23:02:41 -0400 | [diff] [blame] | 8 | #include <linux/ring_buffer.h> |
Pekka Paalanen | bd8ac68 | 2008-05-12 21:20:57 +0200 | [diff] [blame] | 9 | #include <linux/mmiotrace.h> |
Frédéric Weisbecker | d13744c | 2008-09-23 11:32:08 +0100 | [diff] [blame] | 10 | #include <linux/ftrace.h> |
Frederic Weisbecker | 3f5ec13 | 2008-11-11 23:21:31 +0100 | [diff] [blame] | 11 | #include <trace/boot.h> |
Frederic Weisbecker | 36994e5 | 2008-12-29 13:42:23 -0800 | [diff] [blame] | 12 | #include <trace/kmemtrace.h> |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 13 | |
Thomas Gleixner | 72829bc | 2008-05-23 21:37:28 +0200 | [diff] [blame] | 14 | enum trace_type { |
| 15 | __TRACE_FIRST_TYPE = 0, |
| 16 | |
| 17 | TRACE_FN, |
| 18 | TRACE_CTX, |
| 19 | TRACE_WAKE, |
| 20 | TRACE_STACK, |
Steven Rostedt | dd0e545 | 2008-08-01 12:26:41 -0400 | [diff] [blame] | 21 | TRACE_PRINT, |
Thomas Gleixner | 72829bc | 2008-05-23 21:37:28 +0200 | [diff] [blame] | 22 | TRACE_SPECIAL, |
Pekka Paalanen | bd8ac68 | 2008-05-12 21:20:57 +0200 | [diff] [blame] | 23 | TRACE_MMIO_RW, |
| 24 | TRACE_MMIO_MAP, |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 25 | TRACE_BRANCH, |
Frederic Weisbecker | 7423907 | 2008-11-11 23:24:42 +0100 | [diff] [blame] | 26 | TRACE_BOOT_CALL, |
| 27 | TRACE_BOOT_RET, |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 28 | TRACE_GRAPH_RET, |
| 29 | TRACE_GRAPH_ENT, |
Török Edwin | 02b6751 | 2008-11-22 13:28:47 +0200 | [diff] [blame] | 30 | TRACE_USER_STACK, |
Markus Metzger | a93751c | 2008-12-11 13:53:26 +0100 | [diff] [blame] | 31 | TRACE_HW_BRANCHES, |
Frederic Weisbecker | 36994e5 | 2008-12-29 13:42:23 -0800 | [diff] [blame] | 32 | TRACE_KMEM_ALLOC, |
| 33 | TRACE_KMEM_FREE, |
Arjan van de Ven | f3f47a6 | 2008-11-23 16:49:58 -0800 | [diff] [blame] | 34 | TRACE_POWER, |
Arnaldo Carvalho de Melo | c71a896 | 2009-01-23 12:06:27 -0200 | [diff] [blame] | 35 | TRACE_BLK, |
Thomas Gleixner | 72829bc | 2008-05-23 21:37:28 +0200 | [diff] [blame] | 36 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 37 | __TRACE_LAST_TYPE, |
Thomas Gleixner | 72829bc | 2008-05-23 21:37:28 +0200 | [diff] [blame] | 38 | }; |
| 39 | |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 40 | /* |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 41 | * The trace entry - the most basic unit of tracing. This is what |
| 42 | * is printed in the end as a single line in the trace output, such as: |
| 43 | * |
| 44 | * bash-15816 [01] 235.197585: idle_cpu <- irq_enter |
| 45 | */ |
| 46 | struct trace_entry { |
| 47 | unsigned char type; |
| 48 | unsigned char cpu; |
| 49 | unsigned char flags; |
| 50 | unsigned char preempt_count; |
| 51 | int pid; |
Török Edwin | 02b6751 | 2008-11-22 13:28:47 +0200 | [diff] [blame] | 52 | int tgid; |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | /* |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 56 | * Function trace entry - function address and parent function addres: |
| 57 | */ |
| 58 | struct ftrace_entry { |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 59 | struct trace_entry ent; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 60 | unsigned long ip; |
| 61 | unsigned long parent_ip; |
| 62 | }; |
Frederic Weisbecker | 15e6cb3 | 2008-11-11 07:14:25 +0100 | [diff] [blame] | 63 | |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 64 | /* Function call entry */ |
| 65 | struct ftrace_graph_ent_entry { |
| 66 | struct trace_entry ent; |
| 67 | struct ftrace_graph_ent graph_ent; |
| 68 | }; |
| 69 | |
Frederic Weisbecker | 15e6cb3 | 2008-11-11 07:14:25 +0100 | [diff] [blame] | 70 | /* Function return entry */ |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 71 | struct ftrace_graph_ret_entry { |
| 72 | struct trace_entry ent; |
| 73 | struct ftrace_graph_ret ret; |
Frederic Weisbecker | 15e6cb3 | 2008-11-11 07:14:25 +0100 | [diff] [blame] | 74 | }; |
Frédéric Weisbecker | d13744c | 2008-09-23 11:32:08 +0100 | [diff] [blame] | 75 | extern struct tracer boot_tracer; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * Context switch trace entry - which task (and prio) we switched from/to: |
| 79 | */ |
| 80 | struct ctx_switch_entry { |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 81 | struct trace_entry ent; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 82 | unsigned int prev_pid; |
| 83 | unsigned char prev_prio; |
| 84 | unsigned char prev_state; |
| 85 | unsigned int next_pid; |
| 86 | unsigned char next_prio; |
Peter Zijlstra | bac524d | 2008-05-12 21:20:53 +0200 | [diff] [blame] | 87 | unsigned char next_state; |
Peter Zijlstra | 80b5e94 | 2008-09-04 10:24:16 +0200 | [diff] [blame] | 88 | unsigned int next_cpu; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 89 | }; |
| 90 | |
| 91 | /* |
Ingo Molnar | f0a920d | 2008-05-12 21:20:47 +0200 | [diff] [blame] | 92 | * Special (free-form) trace entry: |
| 93 | */ |
| 94 | struct special_entry { |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 95 | struct trace_entry ent; |
Ingo Molnar | f0a920d | 2008-05-12 21:20:47 +0200 | [diff] [blame] | 96 | unsigned long arg1; |
| 97 | unsigned long arg2; |
| 98 | unsigned long arg3; |
| 99 | }; |
| 100 | |
| 101 | /* |
Ingo Molnar | 86387f7 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 102 | * Stack-trace entry: |
| 103 | */ |
| 104 | |
Ingo Molnar | 74f4e36 | 2008-05-12 21:21:15 +0200 | [diff] [blame] | 105 | #define FTRACE_STACK_ENTRIES 8 |
Ingo Molnar | 86387f7 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 106 | |
| 107 | struct stack_entry { |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 108 | struct trace_entry ent; |
Ingo Molnar | 86387f7 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 109 | unsigned long caller[FTRACE_STACK_ENTRIES]; |
| 110 | }; |
| 111 | |
Török Edwin | 02b6751 | 2008-11-22 13:28:47 +0200 | [diff] [blame] | 112 | struct userstack_entry { |
| 113 | struct trace_entry ent; |
| 114 | unsigned long caller[FTRACE_STACK_ENTRIES]; |
| 115 | }; |
| 116 | |
Ingo Molnar | 86387f7 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 117 | /* |
Steven Rostedt | dd0e545 | 2008-08-01 12:26:41 -0400 | [diff] [blame] | 118 | * ftrace_printk entry: |
| 119 | */ |
| 120 | struct print_entry { |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 121 | struct trace_entry ent; |
Steven Rostedt | dd0e545 | 2008-08-01 12:26:41 -0400 | [diff] [blame] | 122 | unsigned long ip; |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 123 | int depth; |
Steven Rostedt | dd0e545 | 2008-08-01 12:26:41 -0400 | [diff] [blame] | 124 | char buf[]; |
| 125 | }; |
| 126 | |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 127 | #define TRACE_OLD_SIZE 88 |
| 128 | |
| 129 | struct trace_field_cont { |
| 130 | unsigned char type; |
| 131 | /* Temporary till we get rid of this completely */ |
| 132 | char buf[TRACE_OLD_SIZE - 1]; |
| 133 | }; |
| 134 | |
| 135 | struct trace_mmiotrace_rw { |
| 136 | struct trace_entry ent; |
| 137 | struct mmiotrace_rw rw; |
| 138 | }; |
| 139 | |
| 140 | struct trace_mmiotrace_map { |
| 141 | struct trace_entry ent; |
| 142 | struct mmiotrace_map map; |
| 143 | }; |
| 144 | |
Frederic Weisbecker | 7423907 | 2008-11-11 23:24:42 +0100 | [diff] [blame] | 145 | struct trace_boot_call { |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 146 | struct trace_entry ent; |
Frederic Weisbecker | 7423907 | 2008-11-11 23:24:42 +0100 | [diff] [blame] | 147 | struct boot_trace_call boot_call; |
| 148 | }; |
| 149 | |
| 150 | struct trace_boot_ret { |
| 151 | struct trace_entry ent; |
| 152 | struct boot_trace_ret boot_ret; |
Steven Rostedt | 777e208 | 2008-09-29 23:02:42 -0400 | [diff] [blame] | 153 | }; |
| 154 | |
Steven Rostedt | 52f232c | 2008-11-12 00:14:40 -0500 | [diff] [blame] | 155 | #define TRACE_FUNC_SIZE 30 |
| 156 | #define TRACE_FILE_SIZE 20 |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 157 | struct trace_branch { |
Steven Rostedt | 52f232c | 2008-11-12 00:14:40 -0500 | [diff] [blame] | 158 | struct trace_entry ent; |
| 159 | unsigned line; |
| 160 | char func[TRACE_FUNC_SIZE+1]; |
| 161 | char file[TRACE_FILE_SIZE+1]; |
| 162 | char correct; |
| 163 | }; |
| 164 | |
Markus Metzger | a93751c | 2008-12-11 13:53:26 +0100 | [diff] [blame] | 165 | struct hw_branch_entry { |
Markus Metzger | 1e9b51c | 2008-11-25 09:24:15 +0100 | [diff] [blame] | 166 | struct trace_entry ent; |
Markus Metzger | a93751c | 2008-12-11 13:53:26 +0100 | [diff] [blame] | 167 | u64 from; |
| 168 | u64 to; |
Markus Metzger | 1e9b51c | 2008-11-25 09:24:15 +0100 | [diff] [blame] | 169 | }; |
| 170 | |
Arjan van de Ven | f3f47a6 | 2008-11-23 16:49:58 -0800 | [diff] [blame] | 171 | struct trace_power { |
| 172 | struct trace_entry ent; |
| 173 | struct power_trace state_data; |
| 174 | }; |
| 175 | |
Frederic Weisbecker | 36994e5 | 2008-12-29 13:42:23 -0800 | [diff] [blame] | 176 | struct kmemtrace_alloc_entry { |
| 177 | struct trace_entry ent; |
| 178 | enum kmemtrace_type_id type_id; |
| 179 | unsigned long call_site; |
| 180 | const void *ptr; |
| 181 | size_t bytes_req; |
| 182 | size_t bytes_alloc; |
| 183 | gfp_t gfp_flags; |
| 184 | int node; |
| 185 | }; |
| 186 | |
| 187 | struct kmemtrace_free_entry { |
| 188 | struct trace_entry ent; |
| 189 | enum kmemtrace_type_id type_id; |
| 190 | unsigned long call_site; |
| 191 | const void *ptr; |
| 192 | }; |
| 193 | |
Steven Rostedt | dd0e545 | 2008-08-01 12:26:41 -0400 | [diff] [blame] | 194 | /* |
Pekka Paalanen | fc5e27a | 2008-09-16 22:02:27 +0300 | [diff] [blame] | 195 | * trace_flag_type is an enumeration that holds different |
| 196 | * states when a trace occurs. These are: |
Steven Rostedt | 9244489 | 2008-10-24 09:42:59 -0400 | [diff] [blame] | 197 | * IRQS_OFF - interrupts were disabled |
| 198 | * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags |
| 199 | * NEED_RESCED - reschedule is requested |
| 200 | * HARDIRQ - inside an interrupt handler |
| 201 | * SOFTIRQ - inside a softirq handler |
Pekka Paalanen | fc5e27a | 2008-09-16 22:02:27 +0300 | [diff] [blame] | 202 | */ |
| 203 | enum trace_flag_type { |
| 204 | TRACE_FLAG_IRQS_OFF = 0x01, |
Steven Rostedt | 9244489 | 2008-10-24 09:42:59 -0400 | [diff] [blame] | 205 | TRACE_FLAG_IRQS_NOSUPPORT = 0x02, |
| 206 | TRACE_FLAG_NEED_RESCHED = 0x04, |
| 207 | TRACE_FLAG_HARDIRQ = 0x08, |
| 208 | TRACE_FLAG_SOFTIRQ = 0x10, |
Pekka Paalanen | fc5e27a | 2008-09-16 22:02:27 +0300 | [diff] [blame] | 209 | }; |
| 210 | |
Pekka Paalanen | 5bf9a1e | 2008-09-16 22:06:42 +0300 | [diff] [blame] | 211 | #define TRACE_BUF_SIZE 1024 |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 212 | |
| 213 | /* |
| 214 | * The CPU trace array - it consists of thousands of trace entries |
| 215 | * plus some other descriptor data: (for example which task started |
| 216 | * the trace, etc.) |
| 217 | */ |
| 218 | struct trace_array_cpu { |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 219 | atomic_t disabled; |
Ingo Molnar | 4e3c333 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 220 | |
Ingo Molnar | c7aafc5 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 221 | /* these fields get copied into max-trace: */ |
Ingo Molnar | c7aafc5 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 222 | unsigned long trace_idx; |
Steven Rostedt | 53d0aa7 | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 223 | unsigned long overrun; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 224 | unsigned long saved_latency; |
| 225 | unsigned long critical_start; |
| 226 | unsigned long critical_end; |
| 227 | unsigned long critical_sequence; |
| 228 | unsigned long nice; |
| 229 | unsigned long policy; |
| 230 | unsigned long rt_priority; |
| 231 | cycle_t preempt_timestamp; |
| 232 | pid_t pid; |
| 233 | uid_t uid; |
| 234 | char comm[TASK_COMM_LEN]; |
| 235 | }; |
| 236 | |
| 237 | struct trace_iterator; |
| 238 | |
| 239 | /* |
| 240 | * The trace array - an array of per-CPU trace arrays. This is the |
| 241 | * highest level data structure that individual tracers deal with. |
| 242 | * They have on/off state as well: |
| 243 | */ |
| 244 | struct trace_array { |
Steven Rostedt | 3928a8a | 2008-09-29 23:02:41 -0400 | [diff] [blame] | 245 | struct ring_buffer *buffer; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 246 | unsigned long entries; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 247 | int cpu; |
| 248 | cycle_t time_start; |
Steven Rostedt | b3806b4 | 2008-05-12 21:20:46 +0200 | [diff] [blame] | 249 | struct task_struct *waiter; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 250 | struct trace_array_cpu *data[NR_CPUS]; |
| 251 | }; |
| 252 | |
Steven Rostedt | 7104f30 | 2008-10-01 10:52:51 -0400 | [diff] [blame] | 253 | #define FTRACE_CMP_TYPE(var, type) \ |
| 254 | __builtin_types_compatible_p(typeof(var), type *) |
| 255 | |
| 256 | #undef IF_ASSIGN |
| 257 | #define IF_ASSIGN(var, entry, etype, id) \ |
| 258 | if (FTRACE_CMP_TYPE(var, etype)) { \ |
| 259 | var = (typeof(var))(entry); \ |
| 260 | WARN_ON(id && (entry)->type != id); \ |
| 261 | break; \ |
| 262 | } |
| 263 | |
| 264 | /* Will cause compile errors if type is not found. */ |
| 265 | extern void __ftrace_bad_type(void); |
| 266 | |
| 267 | /* |
| 268 | * The trace_assign_type is a verifier that the entry type is |
| 269 | * the same as the type being assigned. To add new types simply |
| 270 | * add a line with the following format: |
| 271 | * |
| 272 | * IF_ASSIGN(var, ent, type, id); |
| 273 | * |
| 274 | * Where "type" is the trace type that includes the trace_entry |
| 275 | * as the "ent" item. And "id" is the trace identifier that is |
| 276 | * used in the trace_type enum. |
| 277 | * |
| 278 | * If the type can have more than one id, then use zero. |
| 279 | */ |
| 280 | #define trace_assign_type(var, ent) \ |
| 281 | do { \ |
| 282 | IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN); \ |
| 283 | IF_ASSIGN(var, ent, struct ctx_switch_entry, 0); \ |
Steven Rostedt | 7104f30 | 2008-10-01 10:52:51 -0400 | [diff] [blame] | 284 | IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \ |
Török Edwin | 02b6751 | 2008-11-22 13:28:47 +0200 | [diff] [blame] | 285 | IF_ASSIGN(var, ent, struct userstack_entry, TRACE_USER_STACK);\ |
Steven Rostedt | 7104f30 | 2008-10-01 10:52:51 -0400 | [diff] [blame] | 286 | IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \ |
| 287 | IF_ASSIGN(var, ent, struct special_entry, 0); \ |
| 288 | IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \ |
| 289 | TRACE_MMIO_RW); \ |
| 290 | IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \ |
| 291 | TRACE_MMIO_MAP); \ |
Frederic Weisbecker | 7423907 | 2008-11-11 23:24:42 +0100 | [diff] [blame] | 292 | IF_ASSIGN(var, ent, struct trace_boot_call, TRACE_BOOT_CALL);\ |
| 293 | IF_ASSIGN(var, ent, struct trace_boot_ret, TRACE_BOOT_RET);\ |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 294 | IF_ASSIGN(var, ent, struct trace_branch, TRACE_BRANCH); \ |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 295 | IF_ASSIGN(var, ent, struct ftrace_graph_ent_entry, \ |
| 296 | TRACE_GRAPH_ENT); \ |
| 297 | IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \ |
| 298 | TRACE_GRAPH_RET); \ |
Markus Metzger | a93751c | 2008-12-11 13:53:26 +0100 | [diff] [blame] | 299 | IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\ |
Arjan van de Ven | f3f47a6 | 2008-11-23 16:49:58 -0800 | [diff] [blame] | 300 | IF_ASSIGN(var, ent, struct trace_power, TRACE_POWER); \ |
Frederic Weisbecker | 36994e5 | 2008-12-29 13:42:23 -0800 | [diff] [blame] | 301 | IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry, \ |
| 302 | TRACE_KMEM_ALLOC); \ |
| 303 | IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \ |
| 304 | TRACE_KMEM_FREE); \ |
Steven Rostedt | 7104f30 | 2008-10-01 10:52:51 -0400 | [diff] [blame] | 305 | __ftrace_bad_type(); \ |
| 306 | } while (0) |
Frederic Weisbecker | 2c4f035 | 2008-09-29 20:18:34 +0200 | [diff] [blame] | 307 | |
| 308 | /* Return values for print_line callback */ |
| 309 | enum print_line_t { |
| 310 | TRACE_TYPE_PARTIAL_LINE = 0, /* Retry after flushing the seq */ |
| 311 | TRACE_TYPE_HANDLED = 1, |
| 312 | TRACE_TYPE_UNHANDLED = 2 /* Relay to other output functions */ |
| 313 | }; |
| 314 | |
Frederic Weisbecker | adf9f19 | 2008-11-17 19:23:42 +0100 | [diff] [blame] | 315 | |
| 316 | /* |
| 317 | * An option specific to a tracer. This is a boolean value. |
| 318 | * The bit is the bit index that sets its value on the |
| 319 | * flags value in struct tracer_flags. |
| 320 | */ |
| 321 | struct tracer_opt { |
| 322 | const char *name; /* Will appear on the trace_options file */ |
| 323 | u32 bit; /* Mask assigned in val field in tracer_flags */ |
| 324 | }; |
| 325 | |
| 326 | /* |
| 327 | * The set of specific options for a tracer. Your tracer |
| 328 | * have to set the initial value of the flags val. |
| 329 | */ |
| 330 | struct tracer_flags { |
| 331 | u32 val; |
| 332 | struct tracer_opt *opts; |
| 333 | }; |
| 334 | |
| 335 | /* Makes more easy to define a tracer opt */ |
| 336 | #define TRACER_OPT(s, b) .name = #s, .bit = b |
| 337 | |
Frederic Weisbecker | 034939b | 2009-01-08 10:03:56 -0800 | [diff] [blame] | 338 | |
| 339 | /* |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 340 | * A specific tracer, represented by methods that operate on a trace array: |
| 341 | */ |
| 342 | struct tracer { |
| 343 | const char *name; |
Frederic Weisbecker | 1c80025 | 2008-11-16 05:57:26 +0100 | [diff] [blame] | 344 | /* Your tracer should raise a warning if init fails */ |
| 345 | int (*init)(struct trace_array *tr); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 346 | void (*reset)(struct trace_array *tr); |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 347 | void (*start)(struct trace_array *tr); |
| 348 | void (*stop)(struct trace_array *tr); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 349 | void (*open)(struct trace_iterator *iter); |
Steven Rostedt | 107bad8 | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 350 | void (*pipe_open)(struct trace_iterator *iter); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 351 | void (*close)(struct trace_iterator *iter); |
Steven Rostedt | 107bad8 | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 352 | ssize_t (*read)(struct trace_iterator *iter, |
| 353 | struct file *filp, char __user *ubuf, |
| 354 | size_t cnt, loff_t *ppos); |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 355 | #ifdef CONFIG_FTRACE_STARTUP_TEST |
| 356 | int (*selftest)(struct tracer *trace, |
| 357 | struct trace_array *tr); |
| 358 | #endif |
Markus Metzger | 8bba1bf | 2008-11-25 09:12:31 +0100 | [diff] [blame] | 359 | void (*print_header)(struct seq_file *m); |
Frederic Weisbecker | 2c4f035 | 2008-09-29 20:18:34 +0200 | [diff] [blame] | 360 | enum print_line_t (*print_line)(struct trace_iterator *iter); |
Frederic Weisbecker | adf9f19 | 2008-11-17 19:23:42 +0100 | [diff] [blame] | 361 | /* If you handled the flag setting, return 0 */ |
| 362 | int (*set_flag)(u32 old_flags, u32 bit, int set); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 363 | struct tracer *next; |
| 364 | int print_max; |
Frederic Weisbecker | adf9f19 | 2008-11-17 19:23:42 +0100 | [diff] [blame] | 365 | struct tracer_flags *flags; |
Frederic Weisbecker | 034939b | 2009-01-08 10:03:56 -0800 | [diff] [blame] | 366 | struct tracer_stat *stats; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 367 | }; |
| 368 | |
Steven Rostedt | 214023c | 2008-05-12 21:20:46 +0200 | [diff] [blame] | 369 | struct trace_seq { |
| 370 | unsigned char buffer[PAGE_SIZE]; |
| 371 | unsigned int len; |
Pekka Paalanen | 6c6c279 | 2008-05-12 21:21:02 +0200 | [diff] [blame] | 372 | unsigned int readpos; |
Steven Rostedt | 214023c | 2008-05-12 21:20:46 +0200 | [diff] [blame] | 373 | }; |
| 374 | |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 375 | /* |
| 376 | * Trace iterator - used by printout routines who present trace |
| 377 | * results to users and which routines might sleep, etc: |
| 378 | */ |
| 379 | struct trace_iterator { |
| 380 | struct trace_array *tr; |
| 381 | struct tracer *trace; |
Steven Rostedt | 107bad8 | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 382 | void *private; |
Steven Rostedt | 3928a8a | 2008-09-29 23:02:41 -0400 | [diff] [blame] | 383 | struct ring_buffer_iter *buffer_iter[NR_CPUS]; |
Ingo Molnar | 4e3c333 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 384 | |
Steven Rostedt | 53d0aa7 | 2008-05-12 21:21:01 +0200 | [diff] [blame] | 385 | /* The below is zeroed out in pipe_read */ |
| 386 | struct trace_seq seq; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 387 | struct trace_entry *ent; |
Ingo Molnar | 4e3c333 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 388 | int cpu; |
Steven Rostedt | 3928a8a | 2008-09-29 23:02:41 -0400 | [diff] [blame] | 389 | u64 ts; |
Ingo Molnar | 4e3c333 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 390 | |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 391 | unsigned long iter_flags; |
| 392 | loff_t pos; |
Steven Rostedt | 4c11d7a | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 393 | long idx; |
Steven Rostedt | a309720 | 2008-11-07 22:36:02 -0500 | [diff] [blame] | 394 | |
Rusty Russell | 4462344 | 2009-01-01 10:12:23 +1030 | [diff] [blame] | 395 | cpumask_var_t started; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 396 | }; |
| 397 | |
Arnaldo Carvalho de Melo | b6f11df | 2009-02-05 18:02:00 -0200 | [diff] [blame^] | 398 | int tracer_init(struct tracer *t, struct trace_array *tr); |
Steven Rostedt | 9036990 | 2008-11-05 16:05:44 -0500 | [diff] [blame] | 399 | int tracing_is_enabled(void); |
Pekka Paalanen | 45dcd8b | 2008-09-16 21:56:41 +0300 | [diff] [blame] | 400 | void trace_wake_up(void); |
Steven Rostedt | 3928a8a | 2008-09-29 23:02:41 -0400 | [diff] [blame] | 401 | void tracing_reset(struct trace_array *tr, int cpu); |
Pekka J Enberg | 213cc06 | 2008-12-19 12:08:39 +0200 | [diff] [blame] | 402 | void tracing_reset_online_cpus(struct trace_array *tr); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 403 | int tracing_open_generic(struct inode *inode, struct file *filp); |
| 404 | struct dentry *tracing_init_dentry(void); |
Ingo Molnar | d618b3e | 2008-05-12 21:20:49 +0200 | [diff] [blame] | 405 | void init_tracer_sysprof_debugfs(struct dentry *d_tracer); |
| 406 | |
Arnaldo Carvalho de Melo | 51a763d | 2009-02-05 16:14:13 -0200 | [diff] [blame] | 407 | struct ring_buffer_event; |
| 408 | |
| 409 | struct ring_buffer_event *trace_buffer_lock_reserve(struct trace_array *tr, |
| 410 | unsigned char type, |
| 411 | unsigned long len, |
| 412 | unsigned long flags, |
| 413 | int pc); |
| 414 | void trace_buffer_unlock_commit(struct trace_array *tr, |
| 415 | struct ring_buffer_event *event, |
| 416 | unsigned long flags, int pc); |
| 417 | |
Pekka Paalanen | 45dcd8b | 2008-09-16 21:56:41 +0300 | [diff] [blame] | 418 | struct trace_entry *tracing_get_trace_entry(struct trace_array *tr, |
| 419 | struct trace_array_cpu *data); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 420 | |
| 421 | struct trace_entry *trace_find_next_entry(struct trace_iterator *iter, |
| 422 | int *ent_cpu, u64 *ent_ts); |
| 423 | |
Pekka Paalanen | 45dcd8b | 2008-09-16 21:56:41 +0300 | [diff] [blame] | 424 | void tracing_generic_entry_update(struct trace_entry *entry, |
Steven Rostedt | 3869705 | 2008-10-01 13:14:09 -0400 | [diff] [blame] | 425 | unsigned long flags, |
| 426 | int pc); |
Pekka Paalanen | 45dcd8b | 2008-09-16 21:56:41 +0300 | [diff] [blame] | 427 | |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 428 | void ftrace(struct trace_array *tr, |
| 429 | struct trace_array_cpu *data, |
| 430 | unsigned long ip, |
| 431 | unsigned long parent_ip, |
Steven Rostedt | 3869705 | 2008-10-01 13:14:09 -0400 | [diff] [blame] | 432 | unsigned long flags, int pc); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 433 | void tracing_sched_switch_trace(struct trace_array *tr, |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 434 | struct task_struct *prev, |
| 435 | struct task_struct *next, |
Steven Rostedt | 3869705 | 2008-10-01 13:14:09 -0400 | [diff] [blame] | 436 | unsigned long flags, int pc); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 437 | void tracing_record_cmdline(struct task_struct *tsk); |
Ingo Molnar | 5742279 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 438 | |
| 439 | void tracing_sched_wakeup_trace(struct trace_array *tr, |
Ingo Molnar | 5742279 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 440 | struct task_struct *wakee, |
| 441 | struct task_struct *cur, |
Steven Rostedt | 3869705 | 2008-10-01 13:14:09 -0400 | [diff] [blame] | 442 | unsigned long flags, int pc); |
Ingo Molnar | f0a920d | 2008-05-12 21:20:47 +0200 | [diff] [blame] | 443 | void trace_special(struct trace_array *tr, |
| 444 | struct trace_array_cpu *data, |
| 445 | unsigned long arg1, |
| 446 | unsigned long arg2, |
Steven Rostedt | 3869705 | 2008-10-01 13:14:09 -0400 | [diff] [blame] | 447 | unsigned long arg3, int pc); |
Steven Rostedt | 6fb44b7 | 2008-05-12 21:20:49 +0200 | [diff] [blame] | 448 | void trace_function(struct trace_array *tr, |
Steven Rostedt | 6fb44b7 | 2008-05-12 21:20:49 +0200 | [diff] [blame] | 449 | unsigned long ip, |
| 450 | unsigned long parent_ip, |
Steven Rostedt | 3869705 | 2008-10-01 13:14:09 -0400 | [diff] [blame] | 451 | unsigned long flags, int pc); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 452 | |
Frederic Weisbecker | 287b6e6 | 2008-11-26 00:57:25 +0100 | [diff] [blame] | 453 | void trace_graph_return(struct ftrace_graph_ret *trace); |
Steven Rostedt | e49dc19 | 2008-12-02 23:50:05 -0500 | [diff] [blame] | 454 | int trace_graph_entry(struct ftrace_graph_ent *trace); |
Markus Metzger | 1e9b51c | 2008-11-25 09:24:15 +0100 | [diff] [blame] | 455 | |
Steven Rostedt | 41bc814 | 2008-05-22 11:49:22 -0400 | [diff] [blame] | 456 | void tracing_start_cmdline_record(void); |
| 457 | void tracing_stop_cmdline_record(void); |
Steven Rostedt | e168e05 | 2008-11-07 22:36:02 -0500 | [diff] [blame] | 458 | void tracing_sched_switch_assign_trace(struct trace_array *tr); |
| 459 | void tracing_stop_sched_switch_record(void); |
| 460 | void tracing_start_sched_switch_record(void); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 461 | int register_tracer(struct tracer *type); |
| 462 | void unregister_tracer(struct tracer *type); |
| 463 | |
| 464 | extern unsigned long nsecs_to_usecs(unsigned long nsecs); |
| 465 | |
| 466 | extern unsigned long tracing_max_latency; |
| 467 | extern unsigned long tracing_thresh; |
| 468 | |
| 469 | void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu); |
| 470 | void update_max_tr_single(struct trace_array *tr, |
| 471 | struct task_struct *tsk, int cpu); |
| 472 | |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 473 | void __trace_stack(struct trace_array *tr, |
Steven Rostedt | 5361499 | 2009-01-15 19:12:40 -0500 | [diff] [blame] | 474 | unsigned long flags, |
| 475 | int skip, int pc); |
| 476 | |
Ingo Molnar | e309b41 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 477 | extern cycle_t ftrace_now(int cpu); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 478 | |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 479 | #ifdef CONFIG_CONTEXT_SWITCH_TRACER |
| 480 | typedef void |
| 481 | (*tracer_switch_func_t)(void *private, |
Mathieu Desnoyers | 5b82a1b | 2008-05-12 21:21:10 +0200 | [diff] [blame] | 482 | void *__rq, |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 483 | struct task_struct *prev, |
| 484 | struct task_struct *next); |
| 485 | |
| 486 | struct tracer_switch_ops { |
| 487 | tracer_switch_func_t func; |
| 488 | void *private; |
| 489 | struct tracer_switch_ops *next; |
| 490 | }; |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 491 | #endif /* CONFIG_CONTEXT_SWITCH_TRACER */ |
| 492 | |
Ingo Molnar | f7d48cb | 2008-12-29 13:02:17 +0100 | [diff] [blame] | 493 | extern char *trace_find_cmdline(int pid); |
| 494 | |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 495 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 496 | extern unsigned long ftrace_update_tot_cnt; |
Steven Rostedt | d05cdb2 | 2008-05-12 21:20:54 +0200 | [diff] [blame] | 497 | #define DYN_FTRACE_TEST_NAME trace_selftest_dynamic_test_func |
| 498 | extern int DYN_FTRACE_TEST_NAME(void); |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 499 | #endif |
| 500 | |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 501 | #ifdef CONFIG_FTRACE_STARTUP_TEST |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 502 | extern int trace_selftest_startup_function(struct tracer *trace, |
| 503 | struct trace_array *tr); |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 504 | extern int trace_selftest_startup_irqsoff(struct tracer *trace, |
| 505 | struct trace_array *tr); |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 506 | extern int trace_selftest_startup_preemptoff(struct tracer *trace, |
| 507 | struct trace_array *tr); |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 508 | extern int trace_selftest_startup_preemptirqsoff(struct tracer *trace, |
| 509 | struct trace_array *tr); |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 510 | extern int trace_selftest_startup_wakeup(struct tracer *trace, |
| 511 | struct trace_array *tr); |
Steven Noonan | fb1b6d8 | 2008-09-19 03:06:43 -0700 | [diff] [blame] | 512 | extern int trace_selftest_startup_nop(struct tracer *trace, |
| 513 | struct trace_array *tr); |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 514 | extern int trace_selftest_startup_sched_switch(struct tracer *trace, |
| 515 | struct trace_array *tr); |
Ingo Molnar | a6dd24f | 2008-05-12 21:20:47 +0200 | [diff] [blame] | 516 | extern int trace_selftest_startup_sysprof(struct tracer *trace, |
| 517 | struct trace_array *tr); |
Steven Rostedt | 80e5ea4 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 518 | extern int trace_selftest_startup_branch(struct tracer *trace, |
| 519 | struct trace_array *tr); |
Steven Rostedt | 60a1177 | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 520 | #endif /* CONFIG_FTRACE_STARTUP_TEST */ |
| 521 | |
Ingo Molnar | c7aafc5 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 522 | extern void *head_page(struct trace_array_cpu *data); |
Thomas Gleixner | 72829bc | 2008-05-23 21:37:28 +0200 | [diff] [blame] | 523 | extern long ns2usecs(cycle_t nsec); |
Frederic Weisbecker | 1fd8f2a | 2008-12-03 23:45:11 +0100 | [diff] [blame] | 524 | extern int |
| 525 | trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args); |
Ingo Molnar | c7aafc5 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 526 | |
Ingo Molnar | 4e65551 | 2008-05-12 21:20:52 +0200 | [diff] [blame] | 527 | extern unsigned long trace_flags; |
| 528 | |
Frederic Weisbecker | 15e6cb3 | 2008-11-11 07:14:25 +0100 | [diff] [blame] | 529 | /* Standard output formatting function used for function return traces */ |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 530 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| 531 | extern enum print_line_t print_graph_function(struct trace_iterator *iter); |
Steven Rostedt | ea4e2bc | 2008-12-03 15:36:57 -0500 | [diff] [blame] | 532 | |
| 533 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 534 | /* TODO: make this variable */ |
| 535 | #define FTRACE_GRAPH_MAX_FUNCS 32 |
| 536 | extern int ftrace_graph_count; |
| 537 | extern unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS]; |
| 538 | |
| 539 | static inline int ftrace_graph_addr(unsigned long addr) |
| 540 | { |
| 541 | int i; |
| 542 | |
| 543 | if (!ftrace_graph_count || test_tsk_trace_graph(current)) |
| 544 | return 1; |
| 545 | |
| 546 | for (i = 0; i < ftrace_graph_count; i++) { |
| 547 | if (addr == ftrace_graph_funcs[i]) |
| 548 | return 1; |
| 549 | } |
| 550 | |
| 551 | return 0; |
| 552 | } |
Frederic Weisbecker | 15e6cb3 | 2008-11-11 07:14:25 +0100 | [diff] [blame] | 553 | #else |
Steven Rostedt | ea4e2bc | 2008-12-03 15:36:57 -0500 | [diff] [blame] | 554 | static inline int ftrace_trace_addr(unsigned long addr) |
| 555 | { |
Ingo Molnar | 6b25393 | 2008-12-04 09:18:28 +0100 | [diff] [blame] | 556 | return 1; |
| 557 | } |
| 558 | static inline int ftrace_graph_addr(unsigned long addr) |
| 559 | { |
| 560 | return 1; |
Steven Rostedt | ea4e2bc | 2008-12-03 15:36:57 -0500 | [diff] [blame] | 561 | } |
| 562 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
| 563 | |
| 564 | #else /* CONFIG_FUNCTION_GRAPH_TRACER */ |
Frederic Weisbecker | 15e6cb3 | 2008-11-11 07:14:25 +0100 | [diff] [blame] | 565 | static inline enum print_line_t |
Frederic Weisbecker | fb52607 | 2008-11-25 21:07:04 +0100 | [diff] [blame] | 566 | print_graph_function(struct trace_iterator *iter) |
Frederic Weisbecker | 15e6cb3 | 2008-11-11 07:14:25 +0100 | [diff] [blame] | 567 | { |
| 568 | return TRACE_TYPE_UNHANDLED; |
| 569 | } |
Steven Rostedt | ea4e2bc | 2008-12-03 15:36:57 -0500 | [diff] [blame] | 570 | #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ |
Frederic Weisbecker | 15e6cb3 | 2008-11-11 07:14:25 +0100 | [diff] [blame] | 571 | |
Steven Rostedt | 978f3a4 | 2008-12-04 00:26:40 -0500 | [diff] [blame] | 572 | extern struct pid *ftrace_pid_trace; |
Steven Rostedt | 804a685 | 2008-12-03 15:36:59 -0500 | [diff] [blame] | 573 | |
| 574 | static inline int ftrace_trace_task(struct task_struct *task) |
| 575 | { |
Frederic Weisbecker | 77d683f3 | 2008-12-04 23:49:47 +0100 | [diff] [blame] | 576 | if (!ftrace_pid_trace) |
Steven Rostedt | 804a685 | 2008-12-03 15:36:59 -0500 | [diff] [blame] | 577 | return 1; |
| 578 | |
| 579 | return test_tsk_trace_trace(task); |
| 580 | } |
| 581 | |
Steven Rostedt | 4fcdae8 | 2008-05-12 21:21:00 +0200 | [diff] [blame] | 582 | /* |
| 583 | * trace_iterator_flags is an enumeration that defines bit |
| 584 | * positions into trace_flags that controls the output. |
| 585 | * |
| 586 | * NOTE: These bits must match the trace_options array in |
| 587 | * trace.c. |
| 588 | */ |
Ingo Molnar | 4e65551 | 2008-05-12 21:20:52 +0200 | [diff] [blame] | 589 | enum trace_iterator_flags { |
| 590 | TRACE_ITER_PRINT_PARENT = 0x01, |
| 591 | TRACE_ITER_SYM_OFFSET = 0x02, |
| 592 | TRACE_ITER_SYM_ADDR = 0x04, |
| 593 | TRACE_ITER_VERBOSE = 0x08, |
| 594 | TRACE_ITER_RAW = 0x10, |
| 595 | TRACE_ITER_HEX = 0x20, |
| 596 | TRACE_ITER_BIN = 0x40, |
| 597 | TRACE_ITER_BLOCK = 0x80, |
| 598 | TRACE_ITER_STACKTRACE = 0x100, |
Ingo Molnar | 4ac3ba4 | 2008-05-12 21:20:52 +0200 | [diff] [blame] | 599 | TRACE_ITER_SCHED_TREE = 0x200, |
Peter Zijlstra | f09ce57 | 2008-09-04 10:24:14 +0200 | [diff] [blame] | 600 | TRACE_ITER_PRINTK = 0x400, |
Steven Rostedt | b2a866f | 2008-11-03 23:15:57 -0500 | [diff] [blame] | 601 | TRACE_ITER_PREEMPTONLY = 0x800, |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 602 | TRACE_ITER_BRANCH = 0x1000, |
Steven Rostedt | 12ef7d4 | 2008-11-12 17:52:38 -0500 | [diff] [blame] | 603 | TRACE_ITER_ANNOTATE = 0x2000, |
Török Edwin | b54d3de | 2008-11-22 13:28:48 +0200 | [diff] [blame] | 604 | TRACE_ITER_USERSTACKTRACE = 0x4000, |
Frederic Weisbecker | 66896a8 | 2008-12-13 20:18:13 +0100 | [diff] [blame] | 605 | TRACE_ITER_SYM_USEROBJ = 0x8000, |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 606 | TRACE_ITER_PRINTK_MSGONLY = 0x10000, |
| 607 | TRACE_ITER_CONTEXT_INFO = 0x20000 /* Print pid/cpu/time */ |
Ingo Molnar | 4e65551 | 2008-05-12 21:20:52 +0200 | [diff] [blame] | 608 | }; |
| 609 | |
Frederic Weisbecker | 15e6cb3 | 2008-11-11 07:14:25 +0100 | [diff] [blame] | 610 | /* |
| 611 | * TRACE_ITER_SYM_MASK masks the options in trace_flags that |
| 612 | * control the output of kernel symbols. |
| 613 | */ |
| 614 | #define TRACE_ITER_SYM_MASK \ |
| 615 | (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR) |
| 616 | |
Frédéric Weisbecker | 43a1538 | 2008-09-21 20:16:30 +0200 | [diff] [blame] | 617 | extern struct tracer nop_trace; |
| 618 | |
Steven Rostedt | 8f0a056 | 2008-11-03 23:15:55 -0500 | [diff] [blame] | 619 | /** |
| 620 | * ftrace_preempt_disable - disable preemption scheduler safe |
| 621 | * |
| 622 | * When tracing can happen inside the scheduler, there exists |
| 623 | * cases that the tracing might happen before the need_resched |
| 624 | * flag is checked. If this happens and the tracer calls |
| 625 | * preempt_enable (after a disable), a schedule might take place |
| 626 | * causing an infinite recursion. |
| 627 | * |
| 628 | * To prevent this, we read the need_recshed flag before |
| 629 | * disabling preemption. When we want to enable preemption we |
| 630 | * check the flag, if it is set, then we call preempt_enable_no_resched. |
| 631 | * Otherwise, we call preempt_enable. |
| 632 | * |
| 633 | * The rational for doing the above is that if need resched is set |
| 634 | * and we have yet to reschedule, we are either in an atomic location |
| 635 | * (where we do not need to check for scheduling) or we are inside |
| 636 | * the scheduler and do not want to resched. |
| 637 | */ |
| 638 | static inline int ftrace_preempt_disable(void) |
| 639 | { |
| 640 | int resched; |
| 641 | |
| 642 | resched = need_resched(); |
| 643 | preempt_disable_notrace(); |
| 644 | |
| 645 | return resched; |
| 646 | } |
| 647 | |
| 648 | /** |
| 649 | * ftrace_preempt_enable - enable preemption scheduler safe |
| 650 | * @resched: the return value from ftrace_preempt_disable |
| 651 | * |
| 652 | * This is a scheduler safe way to enable preemption and not miss |
| 653 | * any preemption checks. The disabled saved the state of preemption. |
| 654 | * If resched is set, then we were either inside an atomic or |
| 655 | * are inside the scheduler (we would have already scheduled |
| 656 | * otherwise). In this case, we do not want to call normal |
| 657 | * preempt_enable, but preempt_enable_no_resched instead. |
| 658 | */ |
| 659 | static inline void ftrace_preempt_enable(int resched) |
| 660 | { |
| 661 | if (resched) |
| 662 | preempt_enable_no_resched_notrace(); |
| 663 | else |
| 664 | preempt_enable_notrace(); |
| 665 | } |
| 666 | |
Steven Rostedt | 2ed84ee | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 667 | #ifdef CONFIG_BRANCH_TRACER |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 668 | extern int enable_branch_tracing(struct trace_array *tr); |
| 669 | extern void disable_branch_tracing(void); |
| 670 | static inline int trace_branch_enable(struct trace_array *tr) |
Steven Rostedt | 52f232c | 2008-11-12 00:14:40 -0500 | [diff] [blame] | 671 | { |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 672 | if (trace_flags & TRACE_ITER_BRANCH) |
| 673 | return enable_branch_tracing(tr); |
Steven Rostedt | 52f232c | 2008-11-12 00:14:40 -0500 | [diff] [blame] | 674 | return 0; |
| 675 | } |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 676 | static inline void trace_branch_disable(void) |
Steven Rostedt | 52f232c | 2008-11-12 00:14:40 -0500 | [diff] [blame] | 677 | { |
| 678 | /* due to races, always disable */ |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 679 | disable_branch_tracing(); |
Steven Rostedt | 52f232c | 2008-11-12 00:14:40 -0500 | [diff] [blame] | 680 | } |
| 681 | #else |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 682 | static inline int trace_branch_enable(struct trace_array *tr) |
Steven Rostedt | 52f232c | 2008-11-12 00:14:40 -0500 | [diff] [blame] | 683 | { |
| 684 | return 0; |
| 685 | } |
Steven Rostedt | 9f029e8 | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 686 | static inline void trace_branch_disable(void) |
Steven Rostedt | 52f232c | 2008-11-12 00:14:40 -0500 | [diff] [blame] | 687 | { |
| 688 | } |
Steven Rostedt | 2ed84ee | 2008-11-12 15:24:24 -0500 | [diff] [blame] | 689 | #endif /* CONFIG_BRANCH_TRACER */ |
Steven Rostedt | 52f232c | 2008-11-12 00:14:40 -0500 | [diff] [blame] | 690 | |
Steven Rostedt | bc0c38d | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 691 | #endif /* _LINUX_KERNEL_TRACE_H */ |