Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 1 | /* |
| 2 | * trace_output.c |
| 3 | * |
| 4 | * Copyright (C) 2008 Red Hat Inc, Steven Rostedt <srostedt@redhat.com> |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include <linux/module.h> |
| 9 | #include <linux/mutex.h> |
| 10 | #include <linux/ftrace.h> |
| 11 | |
| 12 | #include "trace_output.h" |
| 13 | |
| 14 | /* must be a power of 2 */ |
| 15 | #define EVENT_HASHSIZE 128 |
| 16 | |
zhangwei(Jovi) | 52f6ad6 | 2013-03-11 15:14:03 +0800 | [diff] [blame] | 17 | DECLARE_RWSEM(trace_event_sem); |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 18 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 19 | static struct hlist_head event_hash[EVENT_HASHSIZE] __read_mostly; |
| 20 | |
| 21 | static int next_event_type = __TRACE_LAST_TYPE + 1; |
| 22 | |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 23 | enum print_line_t trace_print_bputs_msg_only(struct trace_iterator *iter) |
| 24 | { |
| 25 | struct trace_seq *s = &iter->seq; |
| 26 | struct trace_entry *entry = iter->ent; |
| 27 | struct bputs_entry *field; |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 28 | |
| 29 | trace_assign_type(field, entry); |
| 30 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 31 | trace_seq_puts(s, field->str); |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 32 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 33 | return trace_handle_return(s); |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 34 | } |
| 35 | |
Steven Rostedt | 5ef841f | 2009-03-19 12:20:38 -0400 | [diff] [blame] | 36 | enum print_line_t trace_print_bprintk_msg_only(struct trace_iterator *iter) |
| 37 | { |
| 38 | struct trace_seq *s = &iter->seq; |
| 39 | struct trace_entry *entry = iter->ent; |
| 40 | struct bprint_entry *field; |
Steven Rostedt | 5ef841f | 2009-03-19 12:20:38 -0400 | [diff] [blame] | 41 | |
| 42 | trace_assign_type(field, entry); |
| 43 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 44 | trace_seq_bprintf(s, field->fmt, field->buf); |
Steven Rostedt | 5ef841f | 2009-03-19 12:20:38 -0400 | [diff] [blame] | 45 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 46 | return trace_handle_return(s); |
Steven Rostedt | 5ef841f | 2009-03-19 12:20:38 -0400 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | enum print_line_t trace_print_printk_msg_only(struct trace_iterator *iter) |
| 50 | { |
| 51 | struct trace_seq *s = &iter->seq; |
| 52 | struct trace_entry *entry = iter->ent; |
| 53 | struct print_entry *field; |
Steven Rostedt | 5ef841f | 2009-03-19 12:20:38 -0400 | [diff] [blame] | 54 | |
| 55 | trace_assign_type(field, entry); |
| 56 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 57 | trace_seq_puts(s, field->buf); |
Steven Rostedt | 5ef841f | 2009-03-19 12:20:38 -0400 | [diff] [blame] | 58 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 59 | return trace_handle_return(s); |
Steven Rostedt | 5ef841f | 2009-03-19 12:20:38 -0400 | [diff] [blame] | 60 | } |
| 61 | |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 62 | const char * |
| 63 | ftrace_print_flags_seq(struct trace_seq *p, const char *delim, |
| 64 | unsigned long flags, |
| 65 | const struct trace_print_flags *flag_array) |
| 66 | { |
| 67 | unsigned long mask; |
| 68 | const char *str; |
Steven Rostedt (Red Hat) | 7b039cb | 2014-06-26 09:42:41 -0400 | [diff] [blame] | 69 | const char *ret = trace_seq_buffer_ptr(p); |
Andrey Vagin | e404b32 | 2012-02-19 14:16:07 +0300 | [diff] [blame] | 70 | int i, first = 1; |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 71 | |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 72 | for (i = 0; flag_array[i].name && flags; i++) { |
| 73 | |
| 74 | mask = flag_array[i].mask; |
| 75 | if ((flags & mask) != mask) |
| 76 | continue; |
| 77 | |
| 78 | str = flag_array[i].name; |
| 79 | flags &= ~mask; |
Andrey Vagin | e404b32 | 2012-02-19 14:16:07 +0300 | [diff] [blame] | 80 | if (!first && delim) |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 81 | trace_seq_puts(p, delim); |
Andrey Vagin | e404b32 | 2012-02-19 14:16:07 +0300 | [diff] [blame] | 82 | else |
| 83 | first = 0; |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 84 | trace_seq_puts(p, str); |
| 85 | } |
| 86 | |
| 87 | /* check for left over flags */ |
| 88 | if (flags) { |
Steven Rostedt | 5b34926 | 2012-02-20 20:37:32 -0500 | [diff] [blame] | 89 | if (!first && delim) |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 90 | trace_seq_puts(p, delim); |
| 91 | trace_seq_printf(p, "0x%lx", flags); |
| 92 | } |
| 93 | |
| 94 | trace_seq_putc(p, 0); |
| 95 | |
Steven Whitehouse | 56d8bd3 | 2009-06-03 14:52:03 +0100 | [diff] [blame] | 96 | return ret; |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 97 | } |
Steven Whitehouse | ec081dd | 2009-06-01 15:53:35 +0100 | [diff] [blame] | 98 | EXPORT_SYMBOL(ftrace_print_flags_seq); |
Steven Rostedt | be74b73 | 2009-05-26 20:25:22 +0200 | [diff] [blame] | 99 | |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 100 | const char * |
| 101 | ftrace_print_symbols_seq(struct trace_seq *p, unsigned long val, |
| 102 | const struct trace_print_flags *symbol_array) |
| 103 | { |
| 104 | int i; |
Steven Rostedt (Red Hat) | 7b039cb | 2014-06-26 09:42:41 -0400 | [diff] [blame] | 105 | const char *ret = trace_seq_buffer_ptr(p); |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 106 | |
| 107 | for (i = 0; symbol_array[i].name; i++) { |
| 108 | |
| 109 | if (val != symbol_array[i].mask) |
| 110 | continue; |
| 111 | |
| 112 | trace_seq_puts(p, symbol_array[i].name); |
| 113 | break; |
| 114 | } |
| 115 | |
Steven Rostedt (Red Hat) | 7b039cb | 2014-06-26 09:42:41 -0400 | [diff] [blame] | 116 | if (ret == (const char *)(trace_seq_buffer_ptr(p))) |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 117 | trace_seq_printf(p, "0x%lx", val); |
Byungchul Park | 8e1e1df | 2014-11-24 09:34:19 +0900 | [diff] [blame] | 118 | |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 119 | trace_seq_putc(p, 0); |
| 120 | |
Steven Whitehouse | 56d8bd3 | 2009-06-03 14:52:03 +0100 | [diff] [blame] | 121 | return ret; |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 122 | } |
Steven Whitehouse | ec081dd | 2009-06-01 15:53:35 +0100 | [diff] [blame] | 123 | EXPORT_SYMBOL(ftrace_print_symbols_seq); |
Steven Rostedt | 0f4fc29 | 2009-05-20 19:21:47 -0400 | [diff] [blame] | 124 | |
liubo | 2fc1b6f | 2011-04-19 09:35:28 +0800 | [diff] [blame] | 125 | #if BITS_PER_LONG == 32 |
| 126 | const char * |
| 127 | ftrace_print_symbols_seq_u64(struct trace_seq *p, unsigned long long val, |
| 128 | const struct trace_print_flags_u64 *symbol_array) |
| 129 | { |
| 130 | int i; |
Steven Rostedt (Red Hat) | 7b039cb | 2014-06-26 09:42:41 -0400 | [diff] [blame] | 131 | const char *ret = trace_seq_buffer_ptr(p); |
liubo | 2fc1b6f | 2011-04-19 09:35:28 +0800 | [diff] [blame] | 132 | |
| 133 | for (i = 0; symbol_array[i].name; i++) { |
| 134 | |
| 135 | if (val != symbol_array[i].mask) |
| 136 | continue; |
| 137 | |
| 138 | trace_seq_puts(p, symbol_array[i].name); |
| 139 | break; |
| 140 | } |
| 141 | |
Steven Rostedt (Red Hat) | 7b039cb | 2014-06-26 09:42:41 -0400 | [diff] [blame] | 142 | if (ret == (const char *)(trace_seq_buffer_ptr(p))) |
liubo | 2fc1b6f | 2011-04-19 09:35:28 +0800 | [diff] [blame] | 143 | trace_seq_printf(p, "0x%llx", val); |
| 144 | |
| 145 | trace_seq_putc(p, 0); |
| 146 | |
| 147 | return ret; |
| 148 | } |
| 149 | EXPORT_SYMBOL(ftrace_print_symbols_seq_u64); |
| 150 | #endif |
| 151 | |
Kei Tokunaga | 5a2e399 | 2010-04-01 20:40:58 +0900 | [diff] [blame] | 152 | const char * |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 153 | ftrace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr, |
| 154 | unsigned int bitmask_size) |
| 155 | { |
Steven Rostedt (Red Hat) | 7b039cb | 2014-06-26 09:42:41 -0400 | [diff] [blame] | 156 | const char *ret = trace_seq_buffer_ptr(p); |
Steven Rostedt (Red Hat) | 4449bf9 | 2014-05-06 13:10:24 -0400 | [diff] [blame] | 157 | |
| 158 | trace_seq_bitmask(p, bitmask_ptr, bitmask_size * 8); |
| 159 | trace_seq_putc(p, 0); |
| 160 | |
| 161 | return ret; |
| 162 | } |
| 163 | EXPORT_SYMBOL_GPL(ftrace_print_bitmask_seq); |
| 164 | |
| 165 | const char * |
Kei Tokunaga | 5a2e399 | 2010-04-01 20:40:58 +0900 | [diff] [blame] | 166 | ftrace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len) |
| 167 | { |
| 168 | int i; |
Steven Rostedt (Red Hat) | 7b039cb | 2014-06-26 09:42:41 -0400 | [diff] [blame] | 169 | const char *ret = trace_seq_buffer_ptr(p); |
Kei Tokunaga | 5a2e399 | 2010-04-01 20:40:58 +0900 | [diff] [blame] | 170 | |
| 171 | for (i = 0; i < buf_len; i++) |
| 172 | trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]); |
| 173 | |
| 174 | trace_seq_putc(p, 0); |
| 175 | |
| 176 | return ret; |
| 177 | } |
| 178 | EXPORT_SYMBOL(ftrace_print_hex_seq); |
| 179 | |
Dave Martin | 6ea2248 | 2015-01-28 12:48:53 +0000 | [diff] [blame^] | 180 | const char * |
| 181 | ftrace_print_array_seq(struct trace_seq *p, const void *buf, int buf_len, |
| 182 | size_t el_size) |
| 183 | { |
| 184 | const char *ret = trace_seq_buffer_ptr(p); |
| 185 | const char *prefix = ""; |
| 186 | void *ptr = (void *)buf; |
| 187 | |
| 188 | trace_seq_putc(p, '{'); |
| 189 | |
| 190 | while (ptr < buf + buf_len) { |
| 191 | switch (el_size) { |
| 192 | case 1: |
| 193 | trace_seq_printf(p, "%s0x%x", prefix, |
| 194 | *(u8 *)ptr); |
| 195 | break; |
| 196 | case 2: |
| 197 | trace_seq_printf(p, "%s0x%x", prefix, |
| 198 | *(u16 *)ptr); |
| 199 | break; |
| 200 | case 4: |
| 201 | trace_seq_printf(p, "%s0x%x", prefix, |
| 202 | *(u32 *)ptr); |
| 203 | break; |
| 204 | case 8: |
| 205 | trace_seq_printf(p, "%s0x%llx", prefix, |
| 206 | *(u64 *)ptr); |
| 207 | break; |
| 208 | default: |
| 209 | trace_seq_printf(p, "BAD SIZE:%zu 0x%x", el_size, |
| 210 | *(u8 *)ptr); |
| 211 | el_size = 1; |
| 212 | } |
| 213 | prefix = ","; |
| 214 | ptr += el_size; |
| 215 | } |
| 216 | |
| 217 | trace_seq_putc(p, '}'); |
| 218 | trace_seq_putc(p, 0); |
| 219 | |
| 220 | return ret; |
| 221 | } |
| 222 | EXPORT_SYMBOL(ftrace_print_array_seq); |
| 223 | |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 224 | int ftrace_raw_output_prep(struct trace_iterator *iter, |
| 225 | struct trace_event *trace_event) |
| 226 | { |
| 227 | struct ftrace_event_call *event; |
| 228 | struct trace_seq *s = &iter->seq; |
| 229 | struct trace_seq *p = &iter->tmp_seq; |
| 230 | struct trace_entry *entry; |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 231 | |
| 232 | event = container_of(trace_event, struct ftrace_event_call, event); |
| 233 | entry = iter->ent; |
| 234 | |
| 235 | if (entry->type != event->event.type) { |
| 236 | WARN_ON_ONCE(1); |
| 237 | return TRACE_TYPE_UNHANDLED; |
| 238 | } |
| 239 | |
| 240 | trace_seq_init(p); |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 241 | trace_seq_printf(s, "%s: ", ftrace_event_name(event)); |
| 242 | |
Steven Rostedt (Red Hat) | 8e2e095 | 2014-11-14 11:42:06 -0500 | [diff] [blame] | 243 | return trace_handle_return(s); |
Li Zefan | f71130d | 2013-02-21 10:32:38 +0800 | [diff] [blame] | 244 | } |
| 245 | EXPORT_SYMBOL(ftrace_raw_output_prep); |
| 246 | |
Steven Rostedt | 1d6bae9 | 2012-08-09 19:16:14 -0400 | [diff] [blame] | 247 | static int ftrace_output_raw(struct trace_iterator *iter, char *name, |
| 248 | char *fmt, va_list ap) |
| 249 | { |
| 250 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | 1d6bae9 | 2012-08-09 19:16:14 -0400 | [diff] [blame] | 251 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 252 | trace_seq_printf(s, "%s: ", name); |
| 253 | trace_seq_vprintf(s, fmt, ap); |
Steven Rostedt | 1d6bae9 | 2012-08-09 19:16:14 -0400 | [diff] [blame] | 254 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 255 | return trace_handle_return(s); |
Steven Rostedt | 1d6bae9 | 2012-08-09 19:16:14 -0400 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | int ftrace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...) |
| 259 | { |
| 260 | va_list ap; |
| 261 | int ret; |
| 262 | |
| 263 | va_start(ap, fmt); |
| 264 | ret = ftrace_output_raw(iter, name, fmt, ap); |
| 265 | va_end(ap); |
| 266 | |
| 267 | return ret; |
| 268 | } |
| 269 | EXPORT_SYMBOL_GPL(ftrace_output_call); |
| 270 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 271 | #ifdef CONFIG_KRETPROBES |
| 272 | static inline const char *kretprobed(const char *name) |
| 273 | { |
| 274 | static const char tramp_name[] = "kretprobe_trampoline"; |
| 275 | int size = sizeof(tramp_name); |
| 276 | |
| 277 | if (strncmp(tramp_name, name, size) == 0) |
| 278 | return "[unknown/kretprobe'd]"; |
| 279 | return name; |
| 280 | } |
| 281 | #else |
| 282 | static inline const char *kretprobed(const char *name) |
| 283 | { |
| 284 | return name; |
| 285 | } |
| 286 | #endif /* CONFIG_KRETPROBES */ |
| 287 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 288 | static void |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 289 | seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address) |
| 290 | { |
| 291 | #ifdef CONFIG_KALLSYMS |
| 292 | char str[KSYM_SYMBOL_LEN]; |
| 293 | const char *name; |
| 294 | |
| 295 | kallsyms_lookup(address, NULL, NULL, NULL, str); |
| 296 | |
| 297 | name = kretprobed(str); |
| 298 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 299 | trace_seq_printf(s, fmt, name); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 300 | #endif |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 301 | } |
| 302 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 303 | static void |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 304 | seq_print_sym_offset(struct trace_seq *s, const char *fmt, |
| 305 | unsigned long address) |
| 306 | { |
| 307 | #ifdef CONFIG_KALLSYMS |
| 308 | char str[KSYM_SYMBOL_LEN]; |
| 309 | const char *name; |
| 310 | |
| 311 | sprint_symbol(str, address); |
| 312 | name = kretprobed(str); |
| 313 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 314 | trace_seq_printf(s, fmt, name); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 315 | #endif |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | #ifndef CONFIG_64BIT |
| 319 | # define IP_FMT "%08lx" |
| 320 | #else |
| 321 | # define IP_FMT "%016lx" |
| 322 | #endif |
| 323 | |
| 324 | int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm, |
| 325 | unsigned long ip, unsigned long sym_flags) |
| 326 | { |
| 327 | struct file *file = NULL; |
| 328 | unsigned long vmstart = 0; |
| 329 | int ret = 1; |
| 330 | |
Johannes Berg | d184b31 | 2009-11-25 16:10:14 +0100 | [diff] [blame] | 331 | if (s->full) |
| 332 | return 0; |
| 333 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 334 | if (mm) { |
| 335 | const struct vm_area_struct *vma; |
| 336 | |
| 337 | down_read(&mm->mmap_sem); |
| 338 | vma = find_vma(mm, ip); |
| 339 | if (vma) { |
| 340 | file = vma->vm_file; |
| 341 | vmstart = vma->vm_start; |
| 342 | } |
| 343 | if (file) { |
| 344 | ret = trace_seq_path(s, &file->f_path); |
| 345 | if (ret) |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 346 | trace_seq_printf(s, "[+0x%lx]", |
| 347 | ip - vmstart); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 348 | } |
| 349 | up_read(&mm->mmap_sem); |
| 350 | } |
| 351 | if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file)) |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 352 | trace_seq_printf(s, " <" IP_FMT ">", ip); |
| 353 | return !trace_seq_has_overflowed(s); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | int |
| 357 | seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s, |
| 358 | unsigned long sym_flags) |
| 359 | { |
| 360 | struct mm_struct *mm = NULL; |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 361 | unsigned int i; |
| 362 | |
| 363 | if (trace_flags & TRACE_ITER_SYM_USEROBJ) { |
| 364 | struct task_struct *task; |
| 365 | /* |
| 366 | * we do the lookup on the thread group leader, |
| 367 | * since individual threads might have already quit! |
| 368 | */ |
| 369 | rcu_read_lock(); |
Steven Rostedt | 48659d3 | 2009-09-11 11:36:23 -0400 | [diff] [blame] | 370 | task = find_task_by_vpid(entry->tgid); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 371 | if (task) |
| 372 | mm = get_task_mm(task); |
| 373 | rcu_read_unlock(); |
| 374 | } |
| 375 | |
| 376 | for (i = 0; i < FTRACE_STACK_ENTRIES; i++) { |
| 377 | unsigned long ip = entry->caller[i]; |
| 378 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 379 | if (ip == ULONG_MAX || trace_seq_has_overflowed(s)) |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 380 | break; |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 381 | |
| 382 | trace_seq_puts(s, " => "); |
| 383 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 384 | if (!ip) { |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 385 | trace_seq_puts(s, "??"); |
| 386 | trace_seq_putc(s, '\n'); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 387 | continue; |
| 388 | } |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 389 | |
| 390 | seq_print_user_ip(s, mm, ip, sym_flags); |
| 391 | trace_seq_putc(s, '\n'); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | if (mm) |
| 395 | mmput(mm); |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 396 | |
| 397 | return !trace_seq_has_overflowed(s); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | int |
| 401 | seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags) |
| 402 | { |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 403 | if (!ip) { |
| 404 | trace_seq_putc(s, '0'); |
| 405 | goto out; |
| 406 | } |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 407 | |
| 408 | if (sym_flags & TRACE_ITER_SYM_OFFSET) |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 409 | seq_print_sym_offset(s, "%s", ip); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 410 | else |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 411 | seq_print_sym_short(s, "%s", ip); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 412 | |
| 413 | if (sym_flags & TRACE_ITER_SYM_ADDR) |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 414 | trace_seq_printf(s, " <" IP_FMT ">", ip); |
| 415 | |
| 416 | out: |
| 417 | return !trace_seq_has_overflowed(s); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 418 | } |
| 419 | |
Steven Rostedt | f81c972 | 2009-09-11 14:24:13 -0400 | [diff] [blame] | 420 | /** |
| 421 | * trace_print_lat_fmt - print the irq, preempt and lockdep fields |
| 422 | * @s: trace seq struct to write to |
| 423 | * @entry: The trace entry field from the ring buffer |
| 424 | * |
| 425 | * Prints the generic fields of irqs off, in hard or softirq, preempt |
Steven Rostedt | e6e1e25 | 2011-03-09 10:41:56 -0500 | [diff] [blame] | 426 | * count. |
Steven Rostedt | f81c972 | 2009-09-11 14:24:13 -0400 | [diff] [blame] | 427 | */ |
| 428 | int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry) |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 429 | { |
David Sharp | 10da37a | 2010-12-03 16:13:26 -0800 | [diff] [blame] | 430 | char hardsoft_irq; |
| 431 | char need_resched; |
| 432 | char irqs_off; |
| 433 | int hardirq; |
| 434 | int softirq; |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 435 | |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 436 | hardirq = entry->flags & TRACE_FLAG_HARDIRQ; |
| 437 | softirq = entry->flags & TRACE_FLAG_SOFTIRQ; |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 438 | |
David Sharp | 10da37a | 2010-12-03 16:13:26 -0800 | [diff] [blame] | 439 | irqs_off = |
| 440 | (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' : |
| 441 | (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 'X' : |
| 442 | '.'; |
Peter Zijlstra | e5137b5 | 2013-10-04 17:28:26 +0200 | [diff] [blame] | 443 | |
| 444 | switch (entry->flags & (TRACE_FLAG_NEED_RESCHED | |
| 445 | TRACE_FLAG_PREEMPT_RESCHED)) { |
| 446 | case TRACE_FLAG_NEED_RESCHED | TRACE_FLAG_PREEMPT_RESCHED: |
| 447 | need_resched = 'N'; |
| 448 | break; |
| 449 | case TRACE_FLAG_NEED_RESCHED: |
| 450 | need_resched = 'n'; |
| 451 | break; |
| 452 | case TRACE_FLAG_PREEMPT_RESCHED: |
| 453 | need_resched = 'p'; |
| 454 | break; |
| 455 | default: |
| 456 | need_resched = '.'; |
| 457 | break; |
| 458 | } |
| 459 | |
David Sharp | 10da37a | 2010-12-03 16:13:26 -0800 | [diff] [blame] | 460 | hardsoft_irq = |
| 461 | (hardirq && softirq) ? 'H' : |
| 462 | hardirq ? 'h' : |
| 463 | softirq ? 's' : |
| 464 | '.'; |
| 465 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 466 | trace_seq_printf(s, "%c%c%c", |
| 467 | irqs_off, need_resched, hardsoft_irq); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 468 | |
Steven Rostedt | 829b876 | 2009-09-27 07:02:07 -0400 | [diff] [blame] | 469 | if (entry->preempt_count) |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 470 | trace_seq_printf(s, "%x", entry->preempt_count); |
Steven Rostedt | 637e7e8 | 2009-09-11 13:55:35 -0400 | [diff] [blame] | 471 | else |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 472 | trace_seq_putc(s, '.'); |
Steven Rostedt | 829b876 | 2009-09-27 07:02:07 -0400 | [diff] [blame] | 473 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 474 | return !trace_seq_has_overflowed(s); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 475 | } |
| 476 | |
Steven Rostedt | f81c972 | 2009-09-11 14:24:13 -0400 | [diff] [blame] | 477 | static int |
| 478 | lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu) |
| 479 | { |
| 480 | char comm[TASK_COMM_LEN]; |
| 481 | |
| 482 | trace_find_cmdline(entry->pid, comm); |
| 483 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 484 | trace_seq_printf(s, "%8.8s-%-5d %3d", |
| 485 | comm, entry->pid, cpu); |
Steven Rostedt | f81c972 | 2009-09-11 14:24:13 -0400 | [diff] [blame] | 486 | |
| 487 | return trace_print_lat_fmt(s, entry); |
| 488 | } |
| 489 | |
Byungchul Park | 8e1e1df | 2014-11-24 09:34:19 +0900 | [diff] [blame] | 490 | #undef MARK |
| 491 | #define MARK(v, s) {.val = v, .sym = s} |
| 492 | /* trace overhead mark */ |
| 493 | static const struct trace_mark { |
| 494 | unsigned long long val; /* unit: nsec */ |
| 495 | char sym; |
| 496 | } mark[] = { |
| 497 | MARK(1000000000ULL , '$'), /* 1 sec */ |
| 498 | MARK(1000000ULL , '#'), /* 1000 usecs */ |
| 499 | MARK(100000ULL , '!'), /* 100 usecs */ |
| 500 | MARK(10000ULL , '+'), /* 10 usecs */ |
| 501 | }; |
| 502 | #undef MARK |
| 503 | |
| 504 | char trace_find_mark(unsigned long long d) |
| 505 | { |
| 506 | int i; |
| 507 | int size = ARRAY_SIZE(mark); |
| 508 | |
| 509 | for (i = 0; i < size; i++) { |
| 510 | if (d >= mark[i].val) |
| 511 | break; |
| 512 | } |
| 513 | |
| 514 | return (i == size) ? ' ' : mark[i].sym; |
| 515 | } |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 516 | |
Arnaldo Carvalho de Melo | d9793bd | 2009-02-03 20:20:41 -0200 | [diff] [blame] | 517 | static int |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 518 | lat_print_timestamp(struct trace_iterator *iter, u64 next_ts) |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 519 | { |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 520 | unsigned long verbose = trace_flags & TRACE_ITER_VERBOSE; |
| 521 | unsigned long in_ns = iter->iter_flags & TRACE_FILE_TIME_IN_NS; |
Steven Rostedt (Red Hat) | 12883ef | 2013-03-05 09:24:35 -0500 | [diff] [blame] | 522 | unsigned long long abs_ts = iter->ts - iter->trace_buffer->time_start; |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 523 | unsigned long long rel_ts = next_ts - iter->ts; |
| 524 | struct trace_seq *s = &iter->seq; |
| 525 | |
| 526 | if (in_ns) { |
| 527 | abs_ts = ns2usecs(abs_ts); |
| 528 | rel_ts = ns2usecs(rel_ts); |
| 529 | } |
| 530 | |
| 531 | if (verbose && in_ns) { |
| 532 | unsigned long abs_usec = do_div(abs_ts, USEC_PER_MSEC); |
| 533 | unsigned long abs_msec = (unsigned long)abs_ts; |
| 534 | unsigned long rel_usec = do_div(rel_ts, USEC_PER_MSEC); |
| 535 | unsigned long rel_msec = (unsigned long)rel_ts; |
| 536 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 537 | trace_seq_printf( |
| 538 | s, "[%08llx] %ld.%03ldms (+%ld.%03ldms): ", |
| 539 | ns2usecs(iter->ts), |
| 540 | abs_msec, abs_usec, |
| 541 | rel_msec, rel_usec); |
| 542 | |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 543 | } else if (verbose && !in_ns) { |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 544 | trace_seq_printf( |
| 545 | s, "[%016llx] %lld (+%lld): ", |
| 546 | iter->ts, abs_ts, rel_ts); |
| 547 | |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 548 | } else if (!verbose && in_ns) { |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 549 | trace_seq_printf( |
| 550 | s, " %4lldus%c: ", |
| 551 | abs_ts, |
Byungchul Park | 8e1e1df | 2014-11-24 09:34:19 +0900 | [diff] [blame] | 552 | trace_find_mark(rel_ts * NSEC_PER_USEC)); |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 553 | |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 554 | } else { /* !verbose && !in_ns */ |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 555 | trace_seq_printf(s, " %4lld: ", abs_ts); |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 556 | } |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 557 | |
| 558 | return !trace_seq_has_overflowed(s); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 559 | } |
| 560 | |
| 561 | int trace_print_context(struct trace_iterator *iter) |
| 562 | { |
| 563 | struct trace_seq *s = &iter->seq; |
| 564 | struct trace_entry *entry = iter->ent; |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 565 | unsigned long long t; |
| 566 | unsigned long secs, usec_rem; |
Steven Rostedt | 4ca53085 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 567 | char comm[TASK_COMM_LEN]; |
| 568 | |
| 569 | trace_find_cmdline(entry->pid, comm); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 570 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 571 | trace_seq_printf(s, "%16s-%-5d [%03d] ", |
Steven Rostedt | 77271ce | 2011-11-17 09:34:33 -0500 | [diff] [blame] | 572 | comm, entry->pid, iter->cpu); |
Steven Rostedt | 77271ce | 2011-11-17 09:34:33 -0500 | [diff] [blame] | 573 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 574 | if (trace_flags & TRACE_ITER_IRQ_INFO) |
| 575 | trace_print_lat_fmt(s, entry); |
Steven Rostedt | 77271ce | 2011-11-17 09:34:33 -0500 | [diff] [blame] | 576 | |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 577 | if (iter->iter_flags & TRACE_FILE_TIME_IN_NS) { |
| 578 | t = ns2usecs(iter->ts); |
| 579 | usec_rem = do_div(t, USEC_PER_SEC); |
| 580 | secs = (unsigned long)t; |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 581 | trace_seq_printf(s, " %5lu.%06lu: ", secs, usec_rem); |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 582 | } else |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 583 | trace_seq_printf(s, " %12llu: ", iter->ts); |
| 584 | |
| 585 | return !trace_seq_has_overflowed(s); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 586 | } |
| 587 | |
| 588 | int trace_print_lat_context(struct trace_iterator *iter) |
| 589 | { |
| 590 | u64 next_ts; |
Steven Rostedt | db4c75c | 2012-04-19 10:31:47 -0400 | [diff] [blame] | 591 | /* trace_find_next_entry will reset ent_size */ |
| 592 | int ent_size = iter->ent_size; |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 593 | struct trace_seq *s = &iter->seq; |
| 594 | struct trace_entry *entry = iter->ent, |
| 595 | *next_entry = trace_find_next_entry(iter, NULL, |
| 596 | &next_ts); |
| 597 | unsigned long verbose = (trace_flags & TRACE_ITER_VERBOSE); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 598 | |
Steven Rostedt | db4c75c | 2012-04-19 10:31:47 -0400 | [diff] [blame] | 599 | /* Restore the original ent_size */ |
| 600 | iter->ent_size = ent_size; |
| 601 | |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 602 | if (!next_entry) |
| 603 | next_ts = iter->ts; |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 604 | |
| 605 | if (verbose) { |
Steven Rostedt | 4ca53085 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 606 | char comm[TASK_COMM_LEN]; |
| 607 | |
| 608 | trace_find_cmdline(entry->pid, comm); |
| 609 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 610 | trace_seq_printf( |
| 611 | s, "%16s %5d %3d %d %08x %08lx ", |
| 612 | comm, entry->pid, iter->cpu, entry->flags, |
| 613 | entry->preempt_count, iter->idx); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 614 | } else { |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 615 | lat_print_generic(s, entry, iter->cpu); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 616 | } |
| 617 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 618 | lat_print_timestamp(iter, next_ts); |
David Sharp | 8be0709 | 2012-11-13 12:18:22 -0800 | [diff] [blame] | 619 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 620 | return !trace_seq_has_overflowed(s); |
Frederic Weisbecker | c4a8e8b | 2009-02-02 20:29:21 -0200 | [diff] [blame] | 621 | } |
| 622 | |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 623 | static const char state_to_char[] = TASK_STATE_TO_CHAR_STR; |
| 624 | |
| 625 | static int task_state_char(unsigned long state) |
| 626 | { |
| 627 | int bit = state ? __ffs(state) + 1 : 0; |
| 628 | |
| 629 | return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?'; |
| 630 | } |
| 631 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 632 | /** |
| 633 | * ftrace_find_event - find a registered event |
| 634 | * @type: the type of event to look for |
| 635 | * |
| 636 | * Returns an event of type @type otherwise NULL |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 637 | * Called with trace_event_read_lock() held. |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 638 | */ |
| 639 | struct trace_event *ftrace_find_event(int type) |
| 640 | { |
| 641 | struct trace_event *event; |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 642 | unsigned key; |
| 643 | |
| 644 | key = type & (EVENT_HASHSIZE - 1); |
| 645 | |
Sasha Levin | b67bfe0 | 2013-02-27 17:06:00 -0800 | [diff] [blame] | 646 | hlist_for_each_entry(event, &event_hash[key], node) { |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 647 | if (event->type == type) |
| 648 | return event; |
| 649 | } |
| 650 | |
| 651 | return NULL; |
| 652 | } |
| 653 | |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 654 | static LIST_HEAD(ftrace_event_list); |
| 655 | |
| 656 | static int trace_search_list(struct list_head **list) |
| 657 | { |
| 658 | struct trace_event *e; |
| 659 | int last = __TRACE_LAST_TYPE; |
| 660 | |
| 661 | if (list_empty(&ftrace_event_list)) { |
| 662 | *list = &ftrace_event_list; |
| 663 | return last + 1; |
| 664 | } |
| 665 | |
| 666 | /* |
| 667 | * We used up all possible max events, |
| 668 | * lets see if somebody freed one. |
| 669 | */ |
| 670 | list_for_each_entry(e, &ftrace_event_list, list) { |
| 671 | if (e->type != last + 1) |
| 672 | break; |
| 673 | last++; |
| 674 | } |
| 675 | |
| 676 | /* Did we used up all 65 thousand events??? */ |
| 677 | if ((last + 1) > FTRACE_MAX_EVENT) |
| 678 | return 0; |
| 679 | |
| 680 | *list = &e->list; |
| 681 | return last + 1; |
| 682 | } |
| 683 | |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 684 | void trace_event_read_lock(void) |
| 685 | { |
zhangwei(Jovi) | 52f6ad6 | 2013-03-11 15:14:03 +0800 | [diff] [blame] | 686 | down_read(&trace_event_sem); |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 687 | } |
| 688 | |
| 689 | void trace_event_read_unlock(void) |
| 690 | { |
zhangwei(Jovi) | 52f6ad6 | 2013-03-11 15:14:03 +0800 | [diff] [blame] | 691 | up_read(&trace_event_sem); |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 692 | } |
| 693 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 694 | /** |
| 695 | * register_ftrace_event - register output for an event type |
| 696 | * @event: the event type to register |
| 697 | * |
| 698 | * Event types are stored in a hash and this hash is used to |
| 699 | * find a way to print an event. If the @event->type is set |
| 700 | * then it will use that type, otherwise it will assign a |
| 701 | * type to use. |
| 702 | * |
| 703 | * If you assign your own type, please make sure it is added |
| 704 | * to the trace_type enum in trace.h, to avoid collisions |
| 705 | * with the dynamic types. |
| 706 | * |
| 707 | * Returns the event type number or zero on error. |
| 708 | */ |
| 709 | int register_ftrace_event(struct trace_event *event) |
| 710 | { |
| 711 | unsigned key; |
| 712 | int ret = 0; |
| 713 | |
zhangwei(Jovi) | 52f6ad6 | 2013-03-11 15:14:03 +0800 | [diff] [blame] | 714 | down_write(&trace_event_sem); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 715 | |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 716 | if (WARN_ON(!event)) |
Peter Zijlstra | 28bea27 | 2009-03-19 20:26:14 +0100 | [diff] [blame] | 717 | goto out; |
Peter Zijlstra | 28bea27 | 2009-03-19 20:26:14 +0100 | [diff] [blame] | 718 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 719 | if (WARN_ON(!event->funcs)) |
| 720 | goto out; |
| 721 | |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 722 | INIT_LIST_HEAD(&event->list); |
| 723 | |
| 724 | if (!event->type) { |
Jaswinder Singh Rajput | 48dd0fe | 2009-05-06 15:45:45 +0530 | [diff] [blame] | 725 | struct list_head *list = NULL; |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 726 | |
| 727 | if (next_event_type > FTRACE_MAX_EVENT) { |
| 728 | |
| 729 | event->type = trace_search_list(&list); |
| 730 | if (!event->type) |
| 731 | goto out; |
| 732 | |
| 733 | } else { |
Byungchul Park | 8e1e1df | 2014-11-24 09:34:19 +0900 | [diff] [blame] | 734 | |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 735 | event->type = next_event_type++; |
| 736 | list = &ftrace_event_list; |
| 737 | } |
| 738 | |
| 739 | if (WARN_ON(ftrace_find_event(event->type))) |
| 740 | goto out; |
| 741 | |
| 742 | list_add_tail(&event->list, list); |
| 743 | |
| 744 | } else if (event->type > __TRACE_LAST_TYPE) { |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 745 | printk(KERN_WARNING "Need to add type to trace.h\n"); |
| 746 | WARN_ON(1); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 747 | goto out; |
Steven Rostedt | 060fa5c8 | 2009-04-24 12:20:52 -0400 | [diff] [blame] | 748 | } else { |
| 749 | /* Is this event already used */ |
| 750 | if (ftrace_find_event(event->type)) |
| 751 | goto out; |
| 752 | } |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 753 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 754 | if (event->funcs->trace == NULL) |
| 755 | event->funcs->trace = trace_nop_print; |
| 756 | if (event->funcs->raw == NULL) |
| 757 | event->funcs->raw = trace_nop_print; |
| 758 | if (event->funcs->hex == NULL) |
| 759 | event->funcs->hex = trace_nop_print; |
| 760 | if (event->funcs->binary == NULL) |
| 761 | event->funcs->binary = trace_nop_print; |
Arnaldo Carvalho de Melo | 268ccda | 2009-02-04 20:16:39 -0200 | [diff] [blame] | 762 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 763 | key = event->type & (EVENT_HASHSIZE - 1); |
| 764 | |
Lai Jiangshan | 4f53596 | 2009-05-18 19:35:34 +0800 | [diff] [blame] | 765 | hlist_add_head(&event->node, &event_hash[key]); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 766 | |
| 767 | ret = event->type; |
| 768 | out: |
zhangwei(Jovi) | 52f6ad6 | 2013-03-11 15:14:03 +0800 | [diff] [blame] | 769 | up_write(&trace_event_sem); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 770 | |
| 771 | return ret; |
| 772 | } |
Steven Rostedt | 17c873e | 2009-04-10 18:12:50 -0400 | [diff] [blame] | 773 | EXPORT_SYMBOL_GPL(register_ftrace_event); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 774 | |
Steven Rostedt | 110bf2b | 2009-06-09 17:29:07 -0400 | [diff] [blame] | 775 | /* |
zhangwei(Jovi) | 52f6ad6 | 2013-03-11 15:14:03 +0800 | [diff] [blame] | 776 | * Used by module code with the trace_event_sem held for write. |
Steven Rostedt | 110bf2b | 2009-06-09 17:29:07 -0400 | [diff] [blame] | 777 | */ |
| 778 | int __unregister_ftrace_event(struct trace_event *event) |
| 779 | { |
| 780 | hlist_del(&event->node); |
| 781 | list_del(&event->list); |
| 782 | return 0; |
| 783 | } |
| 784 | |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 785 | /** |
| 786 | * unregister_ftrace_event - remove a no longer used event |
| 787 | * @event: the event to remove |
| 788 | */ |
| 789 | int unregister_ftrace_event(struct trace_event *event) |
| 790 | { |
zhangwei(Jovi) | 52f6ad6 | 2013-03-11 15:14:03 +0800 | [diff] [blame] | 791 | down_write(&trace_event_sem); |
Steven Rostedt | 110bf2b | 2009-06-09 17:29:07 -0400 | [diff] [blame] | 792 | __unregister_ftrace_event(event); |
zhangwei(Jovi) | 52f6ad6 | 2013-03-11 15:14:03 +0800 | [diff] [blame] | 793 | up_write(&trace_event_sem); |
Steven Rostedt | f0868d1 | 2008-12-23 23:24:12 -0500 | [diff] [blame] | 794 | |
| 795 | return 0; |
| 796 | } |
Steven Rostedt | 17c873e | 2009-04-10 18:12:50 -0400 | [diff] [blame] | 797 | EXPORT_SYMBOL_GPL(unregister_ftrace_event); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 798 | |
| 799 | /* |
| 800 | * Standard events |
| 801 | */ |
| 802 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 803 | enum print_line_t trace_nop_print(struct trace_iterator *iter, int flags, |
| 804 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 805 | { |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 806 | trace_seq_printf(&iter->seq, "type: %d\n", iter->ent->type); |
Jiri Olsa | ee5e51f | 2011-03-25 12:05:18 +0100 | [diff] [blame] | 807 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 808 | return trace_handle_return(&iter->seq); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | /* TRACE_FN */ |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 812 | static enum print_line_t trace_fn_trace(struct trace_iterator *iter, int flags, |
| 813 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 814 | { |
| 815 | struct ftrace_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 816 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 817 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 818 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 819 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 820 | seq_print_ip_sym(s, field->ip, flags); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 821 | |
| 822 | if ((flags & TRACE_ITER_PRINT_PARENT) && field->parent_ip) { |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 823 | trace_seq_puts(s, " <-"); |
| 824 | seq_print_ip_sym(s, field->parent_ip, flags); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 825 | } |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 826 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 827 | trace_seq_putc(s, '\n'); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 828 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 829 | return trace_handle_return(s); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 830 | } |
| 831 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 832 | static enum print_line_t trace_fn_raw(struct trace_iterator *iter, int flags, |
| 833 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 834 | { |
| 835 | struct ftrace_entry *field; |
| 836 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 837 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 838 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 839 | trace_seq_printf(&iter->seq, "%lx %lx\n", |
| 840 | field->ip, |
| 841 | field->parent_ip); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 842 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 843 | return trace_handle_return(&iter->seq); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 844 | } |
| 845 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 846 | static enum print_line_t trace_fn_hex(struct trace_iterator *iter, int flags, |
| 847 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 848 | { |
| 849 | struct ftrace_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 850 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 851 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 852 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 853 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 854 | SEQ_PUT_HEX_FIELD(s, field->ip); |
| 855 | SEQ_PUT_HEX_FIELD(s, field->parent_ip); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 856 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 857 | return trace_handle_return(s); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 858 | } |
| 859 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 860 | static enum print_line_t trace_fn_bin(struct trace_iterator *iter, int flags, |
| 861 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 862 | { |
| 863 | struct ftrace_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 864 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 865 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 866 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 867 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 868 | SEQ_PUT_FIELD(s, field->ip); |
| 869 | SEQ_PUT_FIELD(s, field->parent_ip); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 870 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 871 | return trace_handle_return(s); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 872 | } |
| 873 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 874 | static struct trace_event_functions trace_fn_funcs = { |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 875 | .trace = trace_fn_trace, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 876 | .raw = trace_fn_raw, |
| 877 | .hex = trace_fn_hex, |
| 878 | .binary = trace_fn_bin, |
| 879 | }; |
| 880 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 881 | static struct trace_event trace_fn_event = { |
| 882 | .type = TRACE_FN, |
| 883 | .funcs = &trace_fn_funcs, |
| 884 | }; |
| 885 | |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 886 | /* TRACE_CTX an TRACE_WAKE */ |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 887 | static enum print_line_t trace_ctxwake_print(struct trace_iterator *iter, |
| 888 | char *delim) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 889 | { |
| 890 | struct ctx_switch_entry *field; |
Steven Rostedt | 4ca53085 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 891 | char comm[TASK_COMM_LEN]; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 892 | int S, T; |
| 893 | |
Steven Rostedt | 4ca53085 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 894 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 895 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 896 | |
| 897 | T = task_state_char(field->next_state); |
| 898 | S = task_state_char(field->prev_state); |
Steven Rostedt | 4ca53085 | 2009-03-16 19:20:15 -0400 | [diff] [blame] | 899 | trace_find_cmdline(field->next_pid, comm); |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 900 | trace_seq_printf(&iter->seq, |
| 901 | " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n", |
| 902 | field->prev_pid, |
| 903 | field->prev_prio, |
| 904 | S, delim, |
| 905 | field->next_cpu, |
| 906 | field->next_pid, |
| 907 | field->next_prio, |
| 908 | T, comm); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 909 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 910 | return trace_handle_return(&iter->seq); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 911 | } |
| 912 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 913 | static enum print_line_t trace_ctx_print(struct trace_iterator *iter, int flags, |
| 914 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 915 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 916 | return trace_ctxwake_print(iter, "==>"); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 917 | } |
| 918 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 919 | static enum print_line_t trace_wake_print(struct trace_iterator *iter, |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 920 | int flags, struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 921 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 922 | return trace_ctxwake_print(iter, " +"); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 923 | } |
| 924 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 925 | static int trace_ctxwake_raw(struct trace_iterator *iter, char S) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 926 | { |
| 927 | struct ctx_switch_entry *field; |
| 928 | int T; |
| 929 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 930 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 931 | |
| 932 | if (!S) |
Hiroshi Shimamoto | b0f56f1 | 2009-10-01 13:33:28 +0900 | [diff] [blame] | 933 | S = task_state_char(field->prev_state); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 934 | T = task_state_char(field->next_state); |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 935 | trace_seq_printf(&iter->seq, "%d %d %c %d %d %d %c\n", |
| 936 | field->prev_pid, |
| 937 | field->prev_prio, |
| 938 | S, |
| 939 | field->next_cpu, |
| 940 | field->next_pid, |
| 941 | field->next_prio, |
| 942 | T); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 943 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 944 | return trace_handle_return(&iter->seq); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 945 | } |
| 946 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 947 | static enum print_line_t trace_ctx_raw(struct trace_iterator *iter, int flags, |
| 948 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 949 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 950 | return trace_ctxwake_raw(iter, 0); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 951 | } |
| 952 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 953 | static enum print_line_t trace_wake_raw(struct trace_iterator *iter, int flags, |
| 954 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 955 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 956 | return trace_ctxwake_raw(iter, '+'); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 957 | } |
| 958 | |
| 959 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 960 | static int trace_ctxwake_hex(struct trace_iterator *iter, char S) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 961 | { |
| 962 | struct ctx_switch_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 963 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 964 | int T; |
| 965 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 966 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 967 | |
| 968 | if (!S) |
Hiroshi Shimamoto | b0f56f1 | 2009-10-01 13:33:28 +0900 | [diff] [blame] | 969 | S = task_state_char(field->prev_state); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 970 | T = task_state_char(field->next_state); |
| 971 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 972 | SEQ_PUT_HEX_FIELD(s, field->prev_pid); |
| 973 | SEQ_PUT_HEX_FIELD(s, field->prev_prio); |
| 974 | SEQ_PUT_HEX_FIELD(s, S); |
| 975 | SEQ_PUT_HEX_FIELD(s, field->next_cpu); |
| 976 | SEQ_PUT_HEX_FIELD(s, field->next_pid); |
| 977 | SEQ_PUT_HEX_FIELD(s, field->next_prio); |
| 978 | SEQ_PUT_HEX_FIELD(s, T); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 979 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 980 | return trace_handle_return(s); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 981 | } |
| 982 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 983 | static enum print_line_t trace_ctx_hex(struct trace_iterator *iter, int flags, |
| 984 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 985 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 986 | return trace_ctxwake_hex(iter, 0); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 987 | } |
| 988 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 989 | static enum print_line_t trace_wake_hex(struct trace_iterator *iter, int flags, |
| 990 | struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 991 | { |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 992 | return trace_ctxwake_hex(iter, '+'); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 993 | } |
| 994 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 995 | static enum print_line_t trace_ctxwake_bin(struct trace_iterator *iter, |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 996 | int flags, struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 997 | { |
| 998 | struct ctx_switch_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 999 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1000 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 1001 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1002 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1003 | SEQ_PUT_FIELD(s, field->prev_pid); |
| 1004 | SEQ_PUT_FIELD(s, field->prev_prio); |
| 1005 | SEQ_PUT_FIELD(s, field->prev_state); |
| 1006 | SEQ_PUT_FIELD(s, field->next_cpu); |
| 1007 | SEQ_PUT_FIELD(s, field->next_pid); |
| 1008 | SEQ_PUT_FIELD(s, field->next_prio); |
| 1009 | SEQ_PUT_FIELD(s, field->next_state); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1010 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1011 | return trace_handle_return(s); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1012 | } |
| 1013 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1014 | static struct trace_event_functions trace_ctx_funcs = { |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1015 | .trace = trace_ctx_print, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1016 | .raw = trace_ctx_raw, |
| 1017 | .hex = trace_ctx_hex, |
| 1018 | .binary = trace_ctxwake_bin, |
| 1019 | }; |
| 1020 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1021 | static struct trace_event trace_ctx_event = { |
| 1022 | .type = TRACE_CTX, |
| 1023 | .funcs = &trace_ctx_funcs, |
| 1024 | }; |
| 1025 | |
| 1026 | static struct trace_event_functions trace_wake_funcs = { |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1027 | .trace = trace_wake_print, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1028 | .raw = trace_wake_raw, |
| 1029 | .hex = trace_wake_hex, |
| 1030 | .binary = trace_ctxwake_bin, |
| 1031 | }; |
| 1032 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1033 | static struct trace_event trace_wake_event = { |
| 1034 | .type = TRACE_WAKE, |
| 1035 | .funcs = &trace_wake_funcs, |
| 1036 | }; |
| 1037 | |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1038 | /* TRACE_STACK */ |
| 1039 | |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 1040 | static enum print_line_t trace_stack_print(struct trace_iterator *iter, |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1041 | int flags, struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1042 | { |
| 1043 | struct stack_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 1044 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | 4a9bd3f | 2011-07-14 16:36:53 -0400 | [diff] [blame] | 1045 | unsigned long *p; |
| 1046 | unsigned long *end; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1047 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 1048 | trace_assign_type(field, iter->ent); |
Steven Rostedt | 4a9bd3f | 2011-07-14 16:36:53 -0400 | [diff] [blame] | 1049 | end = (unsigned long *)((long)iter->ent + iter->ent_size); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1050 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1051 | trace_seq_puts(s, "<stack trace>\n"); |
Steven Rostedt | 4a9bd3f | 2011-07-14 16:36:53 -0400 | [diff] [blame] | 1052 | |
| 1053 | for (p = field->caller; p && *p != ULONG_MAX && p < end; p++) { |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1054 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1055 | if (trace_seq_has_overflowed(s)) |
| 1056 | break; |
| 1057 | |
| 1058 | trace_seq_puts(s, " => "); |
| 1059 | seq_print_ip_sym(s, *p, flags); |
| 1060 | trace_seq_putc(s, '\n'); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1061 | } |
| 1062 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1063 | return trace_handle_return(s); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1064 | } |
| 1065 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1066 | static struct trace_event_functions trace_stack_funcs = { |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1067 | .trace = trace_stack_print, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1068 | }; |
| 1069 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1070 | static struct trace_event trace_stack_event = { |
| 1071 | .type = TRACE_STACK, |
| 1072 | .funcs = &trace_stack_funcs, |
| 1073 | }; |
| 1074 | |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1075 | /* TRACE_USER_STACK */ |
Arnaldo Carvalho de Melo | ae7462b | 2009-02-03 22:05:50 -0200 | [diff] [blame] | 1076 | static enum print_line_t trace_user_stack_print(struct trace_iterator *iter, |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1077 | int flags, struct trace_event *event) |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1078 | { |
| 1079 | struct userstack_entry *field; |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 1080 | struct trace_seq *s = &iter->seq; |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1081 | |
Arnaldo Carvalho de Melo | 2c9b238 | 2009-02-02 20:30:12 -0200 | [diff] [blame] | 1082 | trace_assign_type(field, iter->ent); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1083 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1084 | trace_seq_puts(s, "<user stack trace>\n"); |
| 1085 | seq_print_userip_objs(field, s, flags); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1086 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1087 | return trace_handle_return(s); |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1088 | } |
| 1089 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1090 | static struct trace_event_functions trace_user_stack_funcs = { |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1091 | .trace = trace_user_stack_print, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1092 | }; |
| 1093 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1094 | static struct trace_event trace_user_stack_event = { |
| 1095 | .type = TRACE_USER_STACK, |
| 1096 | .funcs = &trace_user_stack_funcs, |
| 1097 | }; |
| 1098 | |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 1099 | /* TRACE_BPUTS */ |
| 1100 | static enum print_line_t |
| 1101 | trace_bputs_print(struct trace_iterator *iter, int flags, |
| 1102 | struct trace_event *event) |
| 1103 | { |
| 1104 | struct trace_entry *entry = iter->ent; |
| 1105 | struct trace_seq *s = &iter->seq; |
| 1106 | struct bputs_entry *field; |
| 1107 | |
| 1108 | trace_assign_type(field, entry); |
| 1109 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1110 | seq_print_ip_sym(s, field->ip, flags); |
| 1111 | trace_seq_puts(s, ": "); |
| 1112 | trace_seq_puts(s, field->str); |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 1113 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1114 | return trace_handle_return(s); |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 1115 | } |
| 1116 | |
| 1117 | |
| 1118 | static enum print_line_t |
| 1119 | trace_bputs_raw(struct trace_iterator *iter, int flags, |
| 1120 | struct trace_event *event) |
| 1121 | { |
| 1122 | struct bputs_entry *field; |
| 1123 | struct trace_seq *s = &iter->seq; |
| 1124 | |
| 1125 | trace_assign_type(field, iter->ent); |
| 1126 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1127 | trace_seq_printf(s, ": %lx : ", field->ip); |
| 1128 | trace_seq_puts(s, field->str); |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 1129 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1130 | return trace_handle_return(s); |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 1131 | } |
| 1132 | |
| 1133 | static struct trace_event_functions trace_bputs_funcs = { |
| 1134 | .trace = trace_bputs_print, |
| 1135 | .raw = trace_bputs_raw, |
| 1136 | }; |
| 1137 | |
| 1138 | static struct trace_event trace_bputs_event = { |
| 1139 | .type = TRACE_BPUTS, |
| 1140 | .funcs = &trace_bputs_funcs, |
| 1141 | }; |
| 1142 | |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1143 | /* TRACE_BPRINT */ |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1144 | static enum print_line_t |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1145 | trace_bprint_print(struct trace_iterator *iter, int flags, |
| 1146 | struct trace_event *event) |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1147 | { |
| 1148 | struct trace_entry *entry = iter->ent; |
| 1149 | struct trace_seq *s = &iter->seq; |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1150 | struct bprint_entry *field; |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1151 | |
| 1152 | trace_assign_type(field, entry); |
| 1153 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1154 | seq_print_ip_sym(s, field->ip, flags); |
| 1155 | trace_seq_puts(s, ": "); |
| 1156 | trace_seq_bprintf(s, field->fmt, field->buf); |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1157 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1158 | return trace_handle_return(s); |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1159 | } |
| 1160 | |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1161 | |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1162 | static enum print_line_t |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1163 | trace_bprint_raw(struct trace_iterator *iter, int flags, |
| 1164 | struct trace_event *event) |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 1165 | { |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1166 | struct bprint_entry *field; |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 1167 | struct trace_seq *s = &iter->seq; |
| 1168 | |
| 1169 | trace_assign_type(field, iter->ent); |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1170 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1171 | trace_seq_printf(s, ": %lx : ", field->ip); |
| 1172 | trace_seq_bprintf(s, field->fmt, field->buf); |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1173 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1174 | return trace_handle_return(s); |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1175 | } |
| 1176 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1177 | static struct trace_event_functions trace_bprint_funcs = { |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1178 | .trace = trace_bprint_print, |
| 1179 | .raw = trace_bprint_raw, |
| 1180 | }; |
| 1181 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1182 | static struct trace_event trace_bprint_event = { |
| 1183 | .type = TRACE_BPRINT, |
| 1184 | .funcs = &trace_bprint_funcs, |
| 1185 | }; |
| 1186 | |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1187 | /* TRACE_PRINT */ |
| 1188 | static enum print_line_t trace_print_print(struct trace_iterator *iter, |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1189 | int flags, struct trace_event *event) |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1190 | { |
| 1191 | struct print_entry *field; |
| 1192 | struct trace_seq *s = &iter->seq; |
| 1193 | |
| 1194 | trace_assign_type(field, iter->ent); |
| 1195 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1196 | seq_print_ip_sym(s, field->ip, flags); |
| 1197 | trace_seq_printf(s, ": %s", field->buf); |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1198 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1199 | return trace_handle_return(s); |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1200 | } |
| 1201 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1202 | static enum print_line_t trace_print_raw(struct trace_iterator *iter, int flags, |
| 1203 | struct trace_event *event) |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1204 | { |
| 1205 | struct print_entry *field; |
| 1206 | |
| 1207 | trace_assign_type(field, iter->ent); |
| 1208 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1209 | trace_seq_printf(&iter->seq, "# %lx %s", field->ip, field->buf); |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1210 | |
Steven Rostedt (Red Hat) | 19a7fe2 | 2014-11-12 10:29:54 -0500 | [diff] [blame] | 1211 | return trace_handle_return(&iter->seq); |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1212 | } |
| 1213 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1214 | static struct trace_event_functions trace_print_funcs = { |
Frederic Weisbecker | 769b044 | 2009-03-06 17:21:49 +0100 | [diff] [blame] | 1215 | .trace = trace_print_print, |
| 1216 | .raw = trace_print_raw, |
Lai Jiangshan | 1427cdf | 2009-03-06 17:21:47 +0100 | [diff] [blame] | 1217 | }; |
| 1218 | |
Steven Rostedt | a9a5776 | 2010-04-22 18:46:14 -0400 | [diff] [blame] | 1219 | static struct trace_event trace_print_event = { |
| 1220 | .type = TRACE_PRINT, |
| 1221 | .funcs = &trace_print_funcs, |
| 1222 | }; |
| 1223 | |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1224 | |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1225 | static struct trace_event *events[] __initdata = { |
| 1226 | &trace_fn_event, |
| 1227 | &trace_ctx_event, |
| 1228 | &trace_wake_event, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1229 | &trace_stack_event, |
| 1230 | &trace_user_stack_event, |
Steven Rostedt (Red Hat) | 09ae723 | 2013-03-08 21:02:34 -0500 | [diff] [blame] | 1231 | &trace_bputs_event, |
Frederic Weisbecker | 48ead02 | 2009-03-12 18:24:49 +0100 | [diff] [blame] | 1232 | &trace_bprint_event, |
Steven Rostedt | f633cef | 2008-12-23 23:24:13 -0500 | [diff] [blame] | 1233 | &trace_print_event, |
| 1234 | NULL |
| 1235 | }; |
| 1236 | |
| 1237 | __init static int init_events(void) |
| 1238 | { |
| 1239 | struct trace_event *event; |
| 1240 | int i, ret; |
| 1241 | |
| 1242 | for (i = 0; events[i]; i++) { |
| 1243 | event = events[i]; |
| 1244 | |
| 1245 | ret = register_ftrace_event(event); |
| 1246 | if (!ret) { |
| 1247 | printk(KERN_WARNING "event %d failed to register\n", |
| 1248 | event->type); |
| 1249 | WARN_ON_ONCE(1); |
| 1250 | } |
| 1251 | } |
| 1252 | |
| 1253 | return 0; |
| 1254 | } |
Steven Rostedt | 7374e82 | 2012-05-31 21:40:05 -0400 | [diff] [blame] | 1255 | early_initcall(init_events); |