aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c1245
1 files changed, 235 insertions, 1010 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 17bb88d86ac2..5b1e9a9e9906 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -37,6 +37,7 @@
37#include <linux/irqflags.h> 37#include <linux/irqflags.h>
38 38
39#include "trace.h" 39#include "trace.h"
40#include "trace_output.h"
40 41
41#define TRACE_BUFFER_FLAGS (RB_FL_OVERWRITE) 42#define TRACE_BUFFER_FLAGS (RB_FL_OVERWRITE)
42 43
@@ -52,6 +53,11 @@ unsigned long __read_mostly tracing_thresh;
52 */ 53 */
53static bool __read_mostly tracing_selftest_running; 54static bool __read_mostly tracing_selftest_running;
54 55
56/*
57 * If a tracer is running, we do not want to run SELFTEST.
58 */
59static bool __read_mostly tracing_selftest_disabled;
60
55/* For tracers that don't implement custom flags */ 61/* For tracers that don't implement custom flags */
56static struct tracer_opt dummy_tracer_opt[] = { 62static struct tracer_opt dummy_tracer_opt[] = {
57 { } 63 { }
@@ -109,14 +115,19 @@ static cpumask_var_t __read_mostly tracing_buffer_mask;
109 */ 115 */
110int ftrace_dump_on_oops; 116int ftrace_dump_on_oops;
111 117
112static int tracing_set_tracer(char *buf); 118static int tracing_set_tracer(const char *buf);
119
120#define BOOTUP_TRACER_SIZE 100
121static char bootup_tracer_buf[BOOTUP_TRACER_SIZE] __initdata;
122static char *default_bootup_tracer;
113 123
114static int __init set_ftrace(char *str) 124static int __init set_ftrace(char *str)
115{ 125{
116 tracing_set_tracer(str); 126 strncpy(bootup_tracer_buf, str, BOOTUP_TRACER_SIZE);
127 default_bootup_tracer = bootup_tracer_buf;
117 return 1; 128 return 1;
118} 129}
119__setup("ftrace", set_ftrace); 130__setup("ftrace=", set_ftrace);
120 131
121static int __init set_ftrace_dump_on_oops(char *str) 132static int __init set_ftrace_dump_on_oops(char *str)
122{ 133{
@@ -186,9 +197,6 @@ int tracing_is_enabled(void)
186 return tracer_enabled; 197 return tracer_enabled;
187} 198}
188 199
189/* function tracing enabled */
190int ftrace_function_enabled;
191
192/* 200/*
193 * trace_buf_size is the size in bytes that is allocated 201 * trace_buf_size is the size in bytes that is allocated
194 * for a buffer. Note, the number of bytes is always rounded 202 * for a buffer. Note, the number of bytes is always rounded
@@ -229,7 +237,7 @@ static DECLARE_WAIT_QUEUE_HEAD(trace_wait);
229 237
230/* trace_flags holds trace_options default values */ 238/* trace_flags holds trace_options default values */
231unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK | 239unsigned long trace_flags = TRACE_ITER_PRINT_PARENT | TRACE_ITER_PRINTK |
232 TRACE_ITER_ANNOTATE; 240 TRACE_ITER_ANNOTATE | TRACE_ITER_CONTEXT_INFO;
233 241
234/** 242/**
235 * trace_wake_up - wake up tasks waiting for trace input 243 * trace_wake_up - wake up tasks waiting for trace input
@@ -287,6 +295,7 @@ static const char *trace_options[] = {
287 "userstacktrace", 295 "userstacktrace",
288 "sym-userobj", 296 "sym-userobj",
289 "printk-msg-only", 297 "printk-msg-only",
298 "context-info",
290 NULL 299 NULL
291}; 300};
292 301
@@ -329,132 +338,6 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
329 tracing_record_cmdline(current); 338 tracing_record_cmdline(current);
330} 339}
331 340
332/**
333 * trace_seq_printf - sequence printing of trace information
334 * @s: trace sequence descriptor
335 * @fmt: printf format string
336 *
337 * The tracer may use either sequence operations or its own
338 * copy to user routines. To simplify formating of a trace
339 * trace_seq_printf is used to store strings into a special
340 * buffer (@s). Then the output may be either used by
341 * the sequencer or pulled into another buffer.
342 */
343int
344trace_seq_printf(struct trace_seq *s, const char *fmt, ...)
345{
346 int len = (PAGE_SIZE - 1) - s->len;
347 va_list ap;
348 int ret;
349
350 if (!len)
351 return 0;
352
353 va_start(ap, fmt);
354 ret = vsnprintf(s->buffer + s->len, len, fmt, ap);
355 va_end(ap);
356
357 /* If we can't write it all, don't bother writing anything */
358 if (ret >= len)
359 return 0;
360
361 s->len += ret;
362
363 return len;
364}
365
366/**
367 * trace_seq_puts - trace sequence printing of simple string
368 * @s: trace sequence descriptor
369 * @str: simple string to record
370 *
371 * The tracer may use either the sequence operations or its own
372 * copy to user routines. This function records a simple string
373 * into a special buffer (@s) for later retrieval by a sequencer
374 * or other mechanism.
375 */
376static int
377trace_seq_puts(struct trace_seq *s, const char *str)
378{
379 int len = strlen(str);
380
381 if (len > ((PAGE_SIZE - 1) - s->len))
382 return 0;
383
384 memcpy(s->buffer + s->len, str, len);
385 s->len += len;
386
387 return len;
388}
389
390static int
391trace_seq_putc(struct trace_seq *s, unsigned char c)
392{
393 if (s->len >= (PAGE_SIZE - 1))
394 return 0;
395
396 s->buffer[s->len++] = c;
397
398 return 1;
399}
400
401static int
402trace_seq_putmem(struct trace_seq *s, void *mem, size_t len)
403{
404 if (len > ((PAGE_SIZE - 1) - s->len))
405 return 0;
406
407 memcpy(s->buffer + s->len, mem, len);
408 s->len += len;
409
410 return len;
411}
412
413#define MAX_MEMHEX_BYTES 8
414#define HEX_CHARS (MAX_MEMHEX_BYTES*2 + 1)
415
416static int
417trace_seq_putmem_hex(struct trace_seq *s, void *mem, size_t len)
418{
419 unsigned char hex[HEX_CHARS];
420 unsigned char *data = mem;
421 int i, j;
422
423#ifdef __BIG_ENDIAN
424 for (i = 0, j = 0; i < len; i++) {
425#else
426 for (i = len-1, j = 0; i >= 0; i--) {
427#endif
428 hex[j++] = hex_asc_hi(data[i]);
429 hex[j++] = hex_asc_lo(data[i]);
430 }
431 hex[j++] = ' ';
432
433 return trace_seq_putmem(s, hex, j);
434}
435
436static int
437trace_seq_path(struct trace_seq *s, struct path *path)
438{
439 unsigned char *p;
440
441 if (s->len >= (PAGE_SIZE - 1))
442 return 0;
443 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
444 if (!IS_ERR(p)) {
445 p = mangle_path(s->buffer + s->len, p, "\n");
446 if (p) {
447 s->len = p - s->buffer;
448 return 1;
449 }
450 } else {
451 s->buffer[s->len++] = '?';
452 return 1;
453 }
454
455 return 0;
456}
457
458static void 341static void
459trace_seq_reset(struct trace_seq *s) 342trace_seq_reset(struct trace_seq *s)
460{ 343{
@@ -543,7 +426,7 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
543 426
544 ftrace_enable_cpu(); 427 ftrace_enable_cpu();
545 428
546 WARN_ON_ONCE(ret); 429 WARN_ON_ONCE(ret && ret != -EAGAIN);
547 430
548 __update_max_tr(tr, tsk, cpu); 431 __update_max_tr(tr, tsk, cpu);
549 __raw_spin_unlock(&ftrace_max_lock); 432 __raw_spin_unlock(&ftrace_max_lock);
@@ -596,7 +479,7 @@ int register_tracer(struct tracer *type)
596 type->flags->opts = dummy_tracer_opt; 479 type->flags->opts = dummy_tracer_opt;
597 480
598#ifdef CONFIG_FTRACE_STARTUP_TEST 481#ifdef CONFIG_FTRACE_STARTUP_TEST
599 if (type->selftest) { 482 if (type->selftest && !tracing_selftest_disabled) {
600 struct tracer *saved_tracer = current_trace; 483 struct tracer *saved_tracer = current_trace;
601 struct trace_array *tr = &global_trace; 484 struct trace_array *tr = &global_trace;
602 int i; 485 int i;
@@ -638,8 +521,26 @@ int register_tracer(struct tracer *type)
638 out: 521 out:
639 tracing_selftest_running = false; 522 tracing_selftest_running = false;
640 mutex_unlock(&trace_types_lock); 523 mutex_unlock(&trace_types_lock);
641 lock_kernel();
642 524
525 if (ret || !default_bootup_tracer)
526 goto out_unlock;
527
528 if (strncmp(default_bootup_tracer, type->name, BOOTUP_TRACER_SIZE))
529 goto out_unlock;
530
531 printk(KERN_INFO "Starting tracer '%s'\n", type->name);
532 /* Do we want this tracer to start on bootup? */
533 tracing_set_tracer(type->name);
534 default_bootup_tracer = NULL;
535 /* disable other selftests, since this will break it. */
536 tracing_selftest_disabled = 1;
537#ifdef CONFIG_FTRACE_STARTUP_TEST
538 printk(KERN_INFO "Disabling FTRACE selftests due to running tracer '%s'\n",
539 type->name);
540#endif
541
542 out_unlock:
543 lock_kernel();
643 return ret; 544 return ret;
644} 545}
645 546
@@ -658,6 +559,15 @@ void unregister_tracer(struct tracer *type)
658 559
659 found: 560 found:
660 *t = (*t)->next; 561 *t = (*t)->next;
562
563 if (type == current_trace && tracer_enabled) {
564 tracer_enabled = 0;
565 tracing_stop();
566 if (current_trace->stop)
567 current_trace->stop(&global_trace);
568 current_trace = &nop_trace;
569 }
570
661 if (strlen(type->name) != max_tracer_type_len) 571 if (strlen(type->name) != max_tracer_type_len)
662 goto out; 572 goto out;
663 573
@@ -738,13 +648,12 @@ void tracing_start(void)
738 return; 648 return;
739 649
740 spin_lock_irqsave(&tracing_start_lock, flags); 650 spin_lock_irqsave(&tracing_start_lock, flags);
741 if (--trace_stop_count) 651 if (--trace_stop_count) {
742 goto out; 652 if (trace_stop_count < 0) {
743 653 /* Someone screwed up their debugging */
744 if (trace_stop_count < 0) { 654 WARN_ON_ONCE(1);
745 /* Someone screwed up their debugging */ 655 trace_stop_count = 0;
746 WARN_ON_ONCE(1); 656 }
747 trace_stop_count = 0;
748 goto out; 657 goto out;
749 } 658 }
750 659
@@ -876,78 +785,100 @@ tracing_generic_entry_update(struct trace_entry *entry, unsigned long flags,
876 (need_resched() ? TRACE_FLAG_NEED_RESCHED : 0); 785 (need_resched() ? TRACE_FLAG_NEED_RESCHED : 0);
877} 786}
878 787
788struct ring_buffer_event *trace_buffer_lock_reserve(struct trace_array *tr,
789 unsigned char type,
790 unsigned long len,
791 unsigned long flags, int pc)
792{
793 struct ring_buffer_event *event;
794
795 event = ring_buffer_lock_reserve(tr->buffer, len);
796 if (event != NULL) {
797 struct trace_entry *ent = ring_buffer_event_data(event);
798
799 tracing_generic_entry_update(ent, flags, pc);
800 ent->type = type;
801 }
802
803 return event;
804}
805static void ftrace_trace_stack(struct trace_array *tr,
806 unsigned long flags, int skip, int pc);
807static void ftrace_trace_userstack(struct trace_array *tr,
808 unsigned long flags, int pc);
809
810void trace_buffer_unlock_commit(struct trace_array *tr,
811 struct ring_buffer_event *event,
812 unsigned long flags, int pc)
813{
814 ring_buffer_unlock_commit(tr->buffer, event);
815
816 ftrace_trace_stack(tr, flags, 6, pc);
817 ftrace_trace_userstack(tr, flags, pc);
818 trace_wake_up();
819}
820
879void 821void
880trace_function(struct trace_array *tr, struct trace_array_cpu *data, 822trace_function(struct trace_array *tr,
881 unsigned long ip, unsigned long parent_ip, unsigned long flags, 823 unsigned long ip, unsigned long parent_ip, unsigned long flags,
882 int pc) 824 int pc)
883{ 825{
884 struct ring_buffer_event *event; 826 struct ring_buffer_event *event;
885 struct ftrace_entry *entry; 827 struct ftrace_entry *entry;
886 unsigned long irq_flags;
887 828
888 /* If we are reading the ring buffer, don't trace */ 829 /* If we are reading the ring buffer, don't trace */
889 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) 830 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled))))
890 return; 831 return;
891 832
892 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 833 event = trace_buffer_lock_reserve(tr, TRACE_FN, sizeof(*entry),
893 &irq_flags); 834 flags, pc);
894 if (!event) 835 if (!event)
895 return; 836 return;
896 entry = ring_buffer_event_data(event); 837 entry = ring_buffer_event_data(event);
897 tracing_generic_entry_update(&entry->ent, flags, pc);
898 entry->ent.type = TRACE_FN;
899 entry->ip = ip; 838 entry->ip = ip;
900 entry->parent_ip = parent_ip; 839 entry->parent_ip = parent_ip;
901 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 840 ring_buffer_unlock_commit(tr->buffer, event);
902} 841}
903 842
904#ifdef CONFIG_FUNCTION_GRAPH_TRACER 843#ifdef CONFIG_FUNCTION_GRAPH_TRACER
905static void __trace_graph_entry(struct trace_array *tr, 844static void __trace_graph_entry(struct trace_array *tr,
906 struct trace_array_cpu *data,
907 struct ftrace_graph_ent *trace, 845 struct ftrace_graph_ent *trace,
908 unsigned long flags, 846 unsigned long flags,
909 int pc) 847 int pc)
910{ 848{
911 struct ring_buffer_event *event; 849 struct ring_buffer_event *event;
912 struct ftrace_graph_ent_entry *entry; 850 struct ftrace_graph_ent_entry *entry;
913 unsigned long irq_flags;
914 851
915 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) 852 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled))))
916 return; 853 return;
917 854
918 event = ring_buffer_lock_reserve(global_trace.buffer, sizeof(*entry), 855 event = trace_buffer_lock_reserve(&global_trace, TRACE_GRAPH_ENT,
919 &irq_flags); 856 sizeof(*entry), flags, pc);
920 if (!event) 857 if (!event)
921 return; 858 return;
922 entry = ring_buffer_event_data(event); 859 entry = ring_buffer_event_data(event);
923 tracing_generic_entry_update(&entry->ent, flags, pc);
924 entry->ent.type = TRACE_GRAPH_ENT;
925 entry->graph_ent = *trace; 860 entry->graph_ent = *trace;
926 ring_buffer_unlock_commit(global_trace.buffer, event, irq_flags); 861 ring_buffer_unlock_commit(global_trace.buffer, event);
927} 862}
928 863
929static void __trace_graph_return(struct trace_array *tr, 864static void __trace_graph_return(struct trace_array *tr,
930 struct trace_array_cpu *data,
931 struct ftrace_graph_ret *trace, 865 struct ftrace_graph_ret *trace,
932 unsigned long flags, 866 unsigned long flags,
933 int pc) 867 int pc)
934{ 868{
935 struct ring_buffer_event *event; 869 struct ring_buffer_event *event;
936 struct ftrace_graph_ret_entry *entry; 870 struct ftrace_graph_ret_entry *entry;
937 unsigned long irq_flags;
938 871
939 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled)))) 872 if (unlikely(local_read(&__get_cpu_var(ftrace_cpu_disabled))))
940 return; 873 return;
941 874
942 event = ring_buffer_lock_reserve(global_trace.buffer, sizeof(*entry), 875 event = trace_buffer_lock_reserve(&global_trace, TRACE_GRAPH_RET,
943 &irq_flags); 876 sizeof(*entry), flags, pc);
944 if (!event) 877 if (!event)
945 return; 878 return;
946 entry = ring_buffer_event_data(event); 879 entry = ring_buffer_event_data(event);
947 tracing_generic_entry_update(&entry->ent, flags, pc);
948 entry->ent.type = TRACE_GRAPH_RET;
949 entry->ret = *trace; 880 entry->ret = *trace;
950 ring_buffer_unlock_commit(global_trace.buffer, event, irq_flags); 881 ring_buffer_unlock_commit(global_trace.buffer, event);
951} 882}
952#endif 883#endif
953 884
@@ -957,31 +888,23 @@ ftrace(struct trace_array *tr, struct trace_array_cpu *data,
957 int pc) 888 int pc)
958{ 889{
959 if (likely(!atomic_read(&data->disabled))) 890 if (likely(!atomic_read(&data->disabled)))
960 trace_function(tr, data, ip, parent_ip, flags, pc); 891 trace_function(tr, ip, parent_ip, flags, pc);
961} 892}
962 893
963static void ftrace_trace_stack(struct trace_array *tr, 894static void __ftrace_trace_stack(struct trace_array *tr,
964 struct trace_array_cpu *data, 895 unsigned long flags,
965 unsigned long flags, 896 int skip, int pc)
966 int skip, int pc)
967{ 897{
968#ifdef CONFIG_STACKTRACE 898#ifdef CONFIG_STACKTRACE
969 struct ring_buffer_event *event; 899 struct ring_buffer_event *event;
970 struct stack_entry *entry; 900 struct stack_entry *entry;
971 struct stack_trace trace; 901 struct stack_trace trace;
972 unsigned long irq_flags;
973
974 if (!(trace_flags & TRACE_ITER_STACKTRACE))
975 return;
976 902
977 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 903 event = trace_buffer_lock_reserve(tr, TRACE_STACK,
978 &irq_flags); 904 sizeof(*entry), flags, pc);
979 if (!event) 905 if (!event)
980 return; 906 return;
981 entry = ring_buffer_event_data(event); 907 entry = ring_buffer_event_data(event);
982 tracing_generic_entry_update(&entry->ent, flags, pc);
983 entry->ent.type = TRACE_STACK;
984
985 memset(&entry->caller, 0, sizeof(entry->caller)); 908 memset(&entry->caller, 0, sizeof(entry->caller));
986 909
987 trace.nr_entries = 0; 910 trace.nr_entries = 0;
@@ -990,38 +913,43 @@ static void ftrace_trace_stack(struct trace_array *tr,
990 trace.entries = entry->caller; 913 trace.entries = entry->caller;
991 914
992 save_stack_trace(&trace); 915 save_stack_trace(&trace);
993 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 916 ring_buffer_unlock_commit(tr->buffer, event);
994#endif 917#endif
995} 918}
996 919
920static void ftrace_trace_stack(struct trace_array *tr,
921 unsigned long flags,
922 int skip, int pc)
923{
924 if (!(trace_flags & TRACE_ITER_STACKTRACE))
925 return;
926
927 __ftrace_trace_stack(tr, flags, skip, pc);
928}
929
997void __trace_stack(struct trace_array *tr, 930void __trace_stack(struct trace_array *tr,
998 struct trace_array_cpu *data,
999 unsigned long flags, 931 unsigned long flags,
1000 int skip) 932 int skip, int pc)
1001{ 933{
1002 ftrace_trace_stack(tr, data, flags, skip, preempt_count()); 934 __ftrace_trace_stack(tr, flags, skip, pc);
1003} 935}
1004 936
1005static void ftrace_trace_userstack(struct trace_array *tr, 937static void ftrace_trace_userstack(struct trace_array *tr,
1006 struct trace_array_cpu *data, 938 unsigned long flags, int pc)
1007 unsigned long flags, int pc)
1008{ 939{
1009#ifdef CONFIG_STACKTRACE 940#ifdef CONFIG_STACKTRACE
1010 struct ring_buffer_event *event; 941 struct ring_buffer_event *event;
1011 struct userstack_entry *entry; 942 struct userstack_entry *entry;
1012 struct stack_trace trace; 943 struct stack_trace trace;
1013 unsigned long irq_flags;
1014 944
1015 if (!(trace_flags & TRACE_ITER_USERSTACKTRACE)) 945 if (!(trace_flags & TRACE_ITER_USERSTACKTRACE))
1016 return; 946 return;
1017 947
1018 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 948 event = trace_buffer_lock_reserve(tr, TRACE_USER_STACK,
1019 &irq_flags); 949 sizeof(*entry), flags, pc);
1020 if (!event) 950 if (!event)
1021 return; 951 return;
1022 entry = ring_buffer_event_data(event); 952 entry = ring_buffer_event_data(event);
1023 tracing_generic_entry_update(&entry->ent, flags, pc);
1024 entry->ent.type = TRACE_USER_STACK;
1025 953
1026 memset(&entry->caller, 0, sizeof(entry->caller)); 954 memset(&entry->caller, 0, sizeof(entry->caller));
1027 955
@@ -1031,70 +959,56 @@ static void ftrace_trace_userstack(struct trace_array *tr,
1031 trace.entries = entry->caller; 959 trace.entries = entry->caller;
1032 960
1033 save_stack_trace_user(&trace); 961 save_stack_trace_user(&trace);
1034 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 962 ring_buffer_unlock_commit(tr->buffer, event);
1035#endif 963#endif
1036} 964}
1037 965
1038void __trace_userstack(struct trace_array *tr, 966void __trace_userstack(struct trace_array *tr, unsigned long flags)
1039 struct trace_array_cpu *data,
1040 unsigned long flags)
1041{ 967{
1042 ftrace_trace_userstack(tr, data, flags, preempt_count()); 968 ftrace_trace_userstack(tr, flags, preempt_count());
1043} 969}
1044 970
1045static void 971static void
1046ftrace_trace_special(void *__tr, void *__data, 972ftrace_trace_special(void *__tr,
1047 unsigned long arg1, unsigned long arg2, unsigned long arg3, 973 unsigned long arg1, unsigned long arg2, unsigned long arg3,
1048 int pc) 974 int pc)
1049{ 975{
1050 struct ring_buffer_event *event; 976 struct ring_buffer_event *event;
1051 struct trace_array_cpu *data = __data;
1052 struct trace_array *tr = __tr; 977 struct trace_array *tr = __tr;
1053 struct special_entry *entry; 978 struct special_entry *entry;
1054 unsigned long irq_flags;
1055 979
1056 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 980 event = trace_buffer_lock_reserve(tr, TRACE_SPECIAL,
1057 &irq_flags); 981 sizeof(*entry), 0, pc);
1058 if (!event) 982 if (!event)
1059 return; 983 return;
1060 entry = ring_buffer_event_data(event); 984 entry = ring_buffer_event_data(event);
1061 tracing_generic_entry_update(&entry->ent, 0, pc);
1062 entry->ent.type = TRACE_SPECIAL;
1063 entry->arg1 = arg1; 985 entry->arg1 = arg1;
1064 entry->arg2 = arg2; 986 entry->arg2 = arg2;
1065 entry->arg3 = arg3; 987 entry->arg3 = arg3;
1066 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 988 trace_buffer_unlock_commit(tr, event, 0, pc);
1067 ftrace_trace_stack(tr, data, irq_flags, 4, pc);
1068 ftrace_trace_userstack(tr, data, irq_flags, pc);
1069
1070 trace_wake_up();
1071} 989}
1072 990
1073void 991void
1074__trace_special(void *__tr, void *__data, 992__trace_special(void *__tr, void *__data,
1075 unsigned long arg1, unsigned long arg2, unsigned long arg3) 993 unsigned long arg1, unsigned long arg2, unsigned long arg3)
1076{ 994{
1077 ftrace_trace_special(__tr, __data, arg1, arg2, arg3, preempt_count()); 995 ftrace_trace_special(__tr, arg1, arg2, arg3, preempt_count());
1078} 996}
1079 997
1080void 998void
1081tracing_sched_switch_trace(struct trace_array *tr, 999tracing_sched_switch_trace(struct trace_array *tr,
1082 struct trace_array_cpu *data,
1083 struct task_struct *prev, 1000 struct task_struct *prev,
1084 struct task_struct *next, 1001 struct task_struct *next,
1085 unsigned long flags, int pc) 1002 unsigned long flags, int pc)
1086{ 1003{
1087 struct ring_buffer_event *event; 1004 struct ring_buffer_event *event;
1088 struct ctx_switch_entry *entry; 1005 struct ctx_switch_entry *entry;
1089 unsigned long irq_flags;
1090 1006
1091 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 1007 event = trace_buffer_lock_reserve(tr, TRACE_CTX,
1092 &irq_flags); 1008 sizeof(*entry), flags, pc);
1093 if (!event) 1009 if (!event)
1094 return; 1010 return;
1095 entry = ring_buffer_event_data(event); 1011 entry = ring_buffer_event_data(event);
1096 tracing_generic_entry_update(&entry->ent, flags, pc);
1097 entry->ent.type = TRACE_CTX;
1098 entry->prev_pid = prev->pid; 1012 entry->prev_pid = prev->pid;
1099 entry->prev_prio = prev->prio; 1013 entry->prev_prio = prev->prio;
1100 entry->prev_state = prev->state; 1014 entry->prev_state = prev->state;
@@ -1102,29 +1016,23 @@ tracing_sched_switch_trace(struct trace_array *tr,
1102 entry->next_prio = next->prio; 1016 entry->next_prio = next->prio;
1103 entry->next_state = next->state; 1017 entry->next_state = next->state;
1104 entry->next_cpu = task_cpu(next); 1018 entry->next_cpu = task_cpu(next);
1105 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 1019 trace_buffer_unlock_commit(tr, event, flags, pc);
1106 ftrace_trace_stack(tr, data, flags, 5, pc);
1107 ftrace_trace_userstack(tr, data, flags, pc);
1108} 1020}
1109 1021
1110void 1022void
1111tracing_sched_wakeup_trace(struct trace_array *tr, 1023tracing_sched_wakeup_trace(struct trace_array *tr,
1112 struct trace_array_cpu *data,
1113 struct task_struct *wakee, 1024 struct task_struct *wakee,
1114 struct task_struct *curr, 1025 struct task_struct *curr,
1115 unsigned long flags, int pc) 1026 unsigned long flags, int pc)
1116{ 1027{
1117 struct ring_buffer_event *event; 1028 struct ring_buffer_event *event;
1118 struct ctx_switch_entry *entry; 1029 struct ctx_switch_entry *entry;
1119 unsigned long irq_flags;
1120 1030
1121 event = ring_buffer_lock_reserve(tr->buffer, sizeof(*entry), 1031 event = trace_buffer_lock_reserve(tr, TRACE_WAKE,
1122 &irq_flags); 1032 sizeof(*entry), flags, pc);
1123 if (!event) 1033 if (!event)
1124 return; 1034 return;
1125 entry = ring_buffer_event_data(event); 1035 entry = ring_buffer_event_data(event);
1126 tracing_generic_entry_update(&entry->ent, flags, pc);
1127 entry->ent.type = TRACE_WAKE;
1128 entry->prev_pid = curr->pid; 1036 entry->prev_pid = curr->pid;
1129 entry->prev_prio = curr->prio; 1037 entry->prev_prio = curr->prio;
1130 entry->prev_state = curr->state; 1038 entry->prev_state = curr->state;
@@ -1132,11 +1040,7 @@ tracing_sched_wakeup_trace(struct trace_array *tr,
1132 entry->next_prio = wakee->prio; 1040 entry->next_prio = wakee->prio;
1133 entry->next_state = wakee->state; 1041 entry->next_state = wakee->state;
1134 entry->next_cpu = task_cpu(wakee); 1042 entry->next_cpu = task_cpu(wakee);
1135 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 1043 trace_buffer_unlock_commit(tr, event, flags, pc);
1136 ftrace_trace_stack(tr, data, flags, 6, pc);
1137 ftrace_trace_userstack(tr, data, flags, pc);
1138
1139 trace_wake_up();
1140} 1044}
1141 1045
1142void 1046void
@@ -1157,66 +1061,7 @@ ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3)
1157 data = tr->data[cpu]; 1061 data = tr->data[cpu];
1158 1062
1159 if (likely(atomic_inc_return(&data->disabled) == 1)) 1063 if (likely(atomic_inc_return(&data->disabled) == 1))
1160 ftrace_trace_special(tr, data, arg1, arg2, arg3, pc); 1064 ftrace_trace_special(tr, arg1, arg2, arg3, pc);
1161
1162 atomic_dec(&data->disabled);
1163 local_irq_restore(flags);
1164}
1165
1166#ifdef CONFIG_FUNCTION_TRACER
1167static void
1168function_trace_call_preempt_only(unsigned long ip, unsigned long parent_ip)
1169{
1170 struct trace_array *tr = &global_trace;
1171 struct trace_array_cpu *data;
1172 unsigned long flags;
1173 long disabled;
1174 int cpu, resched;
1175 int pc;
1176
1177 if (unlikely(!ftrace_function_enabled))
1178 return;
1179
1180 pc = preempt_count();
1181 resched = ftrace_preempt_disable();
1182 local_save_flags(flags);
1183 cpu = raw_smp_processor_id();
1184 data = tr->data[cpu];
1185 disabled = atomic_inc_return(&data->disabled);
1186
1187 if (likely(disabled == 1))
1188 trace_function(tr, data, ip, parent_ip, flags, pc);
1189
1190 atomic_dec(&data->disabled);
1191 ftrace_preempt_enable(resched);
1192}
1193
1194static void
1195function_trace_call(unsigned long ip, unsigned long parent_ip)
1196{
1197 struct trace_array *tr = &global_trace;
1198 struct trace_array_cpu *data;
1199 unsigned long flags;
1200 long disabled;
1201 int cpu;
1202 int pc;
1203
1204 if (unlikely(!ftrace_function_enabled))
1205 return;
1206
1207 /*
1208 * Need to use raw, since this must be called before the
1209 * recursive protection is performed.
1210 */
1211 local_irq_save(flags);
1212 cpu = raw_smp_processor_id();
1213 data = tr->data[cpu];
1214 disabled = atomic_inc_return(&data->disabled);
1215
1216 if (likely(disabled == 1)) {
1217 pc = preempt_count();
1218 trace_function(tr, data, ip, parent_ip, flags, pc);
1219 }
1220 1065
1221 atomic_dec(&data->disabled); 1066 atomic_dec(&data->disabled);
1222 local_irq_restore(flags); 1067 local_irq_restore(flags);
@@ -1244,7 +1089,7 @@ int trace_graph_entry(struct ftrace_graph_ent *trace)
1244 disabled = atomic_inc_return(&data->disabled); 1089 disabled = atomic_inc_return(&data->disabled);
1245 if (likely(disabled == 1)) { 1090 if (likely(disabled == 1)) {
1246 pc = preempt_count(); 1091 pc = preempt_count();
1247 __trace_graph_entry(tr, data, trace, flags, pc); 1092 __trace_graph_entry(tr, trace, flags, pc);
1248 } 1093 }
1249 /* Only do the atomic if it is not already set */ 1094 /* Only do the atomic if it is not already set */
1250 if (!test_tsk_trace_graph(current)) 1095 if (!test_tsk_trace_graph(current))
@@ -1270,7 +1115,7 @@ void trace_graph_return(struct ftrace_graph_ret *trace)
1270 disabled = atomic_inc_return(&data->disabled); 1115 disabled = atomic_inc_return(&data->disabled);
1271 if (likely(disabled == 1)) { 1116 if (likely(disabled == 1)) {
1272 pc = preempt_count(); 1117 pc = preempt_count();
1273 __trace_graph_return(tr, data, trace, flags, pc); 1118 __trace_graph_return(tr, trace, flags, pc);
1274 } 1119 }
1275 if (!trace->depth) 1120 if (!trace->depth)
1276 clear_tsk_trace_graph(current); 1121 clear_tsk_trace_graph(current);
@@ -1279,31 +1124,6 @@ void trace_graph_return(struct ftrace_graph_ret *trace)
1279} 1124}
1280#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 1125#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
1281 1126
1282static struct ftrace_ops trace_ops __read_mostly =
1283{
1284 .func = function_trace_call,
1285};
1286
1287void tracing_start_function_trace(void)
1288{
1289 ftrace_function_enabled = 0;
1290
1291 if (trace_flags & TRACE_ITER_PREEMPTONLY)
1292 trace_ops.func = function_trace_call_preempt_only;
1293 else
1294 trace_ops.func = function_trace_call;
1295
1296 register_ftrace_function(&trace_ops);
1297 ftrace_function_enabled = 1;
1298}
1299
1300void tracing_stop_function_trace(void)
1301{
1302 ftrace_function_enabled = 0;
1303 unregister_ftrace_function(&trace_ops);
1304}
1305#endif
1306
1307enum trace_file_type { 1127enum trace_file_type {
1308 TRACE_FILE_LAT_FMT = 1, 1128 TRACE_FILE_LAT_FMT = 1,
1309 TRACE_FILE_ANNOTATE = 2, 1129 TRACE_FILE_ANNOTATE = 2,
@@ -1376,8 +1196,8 @@ __find_next_entry(struct trace_iterator *iter, int *ent_cpu, u64 *ent_ts)
1376} 1196}
1377 1197
1378/* Find the next real entry, without updating the iterator itself */ 1198/* Find the next real entry, without updating the iterator itself */
1379static struct trace_entry * 1199struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
1380find_next_entry(struct trace_iterator *iter, int *ent_cpu, u64 *ent_ts) 1200 int *ent_cpu, u64 *ent_ts)
1381{ 1201{
1382 return __find_next_entry(iter, ent_cpu, ent_ts); 1202 return __find_next_entry(iter, ent_cpu, ent_ts);
1383} 1203}
@@ -1472,154 +1292,6 @@ static void s_stop(struct seq_file *m, void *p)
1472 mutex_unlock(&trace_types_lock); 1292 mutex_unlock(&trace_types_lock);
1473} 1293}
1474 1294
1475#ifdef CONFIG_KRETPROBES
1476static inline const char *kretprobed(const char *name)
1477{
1478 static const char tramp_name[] = "kretprobe_trampoline";
1479 int size = sizeof(tramp_name);
1480
1481 if (strncmp(tramp_name, name, size) == 0)
1482 return "[unknown/kretprobe'd]";
1483 return name;
1484}
1485#else
1486static inline const char *kretprobed(const char *name)
1487{
1488 return name;
1489}
1490#endif /* CONFIG_KRETPROBES */
1491
1492static int
1493seq_print_sym_short(struct trace_seq *s, const char *fmt, unsigned long address)
1494{
1495#ifdef CONFIG_KALLSYMS
1496 char str[KSYM_SYMBOL_LEN];
1497 const char *name;
1498
1499 kallsyms_lookup(address, NULL, NULL, NULL, str);
1500
1501 name = kretprobed(str);
1502
1503 return trace_seq_printf(s, fmt, name);
1504#endif
1505 return 1;
1506}
1507
1508static int
1509seq_print_sym_offset(struct trace_seq *s, const char *fmt,
1510 unsigned long address)
1511{
1512#ifdef CONFIG_KALLSYMS
1513 char str[KSYM_SYMBOL_LEN];
1514 const char *name;
1515
1516 sprint_symbol(str, address);
1517 name = kretprobed(str);
1518
1519 return trace_seq_printf(s, fmt, name);
1520#endif
1521 return 1;
1522}
1523
1524#ifndef CONFIG_64BIT
1525# define IP_FMT "%08lx"
1526#else
1527# define IP_FMT "%016lx"
1528#endif
1529
1530int
1531seq_print_ip_sym(struct trace_seq *s, unsigned long ip, unsigned long sym_flags)
1532{
1533 int ret;
1534
1535 if (!ip)
1536 return trace_seq_printf(s, "0");
1537
1538 if (sym_flags & TRACE_ITER_SYM_OFFSET)
1539 ret = seq_print_sym_offset(s, "%s", ip);
1540 else
1541 ret = seq_print_sym_short(s, "%s", ip);
1542
1543 if (!ret)
1544 return 0;
1545
1546 if (sym_flags & TRACE_ITER_SYM_ADDR)
1547 ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
1548 return ret;
1549}
1550
1551static inline int seq_print_user_ip(struct trace_seq *s, struct mm_struct *mm,
1552 unsigned long ip, unsigned long sym_flags)
1553{
1554 struct file *file = NULL;
1555 unsigned long vmstart = 0;
1556 int ret = 1;
1557
1558 if (mm) {
1559 const struct vm_area_struct *vma;
1560
1561 down_read(&mm->mmap_sem);
1562 vma = find_vma(mm, ip);
1563 if (vma) {
1564 file = vma->vm_file;
1565 vmstart = vma->vm_start;
1566 }
1567 if (file) {
1568 ret = trace_seq_path(s, &file->f_path);
1569 if (ret)
1570 ret = trace_seq_printf(s, "[+0x%lx]", ip - vmstart);
1571 }
1572 up_read(&mm->mmap_sem);
1573 }
1574 if (ret && ((sym_flags & TRACE_ITER_SYM_ADDR) || !file))
1575 ret = trace_seq_printf(s, " <" IP_FMT ">", ip);
1576 return ret;
1577}
1578
1579static int
1580seq_print_userip_objs(const struct userstack_entry *entry, struct trace_seq *s,
1581 unsigned long sym_flags)
1582{
1583 struct mm_struct *mm = NULL;
1584 int ret = 1;
1585 unsigned int i;
1586
1587 if (trace_flags & TRACE_ITER_SYM_USEROBJ) {
1588 struct task_struct *task;
1589 /*
1590 * we do the lookup on the thread group leader,
1591 * since individual threads might have already quit!
1592 */
1593 rcu_read_lock();
1594 task = find_task_by_vpid(entry->ent.tgid);
1595 if (task)
1596 mm = get_task_mm(task);
1597 rcu_read_unlock();
1598 }
1599
1600 for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
1601 unsigned long ip = entry->caller[i];
1602
1603 if (ip == ULONG_MAX || !ret)
1604 break;
1605 if (i && ret)
1606 ret = trace_seq_puts(s, " <- ");
1607 if (!ip) {
1608 if (ret)
1609 ret = trace_seq_puts(s, "??");
1610 continue;
1611 }
1612 if (!ret)
1613 break;
1614 if (ret)
1615 ret = seq_print_user_ip(s, mm, ip, sym_flags);
1616 }
1617
1618 if (mm)
1619 mmput(mm);
1620 return ret;
1621}
1622
1623static void print_lat_help_header(struct seq_file *m) 1295static void print_lat_help_header(struct seq_file *m)
1624{ 1296{
1625 seq_puts(m, "# _------=> CPU# \n"); 1297 seq_puts(m, "# _------=> CPU# \n");
@@ -1704,103 +1376,6 @@ print_trace_header(struct seq_file *m, struct trace_iterator *iter)
1704 seq_puts(m, "\n"); 1376 seq_puts(m, "\n");
1705} 1377}
1706 1378
1707static void
1708lat_print_generic(struct trace_seq *s, struct trace_entry *entry, int cpu)
1709{
1710 int hardirq, softirq;
1711 char *comm;
1712
1713 comm = trace_find_cmdline(entry->pid);
1714
1715 trace_seq_printf(s, "%8.8s-%-5d ", comm, entry->pid);
1716 trace_seq_printf(s, "%3d", cpu);
1717 trace_seq_printf(s, "%c%c",
1718 (entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
1719 (entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 'X' : '.',
1720 ((entry->flags & TRACE_FLAG_NEED_RESCHED) ? 'N' : '.'));
1721
1722 hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
1723 softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
1724 if (hardirq && softirq) {
1725 trace_seq_putc(s, 'H');
1726 } else {
1727 if (hardirq) {
1728 trace_seq_putc(s, 'h');
1729 } else {
1730 if (softirq)
1731 trace_seq_putc(s, 's');
1732 else
1733 trace_seq_putc(s, '.');
1734 }
1735 }
1736
1737 if (entry->preempt_count)
1738 trace_seq_printf(s, "%x", entry->preempt_count);
1739 else
1740 trace_seq_puts(s, ".");
1741}
1742
1743unsigned long preempt_mark_thresh = 100;
1744
1745static void
1746lat_print_timestamp(struct trace_seq *s, u64 abs_usecs,
1747 unsigned long rel_usecs)
1748{
1749 trace_seq_printf(s, " %4lldus", abs_usecs);
1750 if (rel_usecs > preempt_mark_thresh)
1751 trace_seq_puts(s, "!: ");
1752 else if (rel_usecs > 1)
1753 trace_seq_puts(s, "+: ");
1754 else
1755 trace_seq_puts(s, " : ");
1756}
1757
1758static const char state_to_char[] = TASK_STATE_TO_CHAR_STR;
1759
1760static int task_state_char(unsigned long state)
1761{
1762 int bit = state ? __ffs(state) + 1 : 0;
1763
1764 return bit < sizeof(state_to_char) - 1 ? state_to_char[bit] : '?';
1765}
1766
1767/*
1768 * The message is supposed to contain an ending newline.
1769 * If the printing stops prematurely, try to add a newline of our own.
1770 */
1771void trace_seq_print_cont(struct trace_seq *s, struct trace_iterator *iter)
1772{
1773 struct trace_entry *ent;
1774 struct trace_field_cont *cont;
1775 bool ok = true;
1776
1777 ent = peek_next_entry(iter, iter->cpu, NULL);
1778 if (!ent || ent->type != TRACE_CONT) {
1779 trace_seq_putc(s, '\n');
1780 return;
1781 }
1782
1783 do {
1784 cont = (struct trace_field_cont *)ent;
1785 if (ok)
1786 ok = (trace_seq_printf(s, "%s", cont->buf) > 0);
1787
1788 ftrace_disable_cpu();
1789
1790 if (iter->buffer_iter[iter->cpu])
1791 ring_buffer_read(iter->buffer_iter[iter->cpu], NULL);
1792 else
1793 ring_buffer_consume(iter->tr->buffer, iter->cpu, NULL);
1794
1795 ftrace_enable_cpu();
1796
1797 ent = peek_next_entry(iter, iter->cpu, NULL);
1798 } while (ent && ent->type == TRACE_CONT);
1799
1800 if (!ok)
1801 trace_seq_putc(s, '\n');
1802}
1803
1804static void test_cpu_buff_start(struct trace_iterator *iter) 1379static void test_cpu_buff_start(struct trace_iterator *iter)
1805{ 1380{
1806 struct trace_seq *s = &iter->seq; 1381 struct trace_seq *s = &iter->seq;
@@ -1818,138 +1393,31 @@ static void test_cpu_buff_start(struct trace_iterator *iter)
1818 trace_seq_printf(s, "##### CPU %u buffer started ####\n", iter->cpu); 1393 trace_seq_printf(s, "##### CPU %u buffer started ####\n", iter->cpu);
1819} 1394}
1820 1395
1821static enum print_line_t 1396static enum print_line_t print_lat_fmt(struct trace_iterator *iter)
1822print_lat_fmt(struct trace_iterator *iter, unsigned int trace_idx, int cpu)
1823{ 1397{
1824 struct trace_seq *s = &iter->seq; 1398 struct trace_seq *s = &iter->seq;
1825 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); 1399 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
1826 struct trace_entry *next_entry; 1400 struct trace_event *event;
1827 unsigned long verbose = (trace_flags & TRACE_ITER_VERBOSE);
1828 struct trace_entry *entry = iter->ent; 1401 struct trace_entry *entry = iter->ent;
1829 unsigned long abs_usecs;
1830 unsigned long rel_usecs;
1831 u64 next_ts;
1832 char *comm;
1833 int S, T;
1834 int i;
1835
1836 if (entry->type == TRACE_CONT)
1837 return TRACE_TYPE_HANDLED;
1838 1402
1839 test_cpu_buff_start(iter); 1403 test_cpu_buff_start(iter);
1840 1404
1841 next_entry = find_next_entry(iter, NULL, &next_ts); 1405 event = ftrace_find_event(entry->type);
1842 if (!next_entry)
1843 next_ts = iter->ts;
1844 rel_usecs = ns2usecs(next_ts - iter->ts);
1845 abs_usecs = ns2usecs(iter->ts - iter->tr->time_start);
1846
1847 if (verbose) {
1848 comm = trace_find_cmdline(entry->pid);
1849 trace_seq_printf(s, "%16s %5d %3d %d %08x %08x [%08lx]"
1850 " %ld.%03ldms (+%ld.%03ldms): ",
1851 comm,
1852 entry->pid, cpu, entry->flags,
1853 entry->preempt_count, trace_idx,
1854 ns2usecs(iter->ts),
1855 abs_usecs/1000,
1856 abs_usecs % 1000, rel_usecs/1000,
1857 rel_usecs % 1000);
1858 } else {
1859 lat_print_generic(s, entry, cpu);
1860 lat_print_timestamp(s, abs_usecs, rel_usecs);
1861 }
1862 switch (entry->type) {
1863 case TRACE_FN: {
1864 struct ftrace_entry *field;
1865
1866 trace_assign_type(field, entry);
1867
1868 seq_print_ip_sym(s, field->ip, sym_flags);
1869 trace_seq_puts(s, " (");
1870 seq_print_ip_sym(s, field->parent_ip, sym_flags);
1871 trace_seq_puts(s, ")\n");
1872 break;
1873 }
1874 case TRACE_CTX:
1875 case TRACE_WAKE: {
1876 struct ctx_switch_entry *field;
1877
1878 trace_assign_type(field, entry);
1879
1880 T = task_state_char(field->next_state);
1881 S = task_state_char(field->prev_state);
1882 comm = trace_find_cmdline(field->next_pid);
1883 trace_seq_printf(s, " %5d:%3d:%c %s [%03d] %5d:%3d:%c %s\n",
1884 field->prev_pid,
1885 field->prev_prio,
1886 S, entry->type == TRACE_CTX ? "==>" : " +",
1887 field->next_cpu,
1888 field->next_pid,
1889 field->next_prio,
1890 T, comm);
1891 break;
1892 }
1893 case TRACE_SPECIAL: {
1894 struct special_entry *field;
1895
1896 trace_assign_type(field, entry);
1897
1898 trace_seq_printf(s, "# %ld %ld %ld\n",
1899 field->arg1,
1900 field->arg2,
1901 field->arg3);
1902 break;
1903 }
1904 case TRACE_STACK: {
1905 struct stack_entry *field;
1906
1907 trace_assign_type(field, entry);
1908
1909 for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
1910 if (i)
1911 trace_seq_puts(s, " <= ");
1912 seq_print_ip_sym(s, field->caller[i], sym_flags);
1913 }
1914 trace_seq_puts(s, "\n");
1915 break;
1916 }
1917 case TRACE_PRINT: {
1918 struct print_entry *field;
1919
1920 trace_assign_type(field, entry);
1921 1406
1922 seq_print_ip_sym(s, field->ip, sym_flags); 1407 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
1923 trace_seq_printf(s, ": %s", field->buf); 1408 if (!trace_print_lat_context(iter))
1924 if (entry->flags & TRACE_FLAG_CONT) 1409 goto partial;
1925 trace_seq_print_cont(s, iter);
1926 break;
1927 } 1410 }
1928 case TRACE_BRANCH: {
1929 struct trace_branch *field;
1930 1411
1931 trace_assign_type(field, entry); 1412 if (event)
1413 return event->latency_trace(iter, sym_flags);
1932 1414
1933 trace_seq_printf(s, "[%s] %s:%s:%d\n", 1415 if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
1934 field->correct ? " ok " : " MISS ", 1416 goto partial;
1935 field->func,
1936 field->file,
1937 field->line);
1938 break;
1939 }
1940 case TRACE_USER_STACK: {
1941 struct userstack_entry *field;
1942 1417
1943 trace_assign_type(field, entry);
1944
1945 seq_print_userip_objs(field, s, sym_flags);
1946 trace_seq_putc(s, '\n');
1947 break;
1948 }
1949 default:
1950 trace_seq_printf(s, "Unknown type %d\n", entry->type);
1951 }
1952 return TRACE_TYPE_HANDLED; 1418 return TRACE_TYPE_HANDLED;
1419partial:
1420 return TRACE_TYPE_PARTIAL_LINE;
1953} 1421}
1954 1422
1955static enum print_line_t print_trace_fmt(struct trace_iterator *iter) 1423static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
@@ -1957,313 +1425,78 @@ static enum print_line_t print_trace_fmt(struct trace_iterator *iter)
1957 struct trace_seq *s = &iter->seq; 1425 struct trace_seq *s = &iter->seq;
1958 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK); 1426 unsigned long sym_flags = (trace_flags & TRACE_ITER_SYM_MASK);
1959 struct trace_entry *entry; 1427 struct trace_entry *entry;
1960 unsigned long usec_rem; 1428 struct trace_event *event;
1961 unsigned long long t;
1962 unsigned long secs;
1963 char *comm;
1964 int ret;
1965 int S, T;
1966 int i;
1967 1429
1968 entry = iter->ent; 1430 entry = iter->ent;
1969 1431
1970 if (entry->type == TRACE_CONT)
1971 return TRACE_TYPE_HANDLED;
1972
1973 test_cpu_buff_start(iter); 1432 test_cpu_buff_start(iter);
1974 1433
1975 comm = trace_find_cmdline(iter->ent->pid); 1434 event = ftrace_find_event(entry->type);
1976
1977 t = ns2usecs(iter->ts);
1978 usec_rem = do_div(t, 1000000ULL);
1979 secs = (unsigned long)t;
1980
1981 ret = trace_seq_printf(s, "%16s-%-5d ", comm, entry->pid);
1982 if (!ret)
1983 return TRACE_TYPE_PARTIAL_LINE;
1984 ret = trace_seq_printf(s, "[%03d] ", iter->cpu);
1985 if (!ret)
1986 return TRACE_TYPE_PARTIAL_LINE;
1987 ret = trace_seq_printf(s, "%5lu.%06lu: ", secs, usec_rem);
1988 if (!ret)
1989 return TRACE_TYPE_PARTIAL_LINE;
1990 1435
1991 switch (entry->type) { 1436 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
1992 case TRACE_FN: { 1437 if (!trace_print_context(iter))
1993 struct ftrace_entry *field; 1438 goto partial;
1994
1995 trace_assign_type(field, entry);
1996
1997 ret = seq_print_ip_sym(s, field->ip, sym_flags);
1998 if (!ret)
1999 return TRACE_TYPE_PARTIAL_LINE;
2000 if ((sym_flags & TRACE_ITER_PRINT_PARENT) &&
2001 field->parent_ip) {
2002 ret = trace_seq_printf(s, " <-");
2003 if (!ret)
2004 return TRACE_TYPE_PARTIAL_LINE;
2005 ret = seq_print_ip_sym(s,
2006 field->parent_ip,
2007 sym_flags);
2008 if (!ret)
2009 return TRACE_TYPE_PARTIAL_LINE;
2010 }
2011 ret = trace_seq_printf(s, "\n");
2012 if (!ret)
2013 return TRACE_TYPE_PARTIAL_LINE;
2014 break;
2015 }
2016 case TRACE_CTX:
2017 case TRACE_WAKE: {
2018 struct ctx_switch_entry *field;
2019
2020 trace_assign_type(field, entry);
2021
2022 T = task_state_char(field->next_state);
2023 S = task_state_char(field->prev_state);
2024 ret = trace_seq_printf(s, " %5d:%3d:%c %s [%03d] %5d:%3d:%c\n",
2025 field->prev_pid,
2026 field->prev_prio,
2027 S,
2028 entry->type == TRACE_CTX ? "==>" : " +",
2029 field->next_cpu,
2030 field->next_pid,
2031 field->next_prio,
2032 T);
2033 if (!ret)
2034 return TRACE_TYPE_PARTIAL_LINE;
2035 break;
2036 } 1439 }
2037 case TRACE_SPECIAL: {
2038 struct special_entry *field;
2039 1440
2040 trace_assign_type(field, entry); 1441 if (event)
1442 return event->trace(iter, sym_flags);
2041 1443
2042 ret = trace_seq_printf(s, "# %ld %ld %ld\n", 1444 if (!trace_seq_printf(s, "Unknown type %d\n", entry->type))
2043 field->arg1, 1445 goto partial;
2044 field->arg2,
2045 field->arg3);
2046 if (!ret)
2047 return TRACE_TYPE_PARTIAL_LINE;
2048 break;
2049 }
2050 case TRACE_STACK: {
2051 struct stack_entry *field;
2052 1446
2053 trace_assign_type(field, entry);
2054
2055 for (i = 0; i < FTRACE_STACK_ENTRIES; i++) {
2056 if (i) {
2057 ret = trace_seq_puts(s, " <= ");
2058 if (!ret)
2059 return TRACE_TYPE_PARTIAL_LINE;
2060 }
2061 ret = seq_print_ip_sym(s, field->caller[i],
2062 sym_flags);
2063 if (!ret)
2064 return TRACE_TYPE_PARTIAL_LINE;
2065 }
2066 ret = trace_seq_puts(s, "\n");
2067 if (!ret)
2068 return TRACE_TYPE_PARTIAL_LINE;
2069 break;
2070 }
2071 case TRACE_PRINT: {
2072 struct print_entry *field;
2073
2074 trace_assign_type(field, entry);
2075
2076 seq_print_ip_sym(s, field->ip, sym_flags);
2077 trace_seq_printf(s, ": %s", field->buf);
2078 if (entry->flags & TRACE_FLAG_CONT)
2079 trace_seq_print_cont(s, iter);
2080 break;
2081 }
2082 case TRACE_GRAPH_RET: {
2083 return print_graph_function(iter);
2084 }
2085 case TRACE_GRAPH_ENT: {
2086 return print_graph_function(iter);
2087 }
2088 case TRACE_BRANCH: {
2089 struct trace_branch *field;
2090
2091 trace_assign_type(field, entry);
2092
2093 trace_seq_printf(s, "[%s] %s:%s:%d\n",
2094 field->correct ? " ok " : " MISS ",
2095 field->func,
2096 field->file,
2097 field->line);
2098 break;
2099 }
2100 case TRACE_USER_STACK: {
2101 struct userstack_entry *field;
2102
2103 trace_assign_type(field, entry);
2104
2105 ret = seq_print_userip_objs(field, s, sym_flags);
2106 if (!ret)
2107 return TRACE_TYPE_PARTIAL_LINE;
2108 ret = trace_seq_putc(s, '\n');
2109 if (!ret)
2110 return TRACE_TYPE_PARTIAL_LINE;
2111 break;
2112 }
2113 }
2114 return TRACE_TYPE_HANDLED; 1447 return TRACE_TYPE_HANDLED;
1448partial:
1449 return TRACE_TYPE_PARTIAL_LINE;
2115} 1450}
2116 1451
2117static enum print_line_t print_raw_fmt(struct trace_iterator *iter) 1452static enum print_line_t print_raw_fmt(struct trace_iterator *iter)
2118{ 1453{
2119 struct trace_seq *s = &iter->seq; 1454 struct trace_seq *s = &iter->seq;
2120 struct trace_entry *entry; 1455 struct trace_entry *entry;
2121 int ret; 1456 struct trace_event *event;
2122 int S, T;
2123 1457
2124 entry = iter->ent; 1458 entry = iter->ent;
2125 1459
2126 if (entry->type == TRACE_CONT) 1460 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
2127 return TRACE_TYPE_HANDLED; 1461 if (!trace_seq_printf(s, "%d %d %llu ",
2128 1462 entry->pid, iter->cpu, iter->ts))
2129 ret = trace_seq_printf(s, "%d %d %llu ", 1463 goto partial;
2130 entry->pid, iter->cpu, iter->ts);
2131 if (!ret)
2132 return TRACE_TYPE_PARTIAL_LINE;
2133
2134 switch (entry->type) {
2135 case TRACE_FN: {
2136 struct ftrace_entry *field;
2137
2138 trace_assign_type(field, entry);
2139
2140 ret = trace_seq_printf(s, "%x %x\n",
2141 field->ip,
2142 field->parent_ip);
2143 if (!ret)
2144 return TRACE_TYPE_PARTIAL_LINE;
2145 break;
2146 } 1464 }
2147 case TRACE_CTX:
2148 case TRACE_WAKE: {
2149 struct ctx_switch_entry *field;
2150
2151 trace_assign_type(field, entry);
2152
2153 T = task_state_char(field->next_state);
2154 S = entry->type == TRACE_WAKE ? '+' :
2155 task_state_char(field->prev_state);
2156 ret = trace_seq_printf(s, "%d %d %c %d %d %d %c\n",
2157 field->prev_pid,
2158 field->prev_prio,
2159 S,
2160 field->next_cpu,
2161 field->next_pid,
2162 field->next_prio,
2163 T);
2164 if (!ret)
2165 return TRACE_TYPE_PARTIAL_LINE;
2166 break;
2167 }
2168 case TRACE_SPECIAL:
2169 case TRACE_USER_STACK:
2170 case TRACE_STACK: {
2171 struct special_entry *field;
2172
2173 trace_assign_type(field, entry);
2174
2175 ret = trace_seq_printf(s, "# %ld %ld %ld\n",
2176 field->arg1,
2177 field->arg2,
2178 field->arg3);
2179 if (!ret)
2180 return TRACE_TYPE_PARTIAL_LINE;
2181 break;
2182 }
2183 case TRACE_PRINT: {
2184 struct print_entry *field;
2185 1465
2186 trace_assign_type(field, entry); 1466 event = ftrace_find_event(entry->type);
1467 if (event)
1468 return event->raw(iter, 0);
1469
1470 if (!trace_seq_printf(s, "%d ?\n", entry->type))
1471 goto partial;
2187 1472
2188 trace_seq_printf(s, "# %lx %s", field->ip, field->buf);
2189 if (entry->flags & TRACE_FLAG_CONT)
2190 trace_seq_print_cont(s, iter);
2191 break;
2192 }
2193 }
2194 return TRACE_TYPE_HANDLED; 1473 return TRACE_TYPE_HANDLED;
1474partial:
1475 return TRACE_TYPE_PARTIAL_LINE;
2195} 1476}
2196 1477
2197#define SEQ_PUT_FIELD_RET(s, x) \
2198do { \
2199 if (!trace_seq_putmem(s, &(x), sizeof(x))) \
2200 return 0; \
2201} while (0)
2202
2203#define SEQ_PUT_HEX_FIELD_RET(s, x) \
2204do { \
2205 BUILD_BUG_ON(sizeof(x) > MAX_MEMHEX_BYTES); \
2206 if (!trace_seq_putmem_hex(s, &(x), sizeof(x))) \
2207 return 0; \
2208} while (0)
2209
2210static enum print_line_t print_hex_fmt(struct trace_iterator *iter) 1478static enum print_line_t print_hex_fmt(struct trace_iterator *iter)
2211{ 1479{
2212 struct trace_seq *s = &iter->seq; 1480 struct trace_seq *s = &iter->seq;
2213 unsigned char newline = '\n'; 1481 unsigned char newline = '\n';
2214 struct trace_entry *entry; 1482 struct trace_entry *entry;
2215 int S, T; 1483 struct trace_event *event;
2216 1484
2217 entry = iter->ent; 1485 entry = iter->ent;
2218 1486
2219 if (entry->type == TRACE_CONT) 1487 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
2220 return TRACE_TYPE_HANDLED; 1488 SEQ_PUT_HEX_FIELD_RET(s, entry->pid);
2221 1489 SEQ_PUT_HEX_FIELD_RET(s, iter->cpu);
2222 SEQ_PUT_HEX_FIELD_RET(s, entry->pid); 1490 SEQ_PUT_HEX_FIELD_RET(s, iter->ts);
2223 SEQ_PUT_HEX_FIELD_RET(s, iter->cpu);
2224 SEQ_PUT_HEX_FIELD_RET(s, iter->ts);
2225
2226 switch (entry->type) {
2227 case TRACE_FN: {
2228 struct ftrace_entry *field;
2229
2230 trace_assign_type(field, entry);
2231
2232 SEQ_PUT_HEX_FIELD_RET(s, field->ip);
2233 SEQ_PUT_HEX_FIELD_RET(s, field->parent_ip);
2234 break;
2235 } 1491 }
2236 case TRACE_CTX:
2237 case TRACE_WAKE: {
2238 struct ctx_switch_entry *field;
2239
2240 trace_assign_type(field, entry);
2241
2242 T = task_state_char(field->next_state);
2243 S = entry->type == TRACE_WAKE ? '+' :
2244 task_state_char(field->prev_state);
2245 SEQ_PUT_HEX_FIELD_RET(s, field->prev_pid);
2246 SEQ_PUT_HEX_FIELD_RET(s, field->prev_prio);
2247 SEQ_PUT_HEX_FIELD_RET(s, S);
2248 SEQ_PUT_HEX_FIELD_RET(s, field->next_cpu);
2249 SEQ_PUT_HEX_FIELD_RET(s, field->next_pid);
2250 SEQ_PUT_HEX_FIELD_RET(s, field->next_prio);
2251 SEQ_PUT_HEX_FIELD_RET(s, T);
2252 break;
2253 }
2254 case TRACE_SPECIAL:
2255 case TRACE_USER_STACK:
2256 case TRACE_STACK: {
2257 struct special_entry *field;
2258
2259 trace_assign_type(field, entry);
2260 1492
2261 SEQ_PUT_HEX_FIELD_RET(s, field->arg1); 1493 event = ftrace_find_event(entry->type);
2262 SEQ_PUT_HEX_FIELD_RET(s, field->arg2); 1494 if (event) {
2263 SEQ_PUT_HEX_FIELD_RET(s, field->arg3); 1495 enum print_line_t ret = event->hex(iter, 0);
2264 break; 1496 if (ret != TRACE_TYPE_HANDLED)
2265 } 1497 return ret;
2266 } 1498 }
1499
2267 SEQ_PUT_FIELD_RET(s, newline); 1500 SEQ_PUT_FIELD_RET(s, newline);
2268 1501
2269 return TRACE_TYPE_HANDLED; 1502 return TRACE_TYPE_HANDLED;
@@ -2278,13 +1511,10 @@ static enum print_line_t print_printk_msg_only(struct trace_iterator *iter)
2278 1511
2279 trace_assign_type(field, entry); 1512 trace_assign_type(field, entry);
2280 1513
2281 ret = trace_seq_printf(s, field->buf); 1514 ret = trace_seq_printf(s, "%s", field->buf);
2282 if (!ret) 1515 if (!ret)
2283 return TRACE_TYPE_PARTIAL_LINE; 1516 return TRACE_TYPE_PARTIAL_LINE;
2284 1517
2285 if (entry->flags & TRACE_FLAG_CONT)
2286 trace_seq_print_cont(s, iter);
2287
2288 return TRACE_TYPE_HANDLED; 1518 return TRACE_TYPE_HANDLED;
2289} 1519}
2290 1520
@@ -2292,53 +1522,18 @@ static enum print_line_t print_bin_fmt(struct trace_iterator *iter)
2292{ 1522{
2293 struct trace_seq *s = &iter->seq; 1523 struct trace_seq *s = &iter->seq;
2294 struct trace_entry *entry; 1524 struct trace_entry *entry;
1525 struct trace_event *event;
2295 1526
2296 entry = iter->ent; 1527 entry = iter->ent;
2297 1528
2298 if (entry->type == TRACE_CONT) 1529 if (trace_flags & TRACE_ITER_CONTEXT_INFO) {
2299 return TRACE_TYPE_HANDLED; 1530 SEQ_PUT_FIELD_RET(s, entry->pid);
2300 1531 SEQ_PUT_FIELD_RET(s, iter->cpu);
2301 SEQ_PUT_FIELD_RET(s, entry->pid); 1532 SEQ_PUT_FIELD_RET(s, iter->ts);
2302 SEQ_PUT_FIELD_RET(s, entry->cpu);
2303 SEQ_PUT_FIELD_RET(s, iter->ts);
2304
2305 switch (entry->type) {
2306 case TRACE_FN: {
2307 struct ftrace_entry *field;
2308
2309 trace_assign_type(field, entry);
2310
2311 SEQ_PUT_FIELD_RET(s, field->ip);
2312 SEQ_PUT_FIELD_RET(s, field->parent_ip);
2313 break;
2314 } 1533 }
2315 case TRACE_CTX: {
2316 struct ctx_switch_entry *field;
2317
2318 trace_assign_type(field, entry);
2319 1534
2320 SEQ_PUT_FIELD_RET(s, field->prev_pid); 1535 event = ftrace_find_event(entry->type);
2321 SEQ_PUT_FIELD_RET(s, field->prev_prio); 1536 return event ? event->binary(iter, 0) : TRACE_TYPE_HANDLED;
2322 SEQ_PUT_FIELD_RET(s, field->prev_state);
2323 SEQ_PUT_FIELD_RET(s, field->next_pid);
2324 SEQ_PUT_FIELD_RET(s, field->next_prio);
2325 SEQ_PUT_FIELD_RET(s, field->next_state);
2326 break;
2327 }
2328 case TRACE_SPECIAL:
2329 case TRACE_USER_STACK:
2330 case TRACE_STACK: {
2331 struct special_entry *field;
2332
2333 trace_assign_type(field, entry);
2334
2335 SEQ_PUT_FIELD_RET(s, field->arg1);
2336 SEQ_PUT_FIELD_RET(s, field->arg2);
2337 SEQ_PUT_FIELD_RET(s, field->arg3);
2338 break;
2339 }
2340 }
2341 return 1;
2342} 1537}
2343 1538
2344static int trace_empty(struct trace_iterator *iter) 1539static int trace_empty(struct trace_iterator *iter)
@@ -2383,7 +1578,7 @@ static enum print_line_t print_trace_line(struct trace_iterator *iter)
2383 return print_raw_fmt(iter); 1578 return print_raw_fmt(iter);
2384 1579
2385 if (iter->iter_flags & TRACE_FILE_LAT_FMT) 1580 if (iter->iter_flags & TRACE_FILE_LAT_FMT)
2386 return print_lat_fmt(iter, iter->idx, iter->cpu); 1581 return print_lat_fmt(iter);
2387 1582
2388 return print_trace_fmt(iter); 1583 return print_trace_fmt(iter);
2389} 1584}
@@ -2985,7 +2180,13 @@ tracing_set_trace_read(struct file *filp, char __user *ubuf,
2985 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r); 2180 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
2986} 2181}
2987 2182
2988static int tracing_set_tracer(char *buf) 2183int tracer_init(struct tracer *t, struct trace_array *tr)
2184{
2185 tracing_reset_online_cpus(tr);
2186 return t->init(tr);
2187}
2188
2189static int tracing_set_tracer(const char *buf)
2989{ 2190{
2990 struct trace_array *tr = &global_trace; 2191 struct trace_array *tr = &global_trace;
2991 struct tracer *t; 2192 struct tracer *t;
@@ -3009,7 +2210,7 @@ static int tracing_set_tracer(char *buf)
3009 2210
3010 current_trace = t; 2211 current_trace = t;
3011 if (t->init) { 2212 if (t->init) {
3012 ret = t->init(tr); 2213 ret = tracer_init(t, tr);
3013 if (ret) 2214 if (ret)
3014 goto out; 2215 goto out;
3015 } 2216 }
@@ -3267,8 +2468,8 @@ waitagain:
3267 iter->seq.len = len; 2468 iter->seq.len = len;
3268 break; 2469 break;
3269 } 2470 }
3270 2471 if (ret != TRACE_TYPE_NO_CONSUME)
3271 trace_consume(iter); 2472 trace_consume(iter);
3272 2473
3273 if (iter->seq.len >= cnt) 2474 if (iter->seq.len >= cnt)
3274 break; 2475 break;
@@ -3653,18 +2854,16 @@ int trace_vprintk(unsigned long ip, int depth, const char *fmt, va_list args)
3653 trace_buf[len] = 0; 2854 trace_buf[len] = 0;
3654 2855
3655 size = sizeof(*entry) + len + 1; 2856 size = sizeof(*entry) + len + 1;
3656 event = ring_buffer_lock_reserve(tr->buffer, size, &irq_flags); 2857 event = trace_buffer_lock_reserve(tr, TRACE_PRINT, size, irq_flags, pc);
3657 if (!event) 2858 if (!event)
3658 goto out_unlock; 2859 goto out_unlock;
3659 entry = ring_buffer_event_data(event); 2860 entry = ring_buffer_event_data(event);
3660 tracing_generic_entry_update(&entry->ent, irq_flags, pc);
3661 entry->ent.type = TRACE_PRINT;
3662 entry->ip = ip; 2861 entry->ip = ip;
3663 entry->depth = depth; 2862 entry->depth = depth;
3664 2863
3665 memcpy(&entry->buf, trace_buf, len); 2864 memcpy(&entry->buf, trace_buf, len);
3666 entry->buf[len] = 0; 2865 entry->buf[len] = 0;
3667 ring_buffer_unlock_commit(tr->buffer, event, irq_flags); 2866 ring_buffer_unlock_commit(tr->buffer, event);
3668 2867
3669 out_unlock: 2868 out_unlock:
3670 spin_unlock_irqrestore(&trace_buf_lock, irq_flags); 2869 spin_unlock_irqrestore(&trace_buf_lock, irq_flags);
@@ -3691,6 +2890,15 @@ int __ftrace_printk(unsigned long ip, const char *fmt, ...)
3691} 2890}
3692EXPORT_SYMBOL_GPL(__ftrace_printk); 2891EXPORT_SYMBOL_GPL(__ftrace_printk);
3693 2892
2893int __ftrace_vprintk(unsigned long ip, const char *fmt, va_list ap)
2894{
2895 if (!(trace_flags & TRACE_ITER_PRINTK))
2896 return 0;
2897
2898 return trace_vprintk(ip, task_curr_ret_stack(current), fmt, ap);
2899}
2900EXPORT_SYMBOL_GPL(__ftrace_vprintk);
2901
3694static int trace_panic_handler(struct notifier_block *this, 2902static int trace_panic_handler(struct notifier_block *this,
3695 unsigned long event, void *unused) 2903 unsigned long event, void *unused)
3696{ 2904{
@@ -3871,14 +3079,10 @@ __init static int tracer_alloc_buffers(void)
3871 trace_init_cmdlines(); 3079 trace_init_cmdlines();
3872 3080
3873 register_tracer(&nop_trace); 3081 register_tracer(&nop_trace);
3082 current_trace = &nop_trace;
3874#ifdef CONFIG_BOOT_TRACER 3083#ifdef CONFIG_BOOT_TRACER
3875 register_tracer(&boot_tracer); 3084 register_tracer(&boot_tracer);
3876 current_trace = &boot_tracer;
3877 current_trace->init(&global_trace);
3878#else
3879 current_trace = &nop_trace;
3880#endif 3085#endif
3881
3882 /* All seems OK, enable tracing */ 3086 /* All seems OK, enable tracing */
3883 tracing_disabled = 0; 3087 tracing_disabled = 0;
3884 3088
@@ -3895,5 +3099,26 @@ out_free_buffer_mask:
3895out: 3099out:
3896 return ret; 3100 return ret;
3897} 3101}
3102
3103__init static int clear_boot_tracer(void)
3104{
3105 /*
3106 * The default tracer at boot buffer is an init section.
3107 * This function is called in lateinit. If we did not
3108 * find the boot tracer, then clear it out, to prevent
3109 * later registration from accessing the buffer that is
3110 * about to be freed.
3111 */
3112 if (!default_bootup_tracer)
3113 return 0;
3114
3115 printk(KERN_INFO "ftrace bootup tracer '%s' not registered.\n",
3116 default_bootup_tracer);
3117 default_bootup_tracer = NULL;
3118
3119 return 0;
3120}
3121
3898early_initcall(tracer_alloc_buffers); 3122early_initcall(tracer_alloc_buffers);
3899fs_initcall(tracer_init_debugfs); 3123fs_initcall(tracer_init_debugfs);
3124late_initcall(clear_boot_tracer);