aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r--kernel/trace/trace.h355
1 files changed, 131 insertions, 224 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 8b9f4f6e9559..405cb850b75d 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -7,10 +7,10 @@
7#include <linux/clocksource.h> 7#include <linux/clocksource.h>
8#include <linux/ring_buffer.h> 8#include <linux/ring_buffer.h>
9#include <linux/mmiotrace.h> 9#include <linux/mmiotrace.h>
10#include <linux/tracepoint.h>
10#include <linux/ftrace.h> 11#include <linux/ftrace.h>
11#include <trace/boot.h> 12#include <trace/boot.h>
12#include <linux/kmemtrace.h> 13#include <linux/kmemtrace.h>
13#include <trace/power.h>
14 14
15#include <linux/trace_seq.h> 15#include <linux/trace_seq.h>
16#include <linux/ftrace_event.h> 16#include <linux/ftrace_event.h>
@@ -34,167 +34,61 @@ enum trace_type {
34 TRACE_GRAPH_ENT, 34 TRACE_GRAPH_ENT,
35 TRACE_USER_STACK, 35 TRACE_USER_STACK,
36 TRACE_HW_BRANCHES, 36 TRACE_HW_BRANCHES,
37 TRACE_SYSCALL_ENTER,
38 TRACE_SYSCALL_EXIT,
39 TRACE_KMEM_ALLOC, 37 TRACE_KMEM_ALLOC,
40 TRACE_KMEM_FREE, 38 TRACE_KMEM_FREE,
41 TRACE_POWER,
42 TRACE_BLK, 39 TRACE_BLK,
43 40
44 __TRACE_LAST_TYPE, 41 __TRACE_LAST_TYPE,
45}; 42};
46 43
47/* 44enum kmemtrace_type_id {
48 * Function trace entry - function address and parent function addres: 45 KMEMTRACE_TYPE_KMALLOC = 0, /* kmalloc() or kfree(). */
49 */ 46 KMEMTRACE_TYPE_CACHE, /* kmem_cache_*(). */
50struct ftrace_entry { 47 KMEMTRACE_TYPE_PAGES, /* __get_free_pages() and friends. */
51 struct trace_entry ent;
52 unsigned long ip;
53 unsigned long parent_ip;
54};
55
56/* Function call entry */
57struct ftrace_graph_ent_entry {
58 struct trace_entry ent;
59 struct ftrace_graph_ent graph_ent;
60}; 48};
61 49
62/* Function return entry */
63struct ftrace_graph_ret_entry {
64 struct trace_entry ent;
65 struct ftrace_graph_ret ret;
66};
67extern struct tracer boot_tracer; 50extern struct tracer boot_tracer;
68 51
69/* 52#undef __field
70 * Context switch trace entry - which task (and prio) we switched from/to: 53#define __field(type, item) type item;
71 */
72struct ctx_switch_entry {
73 struct trace_entry ent;
74 unsigned int prev_pid;
75 unsigned char prev_prio;
76 unsigned char prev_state;
77 unsigned int next_pid;
78 unsigned char next_prio;
79 unsigned char next_state;
80 unsigned int next_cpu;
81};
82 54
83/* 55#undef __field_struct
84 * Special (free-form) trace entry: 56#define __field_struct(type, item) __field(type, item)
85 */
86struct special_entry {
87 struct trace_entry ent;
88 unsigned long arg1;
89 unsigned long arg2;
90 unsigned long arg3;
91};
92 57
93/* 58#undef __field_desc
94 * Stack-trace entry: 59#define __field_desc(type, container, item)
95 */
96 60
97#define FTRACE_STACK_ENTRIES 8 61#undef __array
62#define __array(type, item, size) type item[size];
98 63
99struct stack_entry { 64#undef __array_desc
100 struct trace_entry ent; 65#define __array_desc(type, container, item, size)
101 unsigned long caller[FTRACE_STACK_ENTRIES];
102};
103 66
104struct userstack_entry { 67#undef __dynamic_array
105 struct trace_entry ent; 68#define __dynamic_array(type, item) type item[];
106 unsigned long caller[FTRACE_STACK_ENTRIES];
107};
108 69
109/* 70#undef F_STRUCT
110 * trace_printk entry: 71#define F_STRUCT(args...) args
111 */
112struct bprint_entry {
113 struct trace_entry ent;
114 unsigned long ip;
115 const char *fmt;
116 u32 buf[];
117};
118 72
119struct print_entry { 73#undef FTRACE_ENTRY
120 struct trace_entry ent; 74#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
121 unsigned long ip; 75 struct struct_name { \
122 char buf[]; 76 struct trace_entry ent; \
123}; 77 tstruct \
124 78 }
125#define TRACE_OLD_SIZE 88
126
127struct trace_field_cont {
128 unsigned char type;
129 /* Temporary till we get rid of this completely */
130 char buf[TRACE_OLD_SIZE - 1];
131};
132
133struct trace_mmiotrace_rw {
134 struct trace_entry ent;
135 struct mmiotrace_rw rw;
136};
137
138struct trace_mmiotrace_map {
139 struct trace_entry ent;
140 struct mmiotrace_map map;
141};
142
143struct trace_boot_call {
144 struct trace_entry ent;
145 struct boot_trace_call boot_call;
146};
147
148struct trace_boot_ret {
149 struct trace_entry ent;
150 struct boot_trace_ret boot_ret;
151};
152
153#define TRACE_FUNC_SIZE 30
154#define TRACE_FILE_SIZE 20
155struct trace_branch {
156 struct trace_entry ent;
157 unsigned line;
158 char func[TRACE_FUNC_SIZE+1];
159 char file[TRACE_FILE_SIZE+1];
160 char correct;
161};
162
163struct hw_branch_entry {
164 struct trace_entry ent;
165 u64 from;
166 u64 to;
167};
168 79
169struct trace_power { 80#undef TP_ARGS
170 struct trace_entry ent; 81#define TP_ARGS(args...) args
171 struct power_trace state_data;
172};
173 82
174enum kmemtrace_type_id { 83#undef FTRACE_ENTRY_DUP
175 KMEMTRACE_TYPE_KMALLOC = 0, /* kmalloc() or kfree(). */ 84#define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk)
176 KMEMTRACE_TYPE_CACHE, /* kmem_cache_*(). */
177 KMEMTRACE_TYPE_PAGES, /* __get_free_pages() and friends. */
178};
179
180struct kmemtrace_alloc_entry {
181 struct trace_entry ent;
182 enum kmemtrace_type_id type_id;
183 unsigned long call_site;
184 const void *ptr;
185 size_t bytes_req;
186 size_t bytes_alloc;
187 gfp_t gfp_flags;
188 int node;
189};
190 85
191struct kmemtrace_free_entry { 86#include "trace_entries.h"
192 struct trace_entry ent;
193 enum kmemtrace_type_id type_id;
194 unsigned long call_site;
195 const void *ptr;
196};
197 87
88/*
89 * syscalls are special, and need special handling, this is why
90 * they are not included in trace_entries.h
91 */
198struct syscall_trace_enter { 92struct syscall_trace_enter {
199 struct trace_entry ent; 93 struct trace_entry ent;
200 int nr; 94 int nr;
@@ -207,13 +101,12 @@ struct syscall_trace_exit {
207 unsigned long ret; 101 unsigned long ret;
208}; 102};
209 103
210
211/* 104/*
212 * trace_flag_type is an enumeration that holds different 105 * trace_flag_type is an enumeration that holds different
213 * states when a trace occurs. These are: 106 * states when a trace occurs. These are:
214 * IRQS_OFF - interrupts were disabled 107 * IRQS_OFF - interrupts were disabled
215 * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags 108 * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags
216 * NEED_RESCED - reschedule is requested 109 * NEED_RESCHED - reschedule is requested
217 * HARDIRQ - inside an interrupt handler 110 * HARDIRQ - inside an interrupt handler
218 * SOFTIRQ - inside a softirq handler 111 * SOFTIRQ - inside a softirq handler
219 */ 112 */
@@ -236,9 +129,6 @@ struct trace_array_cpu {
236 atomic_t disabled; 129 atomic_t disabled;
237 void *buffer_page; /* ring buffer spare */ 130 void *buffer_page; /* ring buffer spare */
238 131
239 /* these fields get copied into max-trace: */
240 unsigned long trace_idx;
241 unsigned long overrun;
242 unsigned long saved_latency; 132 unsigned long saved_latency;
243 unsigned long critical_start; 133 unsigned long critical_start;
244 unsigned long critical_end; 134 unsigned long critical_end;
@@ -246,6 +136,7 @@ struct trace_array_cpu {
246 unsigned long nice; 136 unsigned long nice;
247 unsigned long policy; 137 unsigned long policy;
248 unsigned long rt_priority; 138 unsigned long rt_priority;
139 unsigned long skipped_entries;
249 cycle_t preempt_timestamp; 140 cycle_t preempt_timestamp;
250 pid_t pid; 141 pid_t pid;
251 uid_t uid; 142 uid_t uid;
@@ -314,15 +205,10 @@ extern void __ftrace_bad_type(void);
314 IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \ 205 IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \
315 TRACE_GRAPH_RET); \ 206 TRACE_GRAPH_RET); \
316 IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\ 207 IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\
317 IF_ASSIGN(var, ent, struct trace_power, TRACE_POWER); \
318 IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry, \ 208 IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry, \
319 TRACE_KMEM_ALLOC); \ 209 TRACE_KMEM_ALLOC); \
320 IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \ 210 IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \
321 TRACE_KMEM_FREE); \ 211 TRACE_KMEM_FREE); \
322 IF_ASSIGN(var, ent, struct syscall_trace_enter, \
323 TRACE_SYSCALL_ENTER); \
324 IF_ASSIGN(var, ent, struct syscall_trace_exit, \
325 TRACE_SYSCALL_EXIT); \
326 __ftrace_bad_type(); \ 212 __ftrace_bad_type(); \
327 } while (0) 213 } while (0)
328 214
@@ -398,7 +284,6 @@ struct tracer {
398 struct tracer *next; 284 struct tracer *next;
399 int print_max; 285 int print_max;
400 struct tracer_flags *flags; 286 struct tracer_flags *flags;
401 struct tracer_stat *stats;
402}; 287};
403 288
404 289
@@ -423,12 +308,13 @@ void init_tracer_sysprof_debugfs(struct dentry *d_tracer);
423 308
424struct ring_buffer_event; 309struct ring_buffer_event;
425 310
426struct ring_buffer_event *trace_buffer_lock_reserve(struct trace_array *tr, 311struct ring_buffer_event *
427 int type, 312trace_buffer_lock_reserve(struct ring_buffer *buffer,
428 unsigned long len, 313 int type,
429 unsigned long flags, 314 unsigned long len,
430 int pc); 315 unsigned long flags,
431void trace_buffer_unlock_commit(struct trace_array *tr, 316 int pc);
317void trace_buffer_unlock_commit(struct ring_buffer *buffer,
432 struct ring_buffer_event *event, 318 struct ring_buffer_event *event,
433 unsigned long flags, int pc); 319 unsigned long flags, int pc);
434 320
@@ -467,6 +353,7 @@ void trace_function(struct trace_array *tr,
467 353
468void trace_graph_return(struct ftrace_graph_ret *trace); 354void trace_graph_return(struct ftrace_graph_ret *trace);
469int trace_graph_entry(struct ftrace_graph_ent *trace); 355int trace_graph_entry(struct ftrace_graph_ent *trace);
356void set_graph_array(struct trace_array *tr);
470 357
471void tracing_start_cmdline_record(void); 358void tracing_start_cmdline_record(void);
472void tracing_stop_cmdline_record(void); 359void tracing_stop_cmdline_record(void);
@@ -475,35 +362,46 @@ void tracing_stop_sched_switch_record(void);
475void tracing_start_sched_switch_record(void); 362void tracing_start_sched_switch_record(void);
476int register_tracer(struct tracer *type); 363int register_tracer(struct tracer *type);
477void unregister_tracer(struct tracer *type); 364void unregister_tracer(struct tracer *type);
365int is_tracing_stopped(void);
478 366
479extern unsigned long nsecs_to_usecs(unsigned long nsecs); 367extern unsigned long nsecs_to_usecs(unsigned long nsecs);
480 368
369#ifdef CONFIG_TRACER_MAX_TRACE
481extern unsigned long tracing_max_latency; 370extern unsigned long tracing_max_latency;
482extern unsigned long tracing_thresh; 371extern unsigned long tracing_thresh;
483 372
484void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu); 373void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu);
485void update_max_tr_single(struct trace_array *tr, 374void update_max_tr_single(struct trace_array *tr,
486 struct task_struct *tsk, int cpu); 375 struct task_struct *tsk, int cpu);
376#endif /* CONFIG_TRACER_MAX_TRACE */
487 377
488void __trace_stack(struct trace_array *tr, 378#ifdef CONFIG_STACKTRACE
489 unsigned long flags, 379void ftrace_trace_stack(struct ring_buffer *buffer, unsigned long flags,
490 int skip, int pc); 380 int skip, int pc);
491 381
492extern cycle_t ftrace_now(int cpu); 382void ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags,
383 int pc);
493 384
494#ifdef CONFIG_CONTEXT_SWITCH_TRACER 385void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
495typedef void 386 int pc);
496(*tracer_switch_func_t)(void *private, 387#else
497 void *__rq, 388static inline void ftrace_trace_stack(struct trace_array *tr,
498 struct task_struct *prev, 389 unsigned long flags, int skip, int pc)
499 struct task_struct *next); 390{
500 391}
501struct tracer_switch_ops { 392
502 tracer_switch_func_t func; 393static inline void ftrace_trace_userstack(struct trace_array *tr,
503 void *private; 394 unsigned long flags, int pc)
504 struct tracer_switch_ops *next; 395{
505}; 396}
506#endif /* CONFIG_CONTEXT_SWITCH_TRACER */ 397
398static inline void __trace_stack(struct trace_array *tr, unsigned long flags,
399 int skip, int pc)
400{
401}
402#endif /* CONFIG_STACKTRACE */
403
404extern cycle_t ftrace_now(int cpu);
507 405
508extern void trace_find_cmdline(int pid, char comm[]); 406extern void trace_find_cmdline(int pid, char comm[]);
509 407
@@ -513,6 +411,10 @@ extern unsigned long ftrace_update_tot_cnt;
513extern int DYN_FTRACE_TEST_NAME(void); 411extern int DYN_FTRACE_TEST_NAME(void);
514#endif 412#endif
515 413
414extern int ring_buffer_expanded;
415extern bool tracing_selftest_disabled;
416DECLARE_PER_CPU(local_t, ftrace_cpu_disabled);
417
516#ifdef CONFIG_FTRACE_STARTUP_TEST 418#ifdef CONFIG_FTRACE_STARTUP_TEST
517extern int trace_selftest_startup_function(struct tracer *trace, 419extern int trace_selftest_startup_function(struct tracer *trace,
518 struct trace_array *tr); 420 struct trace_array *tr);
@@ -544,9 +446,16 @@ extern int
544trace_vbprintk(unsigned long ip, const char *fmt, va_list args); 446trace_vbprintk(unsigned long ip, const char *fmt, va_list args);
545extern int 447extern int
546trace_vprintk(unsigned long ip, const char *fmt, va_list args); 448trace_vprintk(unsigned long ip, const char *fmt, va_list args);
449extern int
450trace_array_vprintk(struct trace_array *tr,
451 unsigned long ip, const char *fmt, va_list args);
452int trace_array_printk(struct trace_array *tr,
453 unsigned long ip, const char *fmt, ...);
547 454
548extern unsigned long trace_flags; 455extern unsigned long trace_flags;
549 456
457extern int trace_clock_id;
458
550/* Standard output formatting function used for function return traces */ 459/* Standard output formatting function used for function return traces */
551#ifdef CONFIG_FUNCTION_GRAPH_TRACER 460#ifdef CONFIG_FUNCTION_GRAPH_TRACER
552extern enum print_line_t print_graph_function(struct trace_iterator *iter); 461extern enum print_line_t print_graph_function(struct trace_iterator *iter);
@@ -609,6 +518,41 @@ static inline int ftrace_trace_task(struct task_struct *task)
609#endif 518#endif
610 519
611/* 520/*
521 * struct trace_parser - servers for reading the user input separated by spaces
522 * @cont: set if the input is not complete - no final space char was found
523 * @buffer: holds the parsed user input
524 * @idx: user input lenght
525 * @size: buffer size
526 */
527struct trace_parser {
528 bool cont;
529 char *buffer;
530 unsigned idx;
531 unsigned size;
532};
533
534static inline bool trace_parser_loaded(struct trace_parser *parser)
535{
536 return (parser->idx != 0);
537}
538
539static inline bool trace_parser_cont(struct trace_parser *parser)
540{
541 return parser->cont;
542}
543
544static inline void trace_parser_clear(struct trace_parser *parser)
545{
546 parser->cont = false;
547 parser->idx = 0;
548}
549
550extern int trace_parser_get_init(struct trace_parser *parser, int size);
551extern void trace_parser_put(struct trace_parser *parser);
552extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
553 size_t cnt, loff_t *ppos);
554
555/*
612 * trace_iterator_flags is an enumeration that defines bit 556 * trace_iterator_flags is an enumeration that defines bit
613 * positions into trace_flags that controls the output. 557 * positions into trace_flags that controls the output.
614 * 558 *
@@ -635,9 +579,8 @@ enum trace_iterator_flags {
635 TRACE_ITER_PRINTK_MSGONLY = 0x10000, 579 TRACE_ITER_PRINTK_MSGONLY = 0x10000,
636 TRACE_ITER_CONTEXT_INFO = 0x20000, /* Print pid/cpu/time */ 580 TRACE_ITER_CONTEXT_INFO = 0x20000, /* Print pid/cpu/time */
637 TRACE_ITER_LATENCY_FMT = 0x40000, 581 TRACE_ITER_LATENCY_FMT = 0x40000,
638 TRACE_ITER_GLOBAL_CLK = 0x80000, 582 TRACE_ITER_SLEEP_TIME = 0x80000,
639 TRACE_ITER_SLEEP_TIME = 0x100000, 583 TRACE_ITER_GRAPH_TIME = 0x100000,
640 TRACE_ITER_GRAPH_TIME = 0x200000,
641}; 584};
642 585
643/* 586/*
@@ -734,6 +677,7 @@ struct ftrace_event_field {
734 struct list_head link; 677 struct list_head link;
735 char *name; 678 char *name;
736 char *type; 679 char *type;
680 int filter_type;
737 int offset; 681 int offset;
738 int size; 682 int size;
739 int is_signed; 683 int is_signed;
@@ -743,13 +687,15 @@ struct event_filter {
743 int n_preds; 687 int n_preds;
744 struct filter_pred **preds; 688 struct filter_pred **preds;
745 char *filter_string; 689 char *filter_string;
690 bool no_reset;
746}; 691};
747 692
748struct event_subsystem { 693struct event_subsystem {
749 struct list_head list; 694 struct list_head list;
750 const char *name; 695 const char *name;
751 struct dentry *entry; 696 struct dentry *entry;
752 void *filter; 697 struct event_filter *filter;
698 int nr_events;
753}; 699};
754 700
755struct filter_pred; 701struct filter_pred;
@@ -777,6 +723,7 @@ extern int apply_subsystem_event_filter(struct event_subsystem *system,
777 char *filter_string); 723 char *filter_string);
778extern void print_subsystem_event_filter(struct event_subsystem *system, 724extern void print_subsystem_event_filter(struct event_subsystem *system,
779 struct trace_seq *s); 725 struct trace_seq *s);
726extern int filter_assign_type(const char *type);
780 727
781static inline int 728static inline int
782filter_check_discard(struct ftrace_event_call *call, void *rec, 729filter_check_discard(struct ftrace_event_call *call, void *rec,
@@ -791,58 +738,18 @@ filter_check_discard(struct ftrace_event_call *call, void *rec,
791 return 0; 738 return 0;
792} 739}
793 740
794#define DEFINE_COMPARISON_PRED(type) \
795static int filter_pred_##type(struct filter_pred *pred, void *event, \
796 int val1, int val2) \
797{ \
798 type *addr = (type *)(event + pred->offset); \
799 type val = (type)pred->val; \
800 int match = 0; \
801 \
802 switch (pred->op) { \
803 case OP_LT: \
804 match = (*addr < val); \
805 break; \
806 case OP_LE: \
807 match = (*addr <= val); \
808 break; \
809 case OP_GT: \
810 match = (*addr > val); \
811 break; \
812 case OP_GE: \
813 match = (*addr >= val); \
814 break; \
815 default: \
816 break; \
817 } \
818 \
819 return match; \
820}
821
822#define DEFINE_EQUALITY_PRED(size) \
823static int filter_pred_##size(struct filter_pred *pred, void *event, \
824 int val1, int val2) \
825{ \
826 u##size *addr = (u##size *)(event + pred->offset); \
827 u##size val = (u##size)pred->val; \
828 int match; \
829 \
830 match = (val == *addr) ^ pred->not; \
831 \
832 return match; \
833}
834
835extern struct mutex event_mutex; 741extern struct mutex event_mutex;
836extern struct list_head ftrace_events; 742extern struct list_head ftrace_events;
837 743
838extern const char *__start___trace_bprintk_fmt[]; 744extern const char *__start___trace_bprintk_fmt[];
839extern const char *__stop___trace_bprintk_fmt[]; 745extern const char *__stop___trace_bprintk_fmt[];
840 746
841#undef TRACE_EVENT_FORMAT 747#undef FTRACE_ENTRY
842#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ 748#define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \
843 extern struct ftrace_event_call event_##call; 749 extern struct ftrace_event_call event_##call;
844#undef TRACE_EVENT_FORMAT_NOFILTER 750#undef FTRACE_ENTRY_DUP
845#define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, tpfmt) 751#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \
846#include "trace_event_types.h" 752 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))
753#include "trace_entries.h"
847 754
848#endif /* _LINUX_KERNEL_TRACE_H */ 755#endif /* _LINUX_KERNEL_TRACE_H */