at91: at91sam9g45 family: identify several chip versions
[linux-2.6/next.git] / kernel / trace / trace.h
blob405cb850b75d9a308d04d198946e9b0e8da21a39
1 #ifndef _LINUX_KERNEL_TRACE_H
2 #define _LINUX_KERNEL_TRACE_H
4 #include <linux/fs.h>
5 #include <asm/atomic.h>
6 #include <linux/sched.h>
7 #include <linux/clocksource.h>
8 #include <linux/ring_buffer.h>
9 #include <linux/mmiotrace.h>
10 #include <linux/tracepoint.h>
11 #include <linux/ftrace.h>
12 #include <trace/boot.h>
13 #include <linux/kmemtrace.h>
15 #include <linux/trace_seq.h>
16 #include <linux/ftrace_event.h>
18 enum trace_type {
19 __TRACE_FIRST_TYPE = 0,
21 TRACE_FN,
22 TRACE_CTX,
23 TRACE_WAKE,
24 TRACE_STACK,
25 TRACE_PRINT,
26 TRACE_BPRINT,
27 TRACE_SPECIAL,
28 TRACE_MMIO_RW,
29 TRACE_MMIO_MAP,
30 TRACE_BRANCH,
31 TRACE_BOOT_CALL,
32 TRACE_BOOT_RET,
33 TRACE_GRAPH_RET,
34 TRACE_GRAPH_ENT,
35 TRACE_USER_STACK,
36 TRACE_HW_BRANCHES,
37 TRACE_KMEM_ALLOC,
38 TRACE_KMEM_FREE,
39 TRACE_BLK,
41 __TRACE_LAST_TYPE,
44 enum kmemtrace_type_id {
45 KMEMTRACE_TYPE_KMALLOC = 0, /* kmalloc() or kfree(). */
46 KMEMTRACE_TYPE_CACHE, /* kmem_cache_*(). */
47 KMEMTRACE_TYPE_PAGES, /* __get_free_pages() and friends. */
50 extern struct tracer boot_tracer;
52 #undef __field
53 #define __field(type, item) type item;
55 #undef __field_struct
56 #define __field_struct(type, item) __field(type, item)
58 #undef __field_desc
59 #define __field_desc(type, container, item)
61 #undef __array
62 #define __array(type, item, size) type item[size];
64 #undef __array_desc
65 #define __array_desc(type, container, item, size)
67 #undef __dynamic_array
68 #define __dynamic_array(type, item) type item[];
70 #undef F_STRUCT
71 #define F_STRUCT(args...) args
73 #undef FTRACE_ENTRY
74 #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
75 struct struct_name { \
76 struct trace_entry ent; \
77 tstruct \
80 #undef TP_ARGS
81 #define TP_ARGS(args...) args
83 #undef FTRACE_ENTRY_DUP
84 #define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk)
86 #include "trace_entries.h"
89 * syscalls are special, and need special handling, this is why
90 * they are not included in trace_entries.h
92 struct syscall_trace_enter {
93 struct trace_entry ent;
94 int nr;
95 unsigned long args[];
98 struct syscall_trace_exit {
99 struct trace_entry ent;
100 int nr;
101 unsigned long ret;
105 * trace_flag_type is an enumeration that holds different
106 * states when a trace occurs. These are:
107 * IRQS_OFF - interrupts were disabled
108 * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags
109 * NEED_RESCHED - reschedule is requested
110 * HARDIRQ - inside an interrupt handler
111 * SOFTIRQ - inside a softirq handler
113 enum trace_flag_type {
114 TRACE_FLAG_IRQS_OFF = 0x01,
115 TRACE_FLAG_IRQS_NOSUPPORT = 0x02,
116 TRACE_FLAG_NEED_RESCHED = 0x04,
117 TRACE_FLAG_HARDIRQ = 0x08,
118 TRACE_FLAG_SOFTIRQ = 0x10,
121 #define TRACE_BUF_SIZE 1024
124 * The CPU trace array - it consists of thousands of trace entries
125 * plus some other descriptor data: (for example which task started
126 * the trace, etc.)
128 struct trace_array_cpu {
129 atomic_t disabled;
130 void *buffer_page; /* ring buffer spare */
132 unsigned long saved_latency;
133 unsigned long critical_start;
134 unsigned long critical_end;
135 unsigned long critical_sequence;
136 unsigned long nice;
137 unsigned long policy;
138 unsigned long rt_priority;
139 unsigned long skipped_entries;
140 cycle_t preempt_timestamp;
141 pid_t pid;
142 uid_t uid;
143 char comm[TASK_COMM_LEN];
147 * The trace array - an array of per-CPU trace arrays. This is the
148 * highest level data structure that individual tracers deal with.
149 * They have on/off state as well:
151 struct trace_array {
152 struct ring_buffer *buffer;
153 unsigned long entries;
154 int cpu;
155 cycle_t time_start;
156 struct task_struct *waiter;
157 struct trace_array_cpu *data[NR_CPUS];
160 #define FTRACE_CMP_TYPE(var, type) \
161 __builtin_types_compatible_p(typeof(var), type *)
163 #undef IF_ASSIGN
164 #define IF_ASSIGN(var, entry, etype, id) \
165 if (FTRACE_CMP_TYPE(var, etype)) { \
166 var = (typeof(var))(entry); \
167 WARN_ON(id && (entry)->type != id); \
168 break; \
171 /* Will cause compile errors if type is not found. */
172 extern void __ftrace_bad_type(void);
175 * The trace_assign_type is a verifier that the entry type is
176 * the same as the type being assigned. To add new types simply
177 * add a line with the following format:
179 * IF_ASSIGN(var, ent, type, id);
181 * Where "type" is the trace type that includes the trace_entry
182 * as the "ent" item. And "id" is the trace identifier that is
183 * used in the trace_type enum.
185 * If the type can have more than one id, then use zero.
187 #define trace_assign_type(var, ent) \
188 do { \
189 IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN); \
190 IF_ASSIGN(var, ent, struct ctx_switch_entry, 0); \
191 IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \
192 IF_ASSIGN(var, ent, struct userstack_entry, TRACE_USER_STACK);\
193 IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \
194 IF_ASSIGN(var, ent, struct bprint_entry, TRACE_BPRINT); \
195 IF_ASSIGN(var, ent, struct special_entry, 0); \
196 IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \
197 TRACE_MMIO_RW); \
198 IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \
199 TRACE_MMIO_MAP); \
200 IF_ASSIGN(var, ent, struct trace_boot_call, TRACE_BOOT_CALL);\
201 IF_ASSIGN(var, ent, struct trace_boot_ret, TRACE_BOOT_RET);\
202 IF_ASSIGN(var, ent, struct trace_branch, TRACE_BRANCH); \
203 IF_ASSIGN(var, ent, struct ftrace_graph_ent_entry, \
204 TRACE_GRAPH_ENT); \
205 IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \
206 TRACE_GRAPH_RET); \
207 IF_ASSIGN(var, ent, struct hw_branch_entry, TRACE_HW_BRANCHES);\
208 IF_ASSIGN(var, ent, struct kmemtrace_alloc_entry, \
209 TRACE_KMEM_ALLOC); \
210 IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \
211 TRACE_KMEM_FREE); \
212 __ftrace_bad_type(); \
213 } while (0)
216 * An option specific to a tracer. This is a boolean value.
217 * The bit is the bit index that sets its value on the
218 * flags value in struct tracer_flags.
220 struct tracer_opt {
221 const char *name; /* Will appear on the trace_options file */
222 u32 bit; /* Mask assigned in val field in tracer_flags */
226 * The set of specific options for a tracer. Your tracer
227 * have to set the initial value of the flags val.
229 struct tracer_flags {
230 u32 val;
231 struct tracer_opt *opts;
234 /* Makes more easy to define a tracer opt */
235 #define TRACER_OPT(s, b) .name = #s, .bit = b
239 * struct tracer - a specific tracer and its callbacks to interact with debugfs
240 * @name: the name chosen to select it on the available_tracers file
241 * @init: called when one switches to this tracer (echo name > current_tracer)
242 * @reset: called when one switches to another tracer
243 * @start: called when tracing is unpaused (echo 1 > tracing_enabled)
244 * @stop: called when tracing is paused (echo 0 > tracing_enabled)
245 * @open: called when the trace file is opened
246 * @pipe_open: called when the trace_pipe file is opened
247 * @wait_pipe: override how the user waits for traces on trace_pipe
248 * @close: called when the trace file is released
249 * @read: override the default read callback on trace_pipe
250 * @splice_read: override the default splice_read callback on trace_pipe
251 * @selftest: selftest to run on boot (see trace_selftest.c)
252 * @print_headers: override the first lines that describe your columns
253 * @print_line: callback that prints a trace
254 * @set_flag: signals one of your private flags changed (trace_options file)
255 * @flags: your private flags
257 struct tracer {
258 const char *name;
259 int (*init)(struct trace_array *tr);
260 void (*reset)(struct trace_array *tr);
261 void (*start)(struct trace_array *tr);
262 void (*stop)(struct trace_array *tr);
263 void (*open)(struct trace_iterator *iter);
264 void (*pipe_open)(struct trace_iterator *iter);
265 void (*wait_pipe)(struct trace_iterator *iter);
266 void (*close)(struct trace_iterator *iter);
267 ssize_t (*read)(struct trace_iterator *iter,
268 struct file *filp, char __user *ubuf,
269 size_t cnt, loff_t *ppos);
270 ssize_t (*splice_read)(struct trace_iterator *iter,
271 struct file *filp,
272 loff_t *ppos,
273 struct pipe_inode_info *pipe,
274 size_t len,
275 unsigned int flags);
276 #ifdef CONFIG_FTRACE_STARTUP_TEST
277 int (*selftest)(struct tracer *trace,
278 struct trace_array *tr);
279 #endif
280 void (*print_header)(struct seq_file *m);
281 enum print_line_t (*print_line)(struct trace_iterator *iter);
282 /* If you handled the flag setting, return 0 */
283 int (*set_flag)(u32 old_flags, u32 bit, int set);
284 struct tracer *next;
285 int print_max;
286 struct tracer_flags *flags;
290 #define TRACE_PIPE_ALL_CPU -1
292 int tracer_init(struct tracer *t, struct trace_array *tr);
293 int tracing_is_enabled(void);
294 void trace_wake_up(void);
295 void tracing_reset(struct trace_array *tr, int cpu);
296 void tracing_reset_online_cpus(struct trace_array *tr);
297 void tracing_reset_current(int cpu);
298 void tracing_reset_current_online_cpus(void);
299 int tracing_open_generic(struct inode *inode, struct file *filp);
300 struct dentry *trace_create_file(const char *name,
301 mode_t mode,
302 struct dentry *parent,
303 void *data,
304 const struct file_operations *fops);
306 struct dentry *tracing_init_dentry(void);
307 void init_tracer_sysprof_debugfs(struct dentry *d_tracer);
309 struct ring_buffer_event;
311 struct ring_buffer_event *
312 trace_buffer_lock_reserve(struct ring_buffer *buffer,
313 int type,
314 unsigned long len,
315 unsigned long flags,
316 int pc);
317 void trace_buffer_unlock_commit(struct ring_buffer *buffer,
318 struct ring_buffer_event *event,
319 unsigned long flags, int pc);
321 struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
322 struct trace_array_cpu *data);
324 struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
325 int *ent_cpu, u64 *ent_ts);
327 void default_wait_pipe(struct trace_iterator *iter);
328 void poll_wait_pipe(struct trace_iterator *iter);
330 void ftrace(struct trace_array *tr,
331 struct trace_array_cpu *data,
332 unsigned long ip,
333 unsigned long parent_ip,
334 unsigned long flags, int pc);
335 void tracing_sched_switch_trace(struct trace_array *tr,
336 struct task_struct *prev,
337 struct task_struct *next,
338 unsigned long flags, int pc);
340 void tracing_sched_wakeup_trace(struct trace_array *tr,
341 struct task_struct *wakee,
342 struct task_struct *cur,
343 unsigned long flags, int pc);
344 void trace_special(struct trace_array *tr,
345 struct trace_array_cpu *data,
346 unsigned long arg1,
347 unsigned long arg2,
348 unsigned long arg3, int pc);
349 void trace_function(struct trace_array *tr,
350 unsigned long ip,
351 unsigned long parent_ip,
352 unsigned long flags, int pc);
354 void trace_graph_return(struct ftrace_graph_ret *trace);
355 int trace_graph_entry(struct ftrace_graph_ent *trace);
356 void set_graph_array(struct trace_array *tr);
358 void tracing_start_cmdline_record(void);
359 void tracing_stop_cmdline_record(void);
360 void tracing_sched_switch_assign_trace(struct trace_array *tr);
361 void tracing_stop_sched_switch_record(void);
362 void tracing_start_sched_switch_record(void);
363 int register_tracer(struct tracer *type);
364 void unregister_tracer(struct tracer *type);
365 int is_tracing_stopped(void);
367 extern unsigned long nsecs_to_usecs(unsigned long nsecs);
369 #ifdef CONFIG_TRACER_MAX_TRACE
370 extern unsigned long tracing_max_latency;
371 extern unsigned long tracing_thresh;
373 void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu);
374 void update_max_tr_single(struct trace_array *tr,
375 struct task_struct *tsk, int cpu);
376 #endif /* CONFIG_TRACER_MAX_TRACE */
378 #ifdef CONFIG_STACKTRACE
379 void ftrace_trace_stack(struct ring_buffer *buffer, unsigned long flags,
380 int skip, int pc);
382 void ftrace_trace_userstack(struct ring_buffer *buffer, unsigned long flags,
383 int pc);
385 void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
386 int pc);
387 #else
388 static inline void ftrace_trace_stack(struct trace_array *tr,
389 unsigned long flags, int skip, int pc)
393 static inline void ftrace_trace_userstack(struct trace_array *tr,
394 unsigned long flags, int pc)
398 static inline void __trace_stack(struct trace_array *tr, unsigned long flags,
399 int skip, int pc)
402 #endif /* CONFIG_STACKTRACE */
404 extern cycle_t ftrace_now(int cpu);
406 extern void trace_find_cmdline(int pid, char comm[]);
408 #ifdef CONFIG_DYNAMIC_FTRACE
409 extern unsigned long ftrace_update_tot_cnt;
410 #define DYN_FTRACE_TEST_NAME trace_selftest_dynamic_test_func
411 extern int DYN_FTRACE_TEST_NAME(void);
412 #endif
414 extern int ring_buffer_expanded;
415 extern bool tracing_selftest_disabled;
416 DECLARE_PER_CPU(local_t, ftrace_cpu_disabled);
418 #ifdef CONFIG_FTRACE_STARTUP_TEST
419 extern int trace_selftest_startup_function(struct tracer *trace,
420 struct trace_array *tr);
421 extern int trace_selftest_startup_function_graph(struct tracer *trace,
422 struct trace_array *tr);
423 extern int trace_selftest_startup_irqsoff(struct tracer *trace,
424 struct trace_array *tr);
425 extern int trace_selftest_startup_preemptoff(struct tracer *trace,
426 struct trace_array *tr);
427 extern int trace_selftest_startup_preemptirqsoff(struct tracer *trace,
428 struct trace_array *tr);
429 extern int trace_selftest_startup_wakeup(struct tracer *trace,
430 struct trace_array *tr);
431 extern int trace_selftest_startup_nop(struct tracer *trace,
432 struct trace_array *tr);
433 extern int trace_selftest_startup_sched_switch(struct tracer *trace,
434 struct trace_array *tr);
435 extern int trace_selftest_startup_sysprof(struct tracer *trace,
436 struct trace_array *tr);
437 extern int trace_selftest_startup_branch(struct tracer *trace,
438 struct trace_array *tr);
439 extern int trace_selftest_startup_hw_branches(struct tracer *trace,
440 struct trace_array *tr);
441 #endif /* CONFIG_FTRACE_STARTUP_TEST */
443 extern void *head_page(struct trace_array_cpu *data);
444 extern unsigned long long ns2usecs(cycle_t nsec);
445 extern int
446 trace_vbprintk(unsigned long ip, const char *fmt, va_list args);
447 extern int
448 trace_vprintk(unsigned long ip, const char *fmt, va_list args);
449 extern int
450 trace_array_vprintk(struct trace_array *tr,
451 unsigned long ip, const char *fmt, va_list args);
452 int trace_array_printk(struct trace_array *tr,
453 unsigned long ip, const char *fmt, ...);
455 extern unsigned long trace_flags;
457 extern int trace_clock_id;
459 /* Standard output formatting function used for function return traces */
460 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
461 extern enum print_line_t print_graph_function(struct trace_iterator *iter);
462 extern enum print_line_t
463 trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
465 #ifdef CONFIG_DYNAMIC_FTRACE
466 /* TODO: make this variable */
467 #define FTRACE_GRAPH_MAX_FUNCS 32
468 extern int ftrace_graph_count;
469 extern unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS];
471 static inline int ftrace_graph_addr(unsigned long addr)
473 int i;
475 if (!ftrace_graph_count || test_tsk_trace_graph(current))
476 return 1;
478 for (i = 0; i < ftrace_graph_count; i++) {
479 if (addr == ftrace_graph_funcs[i])
480 return 1;
483 return 0;
485 #else
486 static inline int ftrace_trace_addr(unsigned long addr)
488 return 1;
490 static inline int ftrace_graph_addr(unsigned long addr)
492 return 1;
494 #endif /* CONFIG_DYNAMIC_FTRACE */
495 #else /* CONFIG_FUNCTION_GRAPH_TRACER */
496 static inline enum print_line_t
497 print_graph_function(struct trace_iterator *iter)
499 return TRACE_TYPE_UNHANDLED;
501 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
503 extern struct pid *ftrace_pid_trace;
505 #ifdef CONFIG_FUNCTION_TRACER
506 static inline int ftrace_trace_task(struct task_struct *task)
508 if (!ftrace_pid_trace)
509 return 1;
511 return test_tsk_trace_trace(task);
513 #else
514 static inline int ftrace_trace_task(struct task_struct *task)
516 return 1;
518 #endif
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
527 struct trace_parser {
528 bool cont;
529 char *buffer;
530 unsigned idx;
531 unsigned size;
534 static inline bool trace_parser_loaded(struct trace_parser *parser)
536 return (parser->idx != 0);
539 static inline bool trace_parser_cont(struct trace_parser *parser)
541 return parser->cont;
544 static inline void trace_parser_clear(struct trace_parser *parser)
546 parser->cont = false;
547 parser->idx = 0;
550 extern int trace_parser_get_init(struct trace_parser *parser, int size);
551 extern void trace_parser_put(struct trace_parser *parser);
552 extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
553 size_t cnt, loff_t *ppos);
556 * trace_iterator_flags is an enumeration that defines bit
557 * positions into trace_flags that controls the output.
559 * NOTE: These bits must match the trace_options array in
560 * trace.c.
562 enum trace_iterator_flags {
563 TRACE_ITER_PRINT_PARENT = 0x01,
564 TRACE_ITER_SYM_OFFSET = 0x02,
565 TRACE_ITER_SYM_ADDR = 0x04,
566 TRACE_ITER_VERBOSE = 0x08,
567 TRACE_ITER_RAW = 0x10,
568 TRACE_ITER_HEX = 0x20,
569 TRACE_ITER_BIN = 0x40,
570 TRACE_ITER_BLOCK = 0x80,
571 TRACE_ITER_STACKTRACE = 0x100,
572 TRACE_ITER_SCHED_TREE = 0x200,
573 TRACE_ITER_PRINTK = 0x400,
574 TRACE_ITER_PREEMPTONLY = 0x800,
575 TRACE_ITER_BRANCH = 0x1000,
576 TRACE_ITER_ANNOTATE = 0x2000,
577 TRACE_ITER_USERSTACKTRACE = 0x4000,
578 TRACE_ITER_SYM_USEROBJ = 0x8000,
579 TRACE_ITER_PRINTK_MSGONLY = 0x10000,
580 TRACE_ITER_CONTEXT_INFO = 0x20000, /* Print pid/cpu/time */
581 TRACE_ITER_LATENCY_FMT = 0x40000,
582 TRACE_ITER_SLEEP_TIME = 0x80000,
583 TRACE_ITER_GRAPH_TIME = 0x100000,
587 * TRACE_ITER_SYM_MASK masks the options in trace_flags that
588 * control the output of kernel symbols.
590 #define TRACE_ITER_SYM_MASK \
591 (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR)
593 extern struct tracer nop_trace;
596 * ftrace_preempt_disable - disable preemption scheduler safe
598 * When tracing can happen inside the scheduler, there exists
599 * cases that the tracing might happen before the need_resched
600 * flag is checked. If this happens and the tracer calls
601 * preempt_enable (after a disable), a schedule might take place
602 * causing an infinite recursion.
604 * To prevent this, we read the need_resched flag before
605 * disabling preemption. When we want to enable preemption we
606 * check the flag, if it is set, then we call preempt_enable_no_resched.
607 * Otherwise, we call preempt_enable.
609 * The rational for doing the above is that if need_resched is set
610 * and we have yet to reschedule, we are either in an atomic location
611 * (where we do not need to check for scheduling) or we are inside
612 * the scheduler and do not want to resched.
614 static inline int ftrace_preempt_disable(void)
616 int resched;
618 resched = need_resched();
619 preempt_disable_notrace();
621 return resched;
625 * ftrace_preempt_enable - enable preemption scheduler safe
626 * @resched: the return value from ftrace_preempt_disable
628 * This is a scheduler safe way to enable preemption and not miss
629 * any preemption checks. The disabled saved the state of preemption.
630 * If resched is set, then we are either inside an atomic or
631 * are inside the scheduler (we would have already scheduled
632 * otherwise). In this case, we do not want to call normal
633 * preempt_enable, but preempt_enable_no_resched instead.
635 static inline void ftrace_preempt_enable(int resched)
637 if (resched)
638 preempt_enable_no_resched_notrace();
639 else
640 preempt_enable_notrace();
643 #ifdef CONFIG_BRANCH_TRACER
644 extern int enable_branch_tracing(struct trace_array *tr);
645 extern void disable_branch_tracing(void);
646 static inline int trace_branch_enable(struct trace_array *tr)
648 if (trace_flags & TRACE_ITER_BRANCH)
649 return enable_branch_tracing(tr);
650 return 0;
652 static inline void trace_branch_disable(void)
654 /* due to races, always disable */
655 disable_branch_tracing();
657 #else
658 static inline int trace_branch_enable(struct trace_array *tr)
660 return 0;
662 static inline void trace_branch_disable(void)
665 #endif /* CONFIG_BRANCH_TRACER */
667 /* set ring buffers to default size if not already done so */
668 int tracing_update_buffers(void);
670 /* trace event type bit fields, not numeric */
671 enum {
672 TRACE_EVENT_TYPE_PRINTF = 1,
673 TRACE_EVENT_TYPE_RAW = 2,
676 struct ftrace_event_field {
677 struct list_head link;
678 char *name;
679 char *type;
680 int filter_type;
681 int offset;
682 int size;
683 int is_signed;
686 struct event_filter {
687 int n_preds;
688 struct filter_pred **preds;
689 char *filter_string;
690 bool no_reset;
693 struct event_subsystem {
694 struct list_head list;
695 const char *name;
696 struct dentry *entry;
697 struct event_filter *filter;
698 int nr_events;
701 struct filter_pred;
703 typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event,
704 int val1, int val2);
706 struct filter_pred {
707 filter_pred_fn_t fn;
708 u64 val;
709 char str_val[MAX_FILTER_STR_VAL];
710 int str_len;
711 char *field_name;
712 int offset;
713 int not;
714 int op;
715 int pop_n;
718 extern void print_event_filter(struct ftrace_event_call *call,
719 struct trace_seq *s);
720 extern int apply_event_filter(struct ftrace_event_call *call,
721 char *filter_string);
722 extern int apply_subsystem_event_filter(struct event_subsystem *system,
723 char *filter_string);
724 extern void print_subsystem_event_filter(struct event_subsystem *system,
725 struct trace_seq *s);
726 extern int filter_assign_type(const char *type);
728 static inline int
729 filter_check_discard(struct ftrace_event_call *call, void *rec,
730 struct ring_buffer *buffer,
731 struct ring_buffer_event *event)
733 if (unlikely(call->filter_active) && !filter_match_preds(call, rec)) {
734 ring_buffer_discard_commit(buffer, event);
735 return 1;
738 return 0;
741 extern struct mutex event_mutex;
742 extern struct list_head ftrace_events;
744 extern const char *__start___trace_bprintk_fmt[];
745 extern const char *__stop___trace_bprintk_fmt[];
747 #undef FTRACE_ENTRY
748 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \
749 extern struct ftrace_event_call event_##call;
750 #undef FTRACE_ENTRY_DUP
751 #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \
752 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))
753 #include "trace_entries.h"
755 #endif /* _LINUX_KERNEL_TRACE_H */