diff options
Diffstat (limited to 'kernel/trace/trace.h')
| -rw-r--r-- | kernel/trace/trace.h | 315 |
1 files changed, 267 insertions, 48 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 4d3d381bfd9..cb0ce3fc36d 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h | |||
| @@ -9,6 +9,8 @@ | |||
| 9 | #include <linux/mmiotrace.h> | 9 | #include <linux/mmiotrace.h> |
| 10 | #include <linux/ftrace.h> | 10 | #include <linux/ftrace.h> |
| 11 | #include <trace/boot.h> | 11 | #include <trace/boot.h> |
| 12 | #include <trace/kmemtrace.h> | ||
| 13 | #include <trace/power.h> | ||
| 12 | 14 | ||
| 13 | enum trace_type { | 15 | enum trace_type { |
| 14 | __TRACE_FIRST_TYPE = 0, | 16 | __TRACE_FIRST_TYPE = 0, |
| @@ -16,9 +18,9 @@ enum trace_type { | |||
| 16 | TRACE_FN, | 18 | TRACE_FN, |
| 17 | TRACE_CTX, | 19 | TRACE_CTX, |
| 18 | TRACE_WAKE, | 20 | TRACE_WAKE, |
| 19 | TRACE_CONT, | ||
| 20 | TRACE_STACK, | 21 | TRACE_STACK, |
| 21 | TRACE_PRINT, | 22 | TRACE_PRINT, |
| 23 | TRACE_BPRINT, | ||
| 22 | TRACE_SPECIAL, | 24 | TRACE_SPECIAL, |
| 23 | TRACE_MMIO_RW, | 25 | TRACE_MMIO_RW, |
| 24 | TRACE_MMIO_MAP, | 26 | TRACE_MMIO_MAP, |
| @@ -29,9 +31,14 @@ enum trace_type { | |||
| 29 | TRACE_GRAPH_ENT, | 31 | TRACE_GRAPH_ENT, |
| 30 | TRACE_USER_STACK, | 32 | TRACE_USER_STACK, |
| 31 | TRACE_HW_BRANCHES, | 33 | TRACE_HW_BRANCHES, |
| 34 | TRACE_SYSCALL_ENTER, | ||
| 35 | TRACE_SYSCALL_EXIT, | ||
| 36 | TRACE_KMEM_ALLOC, | ||
| 37 | TRACE_KMEM_FREE, | ||
| 32 | TRACE_POWER, | 38 | TRACE_POWER, |
| 39 | TRACE_BLK, | ||
| 33 | 40 | ||
| 34 | __TRACE_LAST_TYPE | 41 | __TRACE_LAST_TYPE, |
| 35 | }; | 42 | }; |
| 36 | 43 | ||
| 37 | /* | 44 | /* |
| @@ -42,7 +49,6 @@ enum trace_type { | |||
| 42 | */ | 49 | */ |
| 43 | struct trace_entry { | 50 | struct trace_entry { |
| 44 | unsigned char type; | 51 | unsigned char type; |
| 45 | unsigned char cpu; | ||
| 46 | unsigned char flags; | 52 | unsigned char flags; |
| 47 | unsigned char preempt_count; | 53 | unsigned char preempt_count; |
| 48 | int pid; | 54 | int pid; |
| @@ -60,13 +66,13 @@ struct ftrace_entry { | |||
| 60 | 66 | ||
| 61 | /* Function call entry */ | 67 | /* Function call entry */ |
| 62 | struct ftrace_graph_ent_entry { | 68 | struct ftrace_graph_ent_entry { |
| 63 | struct trace_entry ent; | 69 | struct trace_entry ent; |
| 64 | struct ftrace_graph_ent graph_ent; | 70 | struct ftrace_graph_ent graph_ent; |
| 65 | }; | 71 | }; |
| 66 | 72 | ||
| 67 | /* Function return entry */ | 73 | /* Function return entry */ |
| 68 | struct ftrace_graph_ret_entry { | 74 | struct ftrace_graph_ret_entry { |
| 69 | struct trace_entry ent; | 75 | struct trace_entry ent; |
| 70 | struct ftrace_graph_ret ret; | 76 | struct ftrace_graph_ret ret; |
| 71 | }; | 77 | }; |
| 72 | extern struct tracer boot_tracer; | 78 | extern struct tracer boot_tracer; |
| @@ -112,12 +118,18 @@ struct userstack_entry { | |||
| 112 | }; | 118 | }; |
| 113 | 119 | ||
| 114 | /* | 120 | /* |
| 115 | * ftrace_printk entry: | 121 | * trace_printk entry: |
| 116 | */ | 122 | */ |
| 123 | struct bprint_entry { | ||
| 124 | struct trace_entry ent; | ||
| 125 | unsigned long ip; | ||
| 126 | const char *fmt; | ||
| 127 | u32 buf[]; | ||
| 128 | }; | ||
| 129 | |||
| 117 | struct print_entry { | 130 | struct print_entry { |
| 118 | struct trace_entry ent; | 131 | struct trace_entry ent; |
| 119 | unsigned long ip; | 132 | unsigned long ip; |
| 120 | int depth; | ||
| 121 | char buf[]; | 133 | char buf[]; |
| 122 | }; | 134 | }; |
| 123 | 135 | ||
| @@ -170,15 +182,45 @@ struct trace_power { | |||
| 170 | struct power_trace state_data; | 182 | struct power_trace state_data; |
| 171 | }; | 183 | }; |
| 172 | 184 | ||
| 185 | struct kmemtrace_alloc_entry { | ||
| 186 | struct trace_entry ent; | ||
| 187 | enum kmemtrace_type_id type_id; | ||
| 188 | unsigned long call_site; | ||
| 189 | const void *ptr; | ||
| 190 | size_t bytes_req; | ||
| 191 | size_t bytes_alloc; | ||
| 192 | gfp_t gfp_flags; | ||
| 193 | int node; | ||
| 194 | }; | ||
| 195 | |||
| 196 | struct kmemtrace_free_entry { | ||
| 197 | struct trace_entry ent; | ||
| 198 | enum kmemtrace_type_id type_id; | ||
| 199 | unsigned long call_site; | ||
| 200 | const void *ptr; | ||
| 201 | }; | ||
| 202 | |||
| 203 | struct syscall_trace_enter { | ||
| 204 | struct trace_entry ent; | ||
| 205 | int nr; | ||
| 206 | unsigned long args[]; | ||
| 207 | }; | ||
| 208 | |||
| 209 | struct syscall_trace_exit { | ||
| 210 | struct trace_entry ent; | ||
| 211 | int nr; | ||
| 212 | unsigned long ret; | ||
| 213 | }; | ||
| 214 | |||
| 215 | |||
| 173 | /* | 216 | /* |
| 174 | * trace_flag_type is an enumeration that holds different | 217 | * trace_flag_type is an enumeration that holds different |
| 175 | * states when a trace occurs. These are: | 218 | * states when a trace occurs. These are: |
| 176 | * IRQS_OFF - interrupts were disabled | 219 | * IRQS_OFF - interrupts were disabled |
| 177 | * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags | 220 | * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags |
| 178 | * NEED_RESCED - reschedule is requested | 221 | * NEED_RESCED - reschedule is requested |
| 179 | * HARDIRQ - inside an interrupt handler | 222 | * HARDIRQ - inside an interrupt handler |
| 180 | * SOFTIRQ - inside a softirq handler | 223 | * SOFTIRQ - inside a softirq handler |
| 181 | * CONT - multiple entries hold the trace item | ||
| 182 | */ | 224 | */ |
| 183 | enum trace_flag_type { | 225 | enum trace_flag_type { |
| 184 | TRACE_FLAG_IRQS_OFF = 0x01, | 226 | TRACE_FLAG_IRQS_OFF = 0x01, |
| @@ -186,7 +228,6 @@ enum trace_flag_type { | |||
| 186 | TRACE_FLAG_NEED_RESCHED = 0x04, | 228 | TRACE_FLAG_NEED_RESCHED = 0x04, |
| 187 | TRACE_FLAG_HARDIRQ = 0x08, | 229 | TRACE_FLAG_HARDIRQ = 0x08, |
| 188 | TRACE_FLAG_SOFTIRQ = 0x10, | 230 | TRACE_FLAG_SOFTIRQ = 0x10, |
| 189 | TRACE_FLAG_CONT = 0x20, | ||
| 190 | }; | 231 | }; |
| 191 | 232 | ||
| 192 | #define TRACE_BUF_SIZE 1024 | 233 | #define TRACE_BUF_SIZE 1024 |
| @@ -198,6 +239,7 @@ enum trace_flag_type { | |||
| 198 | */ | 239 | */ |
| 199 | struct trace_array_cpu { | 240 | struct trace_array_cpu { |
| 200 | atomic_t disabled; | 241 | atomic_t disabled; |
| 242 | void *buffer_page; /* ring buffer spare */ | ||
| 201 | 243 | ||
| 202 | /* these fields get copied into max-trace: */ | 244 | /* these fields get copied into max-trace: */ |
| 203 | unsigned long trace_idx; | 245 | unsigned long trace_idx; |
| @@ -262,10 +304,10 @@ extern void __ftrace_bad_type(void); | |||
| 262 | do { \ | 304 | do { \ |
| 263 | IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN); \ | 305 | IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN); \ |
| 264 | IF_ASSIGN(var, ent, struct ctx_switch_entry, 0); \ | 306 | IF_ASSIGN(var, ent, struct ctx_switch_entry, 0); \ |
| 265 | IF_ASSIGN(var, ent, struct trace_field_cont, TRACE_CONT); \ | ||
| 266 | IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \ | 307 | IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \ |
| 267 | IF_ASSIGN(var, ent, struct userstack_entry, TRACE_USER_STACK);\ | 308 | IF_ASSIGN(var, ent, struct userstack_entry, TRACE_USER_STACK);\ |
| 268 | IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \ | 309 | IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \ |
| 310 | IF_ASSIGN(var, ent, struct bprint_entry, TRACE_BPRINT); \ | ||
| 269 | IF_ASSIGN(var, ent, struct special_entry, 0); \ | 311 | IF_ASSIGN(var, ent, struct special_entry, 0); \ |
| 270 | IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \ | 312 | IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \ |
| 271 | TRACE_MMIO_RW); \ | 313 | TRACE_MMIO_RW); \ |
| @@ -279,7 +321,15 @@ extern void __ftrace_bad_type(void); | |||
| 279 | IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \ | 321 | IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \ |
| 280 | TRACE_GRAPH_RET); \ | 322 | TRACE_GRAPH_RET); \ |
| 281 | IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\ | 323 | IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\ |
| 282 | IF_ASSIGN(var, ent, struct trace_power, TRACE_POWER); \ | 324 | IF_ASSIGN(var, ent, struct trace_power, TRACE_POWER); \ |
| 325 | IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry, \ | ||
| 326 | TRACE_KMEM_ALLOC); \ | ||
| 327 | IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \ | ||
| 328 | TRACE_KMEM_FREE); \ | ||
| 329 | IF_ASSIGN(var, ent, struct syscall_trace_enter, \ | ||
| 330 | TRACE_SYSCALL_ENTER); \ | ||
| 331 | IF_ASSIGN(var, ent, struct syscall_trace_exit, \ | ||
| 332 | TRACE_SYSCALL_EXIT); \ | ||
| 283 | __ftrace_bad_type(); \ | 333 | __ftrace_bad_type(); \ |
| 284 | } while (0) | 334 | } while (0) |
| 285 | 335 | ||
| @@ -287,7 +337,8 @@ extern void __ftrace_bad_type(void); | |||
| 287 | enum print_line_t { | 337 | enum print_line_t { |
| 288 | TRACE_TYPE_PARTIAL | ||
