aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.h
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2009-09-23 17:08:43 -0400
committerFrederic Weisbecker <fweisbec@gmail.com>2009-09-23 17:08:43 -0400
commitd7a4b414eed51f1653bb05ebe84122bf9a7ae18b (patch)
treebd6603a0c27de4c138a1767871897e9cd3e1a1d2 /kernel/trace/trace.h
parent1f0ab40976460bc4673fa204ce917a725185d8f2 (diff)
parenta724eada8c2a7b62463b73ccf73fd0bb6e928aeb (diff)
Merge commit 'linus/master' into tracing/kprobes
Conflicts: kernel/trace/Makefile kernel/trace/trace.h kernel/trace/trace_event_types.h kernel/trace/trace_export.c Merge reason: Sync with latest significant tracing core changes.
Diffstat (limited to 'kernel/trace/trace.h')
-rw-r--r--kernel/trace/trace.h280
1 files changed, 77 insertions, 203 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 821064914c80..104c1a72418f 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>
@@ -36,163 +36,59 @@ enum trace_type {
36 TRACE_HW_BRANCHES, 36 TRACE_HW_BRANCHES,
37 TRACE_KMEM_ALLOC, 37 TRACE_KMEM_ALLOC,
38 TRACE_KMEM_FREE, 38 TRACE_KMEM_FREE,
39 TRACE_POWER,
40 TRACE_BLK, 39 TRACE_BLK,
41 40
42 __TRACE_LAST_TYPE, 41 __TRACE_LAST_TYPE,
43}; 42};
44 43
45/* 44enum kmemtrace_type_id {
46 * Function trace entry - function address and parent function addres: 45 KMEMTRACE_TYPE_KMALLOC = 0, /* kmalloc() or kfree(). */
47 */ 46 KMEMTRACE_TYPE_CACHE, /* kmem_cache_*(). */
48struct ftrace_entry { 47 KMEMTRACE_TYPE_PAGES, /* __get_free_pages() and friends. */
49 struct trace_entry ent;
50 unsigned long ip;
51 unsigned long parent_ip;
52};
53
54/* Function call entry */
55struct ftrace_graph_ent_entry {
56 struct trace_entry ent;
57 struct ftrace_graph_ent graph_ent;
58}; 48};
59 49
60/* Function return entry */
61struct ftrace_graph_ret_entry {
62 struct trace_entry ent;
63 struct ftrace_graph_ret ret;
64};
65extern struct tracer boot_tracer; 50extern struct tracer boot_tracer;
66 51
67/* 52#undef __field
68 * Context switch trace entry - which task (and prio) we switched from/to: 53#define __field(type, item) type item;
69 */
70struct ctx_switch_entry {
71 struct trace_entry ent;
72 unsigned int prev_pid;
73 unsigned char prev_prio;
74 unsigned char prev_state;
75 unsigned int next_pid;
76 unsigned char next_prio;
77 unsigned char next_state;
78 unsigned int next_cpu;
79};
80
81/*
82 * Special (free-form) trace entry:
83 */
84struct special_entry {
85 struct trace_entry ent;
86 unsigned long arg1;
87 unsigned long arg2;
88 unsigned long arg3;
89};
90
91/*
92 * Stack-trace entry:
93 */
94
95#define FTRACE_STACK_ENTRIES 8
96 54
97struct stack_entry { 55#undef __field_struct
98 struct trace_entry ent; 56#define __field_struct(type, item) __field(type, item)
99 unsigned long caller[FTRACE_STACK_ENTRIES];
100};
101 57
102struct userstack_entry { 58#undef __field_desc
103 struct trace_entry ent; 59#define __field_desc(type, container, item)
104 unsigned long caller[FTRACE_STACK_ENTRIES];
105};
106 60
107/* 61#undef __array
108 * trace_printk entry: 62#define __array(type, item, size) type item[size];
109 */
110struct bprint_entry {
111 struct trace_entry ent;
112 unsigned long ip;
113 const char *fmt;
114 u32 buf[];
115};
116 63
117struct print_entry { 64#undef __array_desc
118 struct trace_entry ent; 65#define __array_desc(type, container, item, size)
119 unsigned long ip;
120 char buf[];
121};
122
123#define TRACE_OLD_SIZE 88
124
125struct trace_field_cont {
126 unsigned char type;
127 /* Temporary till we get rid of this completely */
128 char buf[TRACE_OLD_SIZE - 1];
129};
130 66
131struct trace_mmiotrace_rw { 67#undef __dynamic_array
132 struct trace_entry ent; 68#define __dynamic_array(type, item) type item[];
133 struct mmiotrace_rw rw;
134};
135 69
136struct trace_mmiotrace_map { 70#undef F_STRUCT
137 struct trace_entry ent; 71#define F_STRUCT(args...) args
138 struct mmiotrace_map map;
139};
140
141struct trace_boot_call {
142 struct trace_entry ent;
143 struct boot_trace_call boot_call;
144};
145 72
146struct trace_boot_ret { 73#undef FTRACE_ENTRY
147 struct trace_entry ent; 74#define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
148 struct boot_trace_ret boot_ret; 75 struct struct_name { \
149}; 76 struct trace_entry ent; \
77 tstruct \
78 }
150 79
151#define TRACE_FUNC_SIZE 30 80#undef TP_ARGS
152#define TRACE_FILE_SIZE 20 81#define TP_ARGS(args...) args
153struct trace_branch {
154 struct trace_entry ent;
155 unsigned line;
156 char func[TRACE_FUNC_SIZE+1];
157 char file[TRACE_FILE_SIZE+1];
158 char correct;
159};
160 82
161struct hw_branch_entry { 83#undef FTRACE_ENTRY_DUP
162 struct trace_entry ent; 84#define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk)
163 u64 from;
164 u64 to;
165};
166 85
167struct trace_power { 86#include "trace_entries.h"
168 struct trace_entry ent;
169 struct power_trace state_data;
170};
171
172enum kmemtrace_type_id {
173 KMEMTRACE_TYPE_KMALLOC = 0, /* kmalloc() or kfree(). */
174 KMEMTRACE_TYPE_CACHE, /* kmem_cache_*(). */
175 KMEMTRACE_TYPE_PAGES, /* __get_free_pages() and friends. */
176};
177
178struct kmemtrace_alloc_entry {
179 struct trace_entry ent;
180 enum kmemtrace_type_id type_id;
181 unsigned long call_site;
182 const void *ptr;
183 size_t bytes_req;
184 size_t bytes_alloc;
185 gfp_t gfp_flags;
186 int node;
187};
188
189struct kmemtrace_free_entry {
190 struct trace_entry ent;
191 enum kmemtrace_type_id type_id;
192 unsigned long call_site;
193 const void *ptr;
194};
195 87
88/*
89 * syscalls are special, and need special handling, this is why
90 * they are not included in trace_entries.h
91 */
196struct syscall_trace_enter { 92struct syscall_trace_enter {
197 struct trace_entry ent; 93 struct trace_entry ent;
198 int nr; 94 int nr;
@@ -228,14 +124,12 @@ struct kretprobe_trace_entry {
228 (offsetof(struct kretprobe_trace_entry, args) + \ 124 (offsetof(struct kretprobe_trace_entry, args) + \
229 (sizeof(unsigned long) * (n))) 125 (sizeof(unsigned long) * (n)))
230 126
231
232
233/* 127/*
234 * trace_flag_type is an enumeration that holds different 128 * trace_flag_type is an enumeration that holds different
235 * states when a trace occurs. These are: 129 * states when a trace occurs. These are:
236 * IRQS_OFF - interrupts were disabled 130 * IRQS_OFF - interrupts were disabled
237 * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags 131 * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags
238 * NEED_RESCED - reschedule is requested 132 * NEED_RESCHED - reschedule is requested
239 * HARDIRQ - inside an interrupt handler 133 * HARDIRQ - inside an interrupt handler
240 * SOFTIRQ - inside a softirq handler 134 * SOFTIRQ - inside a softirq handler
241 */ 135 */
@@ -334,7 +228,6 @@ extern void __ftrace_bad_type(void);
334 IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \ 228 IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \
335 TRACE_GRAPH_RET); \ 229 TRACE_GRAPH_RET); \
336 IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\ 230 IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\
337 IF_ASSIGN(var, ent, struct trace_power, TRACE_POWER); \
338 IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry, \ 231 IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry, \
339 TRACE_KMEM_ALLOC); \ 232 TRACE_KMEM_ALLOC); \
340 IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \ 233 IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \
@@ -414,7 +307,6 @@ struct tracer {
414 struct tracer *next; 307 struct tracer *next;
415 int print_max; 308 int print_max;
416 struct tracer_flags *flags; 309 struct tracer_flags *flags;
417 struct tracer_stat *stats;
418}; 310};
419 311
420 312
@@ -493,6 +385,7 @@ void tracing_stop_sched_switch_record(void);
493void tracing_start_sched_switch_record(void); 385void tracing_start_sched_switch_record(void);
494int register_tracer(struct tracer *type); 386int register_tracer(struct tracer *type);
495void unregister_tracer(struct tracer *type); 387void unregister_tracer(struct tracer *type);
388int is_tracing_stopped(void);
496 389
497extern unsigned long nsecs_to_usecs(unsigned long nsecs); 390extern unsigned long nsecs_to_usecs(unsigned long nsecs);
498 391
@@ -533,20 +426,6 @@ static inline void __trace_stack(struct trace_array *tr, unsigned long flags,
533 426
534extern cycle_t ftrace_now(int cpu); 427extern cycle_t ftrace_now(int cpu);
535 428
536#ifdef CONFIG_CONTEXT_SWITCH_TRACER
537typedef void
538(*tracer_switch_func_t)(void *private,
539 void *__rq,
540 struct task_struct *prev,
541 struct task_struct *next);
542
543struct tracer_switch_ops {
544 tracer_switch_func_t func;
545 void *private;
546 struct tracer_switch_ops *next;
547};
548#endif /* CONFIG_CONTEXT_SWITCH_TRACER */
549
550extern void trace_find_cmdline(int pid, char comm[]); 429extern void trace_find_cmdline(int pid, char comm[]);
551 430
552#ifdef CONFIG_DYNAMIC_FTRACE 431#ifdef CONFIG_DYNAMIC_FTRACE
@@ -662,6 +541,41 @@ static inline int ftrace_trace_task(struct task_struct *task)
662#endif 541#endif
663 542
664/* 543/*
544 * struct trace_parser - servers for reading the user input separated by spaces
545 * @cont: set if the input is not complete - no final space char was found
546 * @buffer: holds the parsed user input
547 * @idx: user input lenght
548 * @size: buffer size
549 */
550struct trace_parser {
551 bool cont;
552 char *buffer;
553 unsigned idx;
554 unsigned size;
555};
556
557static inline bool trace_parser_loaded(struct trace_parser *parser)
558{
559 return (parser->idx != 0);
560}
561
562static inline bool trace_parser_cont(struct trace_parser *parser)
563{
564 return parser->cont;
565}
566
567static inline void trace_parser_clear(struct trace_parser *parser)
568{
569 parser->cont = false;
570 parser->idx = 0;
571}
572
573extern int trace_parser_get_init(struct trace_parser *parser, int size);
574extern void trace_parser_put(struct trace_parser *parser);
575extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
576 size_t cnt, loff_t *ppos);
577
578/*
665 * trace_iterator_flags is an enumeration that defines bit 579 * trace_iterator_flags is an enumeration that defines bit
666 * positions into trace_flags that controls the output. 580 * positions into trace_flags that controls the output.
667 * 581 *
@@ -847,58 +761,18 @@ filter_check_discard(struct ftrace_event_call *call, void *rec,
847 return 0; 761 return 0;
848} 762}
849 763
850#define DEFINE_COMPARISON_PRED(type) \
851static int filter_pred_##type(struct filter_pred *pred, void *event, \
852 int val1, int val2) \
853{ \
854 type *addr = (type *)(event + pred->offset); \
855 type val = (type)pred->val; \
856 int match = 0; \
857 \
858 switch (pred->op) { \
859 case OP_LT: \
860 match = (*addr < val); \
861 break; \
862 case OP_LE: \
863 match = (*addr <= val); \
864 break; \
865 case OP_GT: \
866 match = (*addr > val); \
867 break; \
868 case OP_GE: \
869 match = (*addr >= val); \
870 break; \
871 default: \
872 break; \
873 } \
874 \
875 return match; \
876}
877
878#define DEFINE_EQUALITY_PRED(size) \
879static int filter_pred_##size(struct filter_pred *pred, void *event, \
880 int val1, int val2) \
881{ \
882 u##size *addr = (u##size *)(event + pred->offset); \
883 u##size val = (u##size)pred->val; \
884 int match; \
885 \
886 match = (val == *addr) ^ pred->not; \
887 \
888 return match; \
889}
890
891extern struct mutex event_mutex; 764extern struct mutex event_mutex;
892extern struct list_head ftrace_events; 765extern struct list_head ftrace_events;
893 766
894extern const char *__start___trace_bprintk_fmt[]; 767extern const char *__start___trace_bprintk_fmt[];
895extern const char *__stop___trace_bprintk_fmt[]; 768extern const char *__stop___trace_bprintk_fmt[];
896 769
897#undef TRACE_EVENT_FORMAT 770#undef FTRACE_ENTRY
898#define TRACE_EVENT_FORMAT(call, proto, args, fmt, tstruct, tpfmt) \ 771#define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \
899 extern struct ftrace_event_call event_##call; 772 extern struct ftrace_event_call event_##call;
900#undef TRACE_EVENT_FORMAT_NOFILTER 773#undef FTRACE_ENTRY_DUP
901#define TRACE_EVENT_FORMAT_NOFILTER(call, proto, args, fmt, tstruct, tpfmt) 774#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \
902#include "trace_event_types.h" 775 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))
776#include "trace_entries.h"
903 777
904#endif /* _LINUX_KERNEL_TRACE_H */ 778#endif /* _LINUX_KERNEL_TRACE_H */