diff options
Diffstat (limited to 'kernel/trace/trace.c')
| -rw-r--r-- | kernel/trace/trace.c | 178 | 
1 files changed, 77 insertions, 101 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 086d36316805..ba14a22be4cc 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c  | |||
| @@ -101,10 +101,7 @@ static inline void ftrace_enable_cpu(void) | |||
| 101 | preempt_enable(); | 101 | preempt_enable(); | 
| 102 | } | 102 | } | 
| 103 | 103 | ||
| 104 | static cpumask_var_t __read_mostly tracing_buffer_mask; | 104 | cpumask_var_t __read_mostly tracing_buffer_mask; | 
| 105 | |||
| 106 | #define for_each_tracing_cpu(cpu) \ | ||
| 107 | for_each_cpu(cpu, tracing_buffer_mask) | ||
| 108 | 105 | ||
| 109 | /* | 106 | /* | 
| 110 | * ftrace_dump_on_oops - variable to dump ftrace buffer on oops | 107 | * ftrace_dump_on_oops - variable to dump ftrace buffer on oops | 
| @@ -344,7 +341,7 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait); | |||
| 344 | /* trace_flags holds trace_options default values */ | 341 | /* trace_flags holds trace_options default values */ | 
| 345 | unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | | 342 | unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | | 
| 346 | TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME | | 343 | TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO | TRACE_ITER_SLEEP_TIME | | 
| 347 | TRACE_ITER_GRAPH_TIME; | 344 | TRACE_ITER_GRAPH_TIME | TRACE_ITER_RECORD_CMD; | 
| 348 | 345 | ||
| 349 | static int trace_stop_count; | 346 | static int trace_stop_count; | 
| 350 | static DEFINE_SPINLOCK(tracing_start_lock); | 347 | static DEFINE_SPINLOCK(tracing_start_lock); | 
| @@ -428,6 +425,7 @@ static const char *trace_options[] = { | |||
| 428 | "latency-format", | 425 | "latency-format", | 
| 429 | "sleep-time", | 426 | "sleep-time", | 
| 430 | "graph-time", | 427 | "graph-time", | 
| 428 | "record-cmd", | ||
| 431 | NULL | 429 | NULL | 
| 432 | }; | 430 | }; | 
| 433 | 431 | ||
| @@ -659,6 +657,10 @@ update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu) | |||
| 659 | return; | 657 | return; | 
| 660 | 658 | ||
| 661 | WARN_ON_ONCE(!irqs_disabled()); | 659 | WARN_ON_ONCE(!irqs_disabled()); | 
| 660 | if (!current_trace->use_max_tr) { | ||
| 661 | WARN_ON_ONCE(1); | ||
| 662 | return; | ||
| 663 | } | ||
| 662 | arch_spin_lock(&ftrace_max_lock); | 664 | arch_spin_lock(&ftrace_max_lock); | 
| 663 | 665 | ||
| 664 | tr->buffer = max_tr.buffer; | 666 | tr->buffer = max_tr.buffer; | 
| @@ -685,6 +687,11 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu) | |||
| 685 | return; | 687 | return; | 
| 686 | 688 | ||
| 687 | WARN_ON_ONCE(!irqs_disabled()); | 689 | WARN_ON_ONCE(!irqs_disabled()); | 
| 690 | if (!current_trace->use_max_tr) { | ||
| 691 | WARN_ON_ONCE(1); | ||
| 692 | return; | ||
| 693 | } | ||
| 694 | |||
| 688 | arch_spin_lock(&ftrace_max_lock); | 695 | arch_spin_lock(&ftrace_max_lock); | 
| 689 | 696 | ||
| 690 | ftrace_disable_cpu(); | 697 | ftrace_disable_cpu(); | 
| @@ -729,18 +736,11 @@ __acquires(kernel_lock) | |||
| 729 | return -1; | 736 | return -1; | 
| 730 | } | 737 | } | 
| 731 | 738 | ||
| 732 | if (strlen(type->name) > MAX_TRACER_SIZE) { | 739 | if (strlen(type->name) >= MAX_TRACER_SIZE) { | 
| 733 | pr_info("Tracer has a name longer than %d\n", MAX_TRACER_SIZE); | 740 | pr_info("Tracer has a name longer than %d\n", MAX_TRACER_SIZE); | 
| 734 | return -1; | 741 | return -1; | 
| 735 | } | 742 | } | 
| 736 | 743 | ||
| 737 | /* | ||
| 738 | * When this gets called we hold the BKL which means that | ||
| 739 | * preemption is disabled. Various trace selftests however | ||
| 740 | * need to disable and enable preemption for successful tests. | ||
| 741 | * So we drop the BKL here and grab it after the tests again. | ||
| 742 | */ | ||
| 743 | unlock_kernel(); | ||
| 744 | mutex_lock(&trace_types_lock); | 744 | mutex_lock(&trace_types_lock); | 
| 745 | 745 | ||
| 746 | tracing_selftest_running = true; | 746 | tracing_selftest_running = true; | 
| @@ -822,7 +822,6 @@ __acquires(kernel_lock) | |||
| 822 | #endif | 822 | #endif | 
| 823 | 823 | ||
| 824 | out_unlock: | 824 | out_unlock: | 
| 825 | lock_kernel(); | ||
| 826 | return ret; | 825 | return ret; | 
| 827 | } | 826 | } | 
| 828 | 827 | ||
| @@ -1331,61 +1330,6 @@ static void __trace_userstack(struct trace_array *tr, unsigned long flags) | |||
| 1331 | 1330 | ||
| 1332 | #endif /* CONFIG_STACKTRACE */ | 1331 | #endif /* CONFIG_STACKTRACE */ | 
| 1333 | 1332 | ||
| 1334 | static void | ||
| 1335 | ftrace_trace_special(void *__tr, | ||
| 1336 | unsigned long arg1, unsigned long arg2, unsigned long arg3, | ||
| 1337 | int pc) | ||
| 1338 | { | ||
| 1339 | struct ftrace_event_call *call = &event_special; | ||
| 1340 | struct ring_buffer_event *event; | ||
| 1341 | struct trace_array *tr = __tr; | ||
| 1342 | struct ring_buffer *buffer = tr->buffer; | ||
| 1343 | struct special_entry *entry; | ||
| 1344 | |||
| 1345 | event = trace_buffer_lock_reserve(buffer, TRACE_SPECIAL, | ||
| 1346 | sizeof(*entry), 0, pc); | ||
| 1347 | if (!event) | ||
| 1348 | return; | ||
| 1349 | entry = ring_buffer_event_data(event); | ||
| 1350 | entry->arg1 = arg1; | ||
| 1351 | entry->arg2 = arg2; | ||
| 1352 | entry->arg3 = arg3; | ||
| 1353 | |||
| 1354 | if (!filter_check_discard(call, entry, buffer, event)) | ||
| 1355 | trace_buffer_unlock_commit(buffer, event, 0, pc); | ||
| 1356 | } | ||
| 1357 | |||
| 1358 | void | ||
| 1359 | __trace_special(void *__tr, void *__data, | ||
| 1360 | unsigned long arg1, unsigned long arg2, unsigned long arg3) | ||
| 1361 | { | ||
| 1362 | ftrace_trace_special(__tr, arg1, arg2, arg3, preempt_count()); | ||
| 1363 | } | ||
| 1364 | |||
| 1365 | void | ||
| 1366 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) | ||
| 1367 | { | ||
| 1368 | struct trace_array *tr = &global_trace; | ||
| 1369 | struct trace_array_cpu *data; | ||
| 1370 | unsigned long flags; | ||
| 1371 | int cpu; | ||
| 1372 | int pc; | ||
| 1373 | |||
| 1374 | if (tracing_disabled) | ||
| 1375 | return; | ||
| 1376 | |||
| 1377 | pc = preempt_count(); | ||
| 1378 | local_irq_save(flags); | ||
| 1379 | cpu = raw_smp_processor_id(); | ||
| 1380 | data = tr->data[cpu]; | ||
| 1381 | |||
| 1382 | if (likely(atomic_inc_return(&data->disabled) == 1)) | ||
| 1383 | ftrace_trace_special(tr, arg1, arg2, arg3, pc); | ||
| 1384 | |||
| 1385 | atomic_dec(&data->disabled); | ||
| 1386 | local_irq_restore(flags); | ||
| 1387 | } | ||
| 1388 | |||
| 1389 | /** | 1333 | /** | 
| 1390 | * trace_vbprintk - write binary msg to tracing buffer | 1334 | * trace_vbprintk - write binary msg to tracing buffer | 
| 1391 | * | 1335 | * | 
| @@ -1404,7 +1348,6 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args) | |||
| 1404 | struct bprint_entry *entry; | 1348 | struct bprint_entry *entry; | 
| 1405 | unsigned long flags; | 1349 | unsigned long flags; | 
| 1406 | int disable; | 1350 | int disable; | 
| 1407 | int resched; | ||
| 1408 | int cpu, len = 0, size, pc; | 1351 | int cpu, len = 0, size, pc; | 
| 1409 | 1352 | ||
| 1410 | if (unlikely(tracing_selftest_running || tracing_disabled)) | 1353 | if (unlikely(tracing_selftest_running || tracing_disabled)) | 
| @@ -1414,7 +1357,7 @@ int trace_vbprintk(unsigned long ip, const char *fmt, va_list args) | |||
| 1414 | pause_graph_tracing(); | 1357 | pause_graph_tracing(); | 
| 1415 | 1358 | ||
| 1416 | pc = preempt_count(); | 1359 | pc = preempt_count(); | 
| 1417 | resched = ftrace_preempt_disable(); | 1360 | preempt_disable_notrace(); | 
| 1418 | cpu = raw_smp_processor_id(); | 1361 | cpu = raw_smp_processor_id(); | 
| 1419 | data = tr->data[cpu]; | 1362 | data = tr->data[cpu]; | 
| 1420 | 1363 | ||
| @@ -1452,7 +1395,7 @@ out_unlock: | |||
| 1452 | 1395 | ||
| 1453 | out: | 1396 | out: | 
| 1454 | atomic_dec_return(&data->disabled); | 1397 | atomic_dec_return(&data->disabled); | 
| 1455 | ftrace_preempt_enable(resched); | 1398 | preempt_enable_notrace(); | 
| 1456 | unpause_graph_tracing(); | 1399 | unpause_graph_tracing(); | 
| 1457 | 1400 | ||
| 1458 | return len; | 1401 | return len; | 
| @@ -1539,11 +1482,6 @@ int trace_vprintk(unsigned long ip, const char *fmt, va_list args) | |||
| 1539 | } | 1482 | } | 
| 1540 | EXPORT_SYMBOL_GPL(trace_vprintk); | 1483 | EXPORT_SYMBOL_GPL(trace_vprintk); | 
| 1541 | 1484 | ||
| 1542 | enum trace_file_type { | ||
| 1543 | TRACE_FILE_LAT_FMT = 1, | ||
| 1544 | TRACE_FILE_ANNOTATE = 2, | ||
| 1545 | }; | ||
| 1546 | |||
| 1547 | static void trace_iterator_increment(struct trace_iterator *iter) | 1485 | static void trace_iterator_increment(struct trace_iterator *iter) | 
| 1548 | { | 1486 | { | 
| 1549 | /* Don't allow ftrace to trace into the ring buffers */ | 1487 | /* Don't allow ftrace to trace into the ring buffers */ | 
| @@ -1641,7 +1579,7 @@ struct trace_entry *trace_find_next_entry(struct trace_iterator *iter, | |||
| 1641 | } | 1579 | } | 
| 1642 | 1580 | ||
| 1643 | /* Find the next real entry, and increment the iterator to the next entry */ | 1581 | /* Find the next real entry, and increment the iterator to the next entry */ | 
| 1644 | static void *find_next_entry_inc(struct trace_iterator *iter) | 1582 | void *trace_find_next_entry_inc(struct trace_iterator *iter) | 
| 1645 | { | 1583 | { | 
| 1646 | iter->ent = __find_next_entry(iter, &iter->cpu, | 1584 | iter->ent = __find_next_entry(iter, &iter->cpu, | 
| 1647 | &iter->lost_events, &iter->ts); | 1585 | &iter->lost_events, &iter->ts); | 
| @@ -1676,19 +1614,19 @@ static void *s_next(struct seq_file *m, void *v, loff_t *pos) | |||
| 1676 | return NULL; | 1614 | return NULL; | 
| 1677 | 1615 | ||
| 1678 | if (iter->idx < 0) | 1616 | if (iter->idx < 0) | 
| 1679 | ent = find_next_entry_inc(iter); | 1617 | ent = trace_find_next_entry_inc(iter); | 
| 1680 | else | 1618 | else | 
| 1681 | ent = iter; | 1619 | ent = iter; | 
| 1682 | 1620 | ||
| 1683 | while (ent && iter->idx < i) | 1621 | while (ent && iter->idx < i) | 
| 1684 | ent = find_next_entry_inc(iter); | 1622 | ent = trace_find_next_entry_inc(iter); | 
| 1685 | 1623 | ||
| 1686 | iter->pos = *pos; | 1624 | iter->pos = *pos; | 
| 1687 | 1625 | ||
| 1688 | return ent; | 1626 | return ent; | 
| 1689 | } | 1627 | } | 
| 1690 | 1628 | ||
| 1691 | static void tracing_iter_reset(struct trace_iterator *iter, int cpu) | 1629 | void tracing_iter_reset(struct trace_iterator *iter, int cpu) | 
| 1692 | { | 1630 | { | 
| 1693 | struct trace_array *tr = iter->tr; | 1631 | struct trace_array *tr = iter->tr; | 
| 1694 | struct ring_buffer_event *event; | 1632 | struct ring_buffer_event *event; | 
| @@ -2049,7 +1987,7 @@ int trace_empty(struct trace_iterator *iter) | |||
| 2049 | } | 1987 | } | 
| 2050 | 1988 | ||
| 2051 | /* Called with trace_event_read_lock() held. */ | 1989 | /* Called with trace_event_read_lock() held. */ | 
| 2052 | static enum print_line_t print_trace_line(struct trace_iterator *iter) | 1990 | enum print_line_t print_trace_line(struct trace_iterator *iter) | 
| 2053 | { | 1991 | { | 
| 2054 | enum print_line_t ret; | 1992 | enum print_line_t ret; | 
| 2055 | 1993 | ||
| @@ -2394,6 +2332,7 @@ static const struct file_operations show_traces_fops = { | |||
| 2394 | .open = show_traces_open, | 2332 | .open = show_traces_open, | 
| 2395 | .read = seq_read, | 2333 | .read = seq_read, | 
| 2396 | .release = seq_release, | 2334 | .release = seq_release, | 
| 2335 | .llseek = seq_lseek, | ||
| 2397 | }; | 2336 | }; | 
| 2398 | 2337 | ||
| 2399 | /* | 2338 | /* | 
| @@ -2487,6 +2426,7 @@ static const struct file_operations tracing_cpumask_fops = { | |||
| 2487 | .open = tracing_open_generic, | 2426 | .open = tracing_open_generic, | 
| 2488 | .read = tracing_cpumask_read, | 2427 | .read = tracing_cpumask_read, | 
| 2489 | .write = tracing_cpumask_write, | 2428 | .write = tracing_cpumask_write, | 
| 2429 | .llseek = generic_file_llseek, | ||
| 2490 | }; | 2430 | }; | 
| 2491 | 2431 | ||
| 2492 | static int tracing_trace_options_show(struct seq_file *m, void *v) | 2432 | static int tracing_trace_options_show(struct seq_file *m, void *v) | 
| @@ -2562,6 +2502,9 @@ static void set_tracer_flags(unsigned int mask, int enabled) | |||
| 2562 | trace_flags |= mask; | 2502 | trace_flags |= mask; | 
| 2563 | else | 2503 | else | 
| 2564 | trace_flags &= ~mask; | 2504 | trace_flags &= ~mask; | 
| 2505 | |||
| 2506 | if (mask == TRACE_ITER_RECORD_CMD) | ||
| 2507 | trace_event_enable_cmd_record(enabled); | ||
| 2565 | } | 2508 | } | 
| 2566 | 2509 | ||
| 2567 | static ssize_t | 2510 | static ssize_t | 
| @@ -2653,6 +2596,7 @@ tracing_readme_read(struct file *filp, char __user *ubuf, | |||
| 2653 | static const struct file_operations tracing_readme_fops = { | 2596 | static const struct file_operations tracing_readme_fops = { | 
| 2654 | .open = tracing_open_generic, | 2597 | .open = tracing_open_generic, | 
| 2655 | .read = tracing_readme_read, | 2598 | .read = tracing_readme_read, | 
| 2599 | .llseek = generic_file_llseek, | ||
| 2656 | }; | 2600 | }; | 
| 2657 | 2601 | ||
| 2658 | static ssize_t | 2602 | static ssize_t | 
| @@ -2703,6 +2647,7 @@ tracing_saved_cmdlines_read(struct file *file, char __user *ubuf, | |||
| 2703 | static const struct file_operations tracing_saved_cmdlines_fops = { | 2647 | static const struct file_operations tracing_saved_cmdlines_fops = { | 
| 2704 | .open = tracing_open_generic, | 2648 | .open = tracing_open_generic, | 
| 2705 | .read = tracing_saved_cmdlines_read, | 2649 | .read = tracing_saved_cmdlines_read, | 
| 2650 | .llseek = generic_file_llseek, | ||
| 2706 | }; | 2651 | }; | 
| 2707 | 2652 | ||
| 2708 | static ssize_t | 2653 | static ssize_t | 
| @@ -2798,6 +2743,9 @@ static int tracing_resize_ring_buffer(unsigned long size) | |||
| 2798 | if (ret < 0) | 2743 | if (ret < 0) | 
| 2799 | return ret; | 2744 | return ret; | 
| 2800 | 2745 | ||
| 2746 | if (!current_trace->use_max_tr) | ||
| 2747 | goto out; | ||
| 2748 | |||
| 2801 | ret = ring_buffer_resize(max_tr.buffer, size); | 2749 | ret = ring_buffer_resize(max_tr.buffer, size); | 
| 2802 | if (ret < 0) { | 2750 | if (ret < 0) { | 
| 2803 | int r; | 2751 | int r; | 
| @@ -2825,11 +2773,14 @@ static int tracing_resize_ring_buffer(unsigned long size) | |||
| 2825 | return ret; | 2773 | return ret; | 
| 2826 | } | 2774 | } | 
| 2827 | 2775 | ||
| 2776 | max_tr.entries = size; | ||
| 2777 | out: | ||
| 2828 | global_trace.entries = size; | 2778 | global_trace.entries = size; | 
| 2829 | 2779 | ||
| 2830 | return ret; | 2780 | return ret; | 
| 2831 | } | 2781 | } | 
| 2832 | 2782 | ||
| 2783 | |||
| 2833 | /** | 2784 | /** | 
| 2834 | * tracing_update_buffers - used by tracing facility to expand ring buffers | 2785 | * tracing_update_buffers - used by tracing facility to expand ring buffers | 
| 2835 | * | 2786 | * | 
| @@ -2890,12 +2841,26 @@ static int tracing_set_tracer(const char *buf) | |||
| 2890 | trace_branch_disable(); | 2841 | trace_branch_disable(); | 
| 2891 | if (current_trace && current_trace->reset) | 2842 | if (current_trace && current_trace->reset) | 
| 2892 | current_trace->reset(tr); | 2843 | current_trace->reset(tr); | 
| 2893 | 2844 | if (current_trace && current_trace->use_max_tr) { | |
| 2845 | /* | ||
| 2846 | * We don't free the ring buffer. instead, resize it because | ||
| 2847 | * The max_tr ring buffer has some state (e.g. ring->clock) and | ||
| 2848 | * we want preserve it. | ||
| 2849 | */ | ||
| 2850 | ring_buffer_resize(max_tr.buffer, 1); | ||
| 2851 | max_tr.entries = 1; | ||
| 2852 | } | ||
| 2894 | destroy_trace_option_files(topts); | 2853 | destroy_trace_option_files(topts); | 
| 2895 | 2854 | ||
| 2896 | current_trace = t; | 2855 | current_trace = t; | 
| 2897 | 2856 | ||
| 2898 | topts = create_trace_option_files(current_trace); | 2857 | topts = create_trace_option_files(current_trace); | 
| 2858 | if (current_trace->use_max_tr) { | ||
| 2859 | ret = ring_buffer_resize(max_tr.buffer, global_trace.entries); | ||
| 2860 | if (ret < 0) | ||
| 2861 | goto out; | ||
| 2862 | max_tr.entries = global_trace.entries; | ||
| 2863 | } | ||
| 2899 | 2864 | ||
| 2900 | if (t->init) { | 2865 | if (t->init) { | 
| 2901 | ret = tracer_init(t, tr); | 2866 | ret = tracer_init(t, tr); | 
| @@ -3032,6 +2997,7 @@ static int tracing_open_pipe(struct inode *inode, struct file *filp) | |||
| 3032 | if (iter->trace->pipe_open) | 2997 | if (iter->trace->pipe_open) | 
| 3033 | iter->trace->pipe_open(iter); | 2998 | iter->trace->pipe_open(iter); | 
| 3034 | 2999 | ||
| 3000 | nonseekable_open(inode, filp); | ||
| 3035 | out: | 3001 | out: | 
| 3036 | mutex_unlock(&trace_types_lock); | 3002 | mutex_unlock(&trace_types_lock); | 
| 3037 | return ret; | 3003 | return ret; | 
| @@ -3211,7 +3177,7 @@ waitagain: | |||
| 3211 | 3177 | ||
| 3212 | trace_event_read_lock(); | 3178 | trace_event_read_lock(); | 
| 3213 | trace_access_lock(iter->cpu_file); | 3179 | trace_access_lock(iter->cpu_file); | 
| 3214 | while (find_next_entry_inc(iter) != NULL) { | 3180 | while (trace_find_next_entry_inc(iter) != NULL) { | 
| 3215 | enum print_line_t ret; | 3181 | enum print_line_t ret; | 
| 3216 | int len = iter->seq.len; | 3182 | int len = iter->seq.len; | 
| 3217 | 3183 | ||
| @@ -3294,7 +3260,7 @@ tracing_fill_pipe_page(size_t rem, struct trace_iterator *iter) | |||
| 3294 | if (ret != TRACE_TYPE_NO_CONSUME) | 3260 | if (ret != TRACE_TYPE_NO_CONSUME) | 
| 3295 | trace_consume(iter); | 3261 | trace_consume(iter); | 
| 3296 | rem -= count; | 3262 | rem -= count; | 
| 3297 | if (!find_next_entry_inc(iter)) { | 3263 | if (!trace_find_next_entry_inc(iter)) { | 
| 3298 | rem = 0; | 3264 | rem = 0; | 
| 3299 | iter->ent = NULL; | 3265 | iter->ent = NULL; | 
| 3300 | break; | 3266 | break; | 
| @@ -3350,7 +3316,7 @@ static ssize_t tracing_splice_read_pipe(struct file *filp, | |||
| 3350 | if (ret <= 0) | 3316 | if (ret <= 0) | 
| 3351 | goto out_err; | 3317 | goto out_err; | 
| 3352 | 3318 | ||
| 3353 | if (!iter->ent && !find_next_entry_inc(iter)) { | 3319 | if (!iter->ent && !trace_find_next_entry_inc(iter)) { | 
| 3354 | ret = -EFAULT; | 3320 | ret = -EFAULT; | 
| 3355 | goto out_err; | 3321 | goto out_err; | 
| 3356 | } | 3322 | } | 
| @@ -3477,7 +3443,6 @@ tracing_entries_write(struct file *filp, const char __user *ubuf, | |||
| 3477 | } | 3443 | } | 
| 3478 | 3444 | ||
| 3479 | tracing_start(); | 3445 | tracing_start(); | 
| 3480 | max_tr.entries = global_trace.entries; | ||
| 3481 | mutex_unlock(&trace_types_lock); | 3446 | mutex_unlock(&trace_types_lock); | 
| 3482 | 3447 | ||
| 3483 | return cnt; | 3448 | return cnt; | 
| @@ -3590,18 +3555,21 @@ static const struct file_operations tracing_max_lat_fops = { | |||
| 3590 | .open = tracing_open_generic, | 3555 | .open = tracing_open_generic, | 
| 3591 | .read = tracing_max_lat_read, | 3556 | .read = tracing_max_lat_read, | 
| 3592 | .write = tracing_max_lat_write, | 3557 | .write = tracing_max_lat_write, | 
| 3558 | .llseek = generic_file_llseek, | ||
| 3593 | }; | 3559 | }; | 
| 3594 | 3560 | ||
| 3595 | static const struct file_operations tracing_ctrl_fops = { | 3561 | static const struct file_operations tracing_ctrl_fops = { | 
| 3596 | .open = tracing_open_generic, | 3562 | .open = tracing_open_generic, | 
| 3597 | .read = tracing_ctrl_read, | 3563 | .read = tracing_ctrl_read, | 
| 3598 | .write = tracing_ctrl_write, | 3564 | .write = tracing_ctrl_write, | 
| 3565 | .llseek = generic_file_llseek, | ||
| 3599 | }; | 3566 | }; | 
| 3600 | 3567 | ||
| 3601 | static const struct file_operations set_tracer_fops = { | 3568 | static const struct file_operations set_tracer_fops = { | 
| 3602 | .open = tracing_open_generic, | 3569 | .open = tracing_open_generic, | 
| 3603 | .read = tracing_set_trace_read, | 3570 | .read = tracing_set_trace_read, | 
| 3604 | .write = tracing_set_trace_write, | 3571 | .write = tracing_set_trace_write, | 
| 3572 | .llseek = generic_file_llseek, | ||
| 3605 | }; | 3573 | }; | 
| 3606 | 3574 | ||
| 3607 | static const struct file_operations tracing_pipe_fops = { | 3575 | static const struct file_operations tracing_pipe_fops = { | 
| @@ -3610,17 +3578,20 @@ static const struct file_operations tracing_pipe_fops = { | |||
| 3610 | .read = tracing_read_pipe, | 3578 | .read = tracing_read_pipe, | 
| 3611 | .splice_read = tracing_splice_read_pipe, | 3579 | .splice_read = tracing_splice_read_pipe, | 
| 3612 | .release = tracing_release_pipe, | 3580 | .release = tracing_release_pipe, | 
| 3581 | .llseek = no_llseek, | ||
| 3613 | }; | 3582 | }; | 
| 3614 | 3583 | ||
| 3615 | static const struct file_operations tracing_entries_fops = { | 3584 | static const struct file_operations tracing_entries_fops = { | 
| 3616 | .open = tracing_open_generic, | 3585 | .open = tracing_open_generic, | 
| 3617 | .read = tracing_entries_read, | 3586 | .read = tracing_entries_read, | 
| 3618 | .write = tracing_entries_write, | 3587 | .write = tracing_entries_write, | 
| 3588 | .llseek = generic_file_llseek, | ||
| 3619 | }; | 3589 | }; | 
| 3620 | 3590 | ||
| 3621 | static const struct file_operations tracing_mark_fops = { | 3591 | static const struct file_operations tracing_mark_fops = { | 
| 3622 | .open = tracing_open_generic, | 3592 | .open = tracing_open_generic, | 
| 3623 | .write = tracing_mark_write, | 3593 | .write = tracing_mark_write, | 
| 3594 | .llseek = generic_file_llseek, | ||
| 3624 | }; | 3595 | }; | 
| 3625 | 3596 | ||
| 3626 | static const struct file_operations trace_clock_fops = { | 3597 | static const struct file_operations trace_clock_fops = { | 
| @@ -3926,6 +3897,7 @@ tracing_stats_read(struct file *filp, char __user *ubuf, | |||
| 3926 | static const struct file_operations tracing_stats_fops = { | 3897 | static const struct file_operations tracing_stats_fops = { | 
| 3927 | .open = tracing_open_generic, | 3898 | .open = tracing_open_generic, | 
| 3928 | .read = tracing_stats_read, | 3899 | .read = tracing_stats_read, | 
| 3900 | .llseek = generic_file_llseek, | ||
| 3929 | }; | 3901 | }; | 
| 3930 | 3902 | ||
| 3931 | #ifdef CONFIG_DYNAMIC_FTRACE | 3903 | #ifdef CONFIG_DYNAMIC_FTRACE | 
| @@ -3962,6 +3934,7 @@ tracing_read_dyn_info(struct file *filp, char __user *ubuf, | |||
| 3962 | static const struct file_operations tracing_dyn_info_fops = { | 3934 | static const struct file_operations tracing_dyn_info_fops = { | 
| 3963 | .open = tracing_open_generic, | 3935 | .open = tracing_open_generic, | 
| 3964 | .read = tracing_read_dyn_info, | 3936 | .read = tracing_read_dyn_info, | 
| 3937 | .llseek = generic_file_llseek, | ||
| 3965 | }; | 3938 | }; | 
| 3966 | #endif | 3939 | #endif | 
| 3967 | 3940 | ||
| @@ -4115,6 +4088,7 @@ static const struct file_operations trace_options_fops = { | |||
| 4115 | .open = tracing_open_generic, | 4088 | .open = tracing_open_generic, | 
| 4116 | .read = trace_options_read, | 4089 | .read = trace_options_read, | 
| 4117 | .write = trace_options_write, | 4090 | .write = trace_options_write, | 
| 4091 | .llseek = generic_file_llseek, | ||
| 4118 | }; | 4092 | }; | 
| 4119 | 4093 | ||
| 4120 | static ssize_t | 4094 | static ssize_t | 
| @@ -4166,6 +4140,7 @@ static const struct file_operations trace_options_core_fops = { | |||
| 4166 | .open = tracing_open_generic, | 4140 | .open = tracing_open_generic, | 
| 4167 | .read = trace_options_core_read, | 4141 | .read = trace_options_core_read, | 
| 4168 | .write = trace_options_core_write, | 4142 | .write = trace_options_core_write, | 
| 4143 | .llseek = generic_file_llseek, | ||
| 4169 | }; | 4144 | }; | 
| 4170 | 4145 | ||
| 4171 | struct dentry *trace_create_file(const char *name, | 4146 | struct dentry *trace_create_file(const char *name, | 
| @@ -4355,9 +4330,6 @@ static __init int tracer_init_debugfs(void) | |||
| 4355 | trace_create_file("dyn_ftrace_total_info", 0444, d_tracer, | 4330 | trace_create_file("dyn_ftrace_total_info", 0444, d_tracer, | 
| 4356 | &ftrace_update_tot_cnt, &tracing_dyn_info_fops); | 4331 | &ftrace_update_tot_cnt, &tracing_dyn_info_fops); | 
| 4357 | #endif | 4332 | #endif | 
| 4358 | #ifdef CONFIG_SYSPROF_TRACER | ||
| 4359 | init_tracer_sysprof_debugfs(d_tracer); | ||
| 4360 | #endif | ||
| 4361 | 4333 | ||
| 4362 | create_trace_options_dir(); | 4334 | create_trace_options_dir(); | 
| 4363 | 4335 | ||
| @@ -4414,7 +4386,7 @@ static struct notifier_block trace_die_notifier = { | |||
| 4414 | */ | 4386 | */ | 
| 4415 | #define KERN_TRACE KERN_EMERG | 4387 | #define KERN_TRACE KERN_EMERG | 
| 4416 | 4388 | ||
| 4417 | static void | 4389 | void | 
| 4418 | trace_printk_seq(struct trace_seq *s) | 4390 | trace_printk_seq(struct trace_seq *s) | 
| 4419 | { | 4391 | { | 
| 4420 | /* Probably should print a warning here. */ | 4392 | /* Probably should print a warning here. */ | 
| @@ -4429,6 +4401,13 @@ trace_printk_seq(struct trace_seq *s) | |||
| 4429 | trace_seq_init(s); | 4401 | trace_seq_init(s); | 
| 4430 | } | 4402 | } | 
| 4431 | 4403 | ||
| 4404 | void trace_init_global_iter(struct trace_iterator *iter) | ||
| 4405 | { | ||
| 4406 | iter->tr = &global_trace; | ||
| 4407 | iter->trace = current_trace; | ||
| 4408 | iter->cpu_file = TRACE_PIPE_ALL_CPU; | ||
| 4409 | } | ||
| 4410 | |||
| 4432 | static void | 4411 | static void | 
| 4433 | __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode) | 4412 | __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode) | 
| 4434 | { | 4413 | { | 
| @@ -4454,8 +4433,10 @@ __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode) | |||
| 4454 | if (disable_tracing) | 4433 | if (disable_tracing) | 
| 4455 | ftrace_kill(); | 4434 | ftrace_kill(); | 
| 4456 | 4435 | ||
| 4436 | trace_init_global_iter(&iter); | ||
| 4437 | |||
| 4457 | for_each_tracing_cpu(cpu) { | 4438 | for_each_tracing_cpu(cpu) { | 
| 4458 | atomic_inc(&global_trace.data[cpu]->disabled); | 4439 | atomic_inc(&iter.tr->data[cpu]->disabled); | 
| 4459 | } | 4440 | } | 
| 4460 | 4441 | ||
| 4461 | old_userobj = trace_flags & TRACE_ITER_SYM_USEROBJ; | 4442 | old_userobj = trace_flags & TRACE_ITER_SYM_USEROBJ; | 
| @@ -4504,7 +4485,7 @@ __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode) | |||
| 4504 | iter.iter_flags |= TRACE_FILE_LAT_FMT; | 4485 | iter.iter_flags |= TRACE_FILE_LAT_FMT; | 
| 4505 | iter.pos = -1; | 4486 | iter.pos = -1; | 
| 4506 | 4487 | ||
| 4507 | if (find_next_entry_inc(&iter) != NULL) { | 4488 | if (trace_find_next_entry_inc(&iter) != NULL) { | 
| 4508 | int ret; | 4489 | int ret; | 
| 4509 | 4490 | ||
| 4510 | ret = print_trace_line(&iter); | 4491 | ret = print_trace_line(&iter); | 
| @@ -4526,7 +4507,7 @@ __ftrace_dump(bool disable_tracing, enum ftrace_dump_mode oops_dump_mode) | |||
| 4526 | trace_flags |= old_userobj; | 4507 | trace_flags |= old_userobj; | 
| 4527 | 4508 | ||
| 4528 | for_each_tracing_cpu(cpu) { | 4509 | for_each_tracing_cpu(cpu) { | 
| 4529 | atomic_dec(&global_trace.data[cpu]->disabled); | 4510 | atomic_dec(&iter.tr->data[cpu]->disabled); | 
| 4530 | } | 4511 | } | 
| 4531 | tracing_on(); | 4512 | tracing_on(); | 
| 4532 | } | 4513 | } | 
| @@ -4575,16 +4556,14 @@ __init static int tracer_alloc_buffers(void) | |||
| 4575 | 4556 | ||
| 4576 | 4557 | ||
| 4577 | #ifdef CONFIG_TRACER_MAX_TRACE | 4558 | #ifdef CONFIG_TRACER_MAX_TRACE | 
| 4578 | max_tr.buffer = ring_buffer_alloc(ring_buf_size, | 4559 | max_tr.buffer = ring_buffer_alloc(1, TRACE_BUFFER_FLAGS); | 
| 4579 | TRACE_BUFFER_FLAGS); | ||
| 4580 | if (!max_tr.buffer) { | 4560 | if (!max_tr.buffer) { | 
| 4581 | printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); | 4561 | printk(KERN_ERR "tracer: failed to allocate max ring buffer!\n"); | 
| 4582 | WARN_ON(1); | 4562 | WARN_ON(1); | 
| 4583 | ring_buffer_free(global_trace.buffer); | 4563 | ring_buffer_free(global_trace.buffer); | 
| 4584 | goto out_free_cpumask; | 4564 | goto out_free_cpumask; | 
| 4585 | } | 4565 | } | 
| 4586 | max_tr.entries = ring_buffer_size(max_tr.buffer); | 4566 | max_tr.entries = 1; | 
| 4587 | WARN_ON(max_tr.entries != global_trace.entries); | ||
| 4588 | #endif | 4567 | #endif | 
| 4589 | 4568 | ||
| 4590 | /* Allocate the first page for all buffers */ | 4569 | /* Allocate the first page for all buffers */ | 
| @@ -4597,9 +4576,6 @@ __init static int tracer_alloc_buffers(void) | |||
| 4597 | 4576 | ||
| 4598 | register_tracer(&nop_trace); | 4577 | register_tracer(&nop_trace); | 
| 4599 | current_trace = &nop_trace; | 4578 | current_trace = &nop_trace; | 
| 4600 | #ifdef CONFIG_BOOT_TRACER | ||
| 4601 | register_tracer(&boot_tracer); | ||
| 4602 | #endif | ||
| 4603 | /* All seems OK, enable tracing */ | 4579 | /* All seems OK, enable tracing */ | 
| 4604 | tracing_disabled = 0; | 4580 | tracing_disabled = 0; | 
| 4605 | 4581 | ||
