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.h118
1 files changed, 83 insertions, 35 deletions
diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
index 405cb850b75d..2825ef2c0b15 100644
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -11,6 +11,7 @@
11#include <linux/ftrace.h> 11#include <linux/ftrace.h>
12#include <trace/boot.h> 12#include <trace/boot.h>
13#include <linux/kmemtrace.h> 13#include <linux/kmemtrace.h>
14#include <linux/hw_breakpoint.h>
14 15
15#include <linux/trace_seq.h> 16#include <linux/trace_seq.h>
16#include <linux/ftrace_event.h> 17#include <linux/ftrace_event.h>
@@ -37,6 +38,7 @@ enum trace_type {
37 TRACE_KMEM_ALLOC, 38 TRACE_KMEM_ALLOC,
38 TRACE_KMEM_FREE, 39 TRACE_KMEM_FREE,
39 TRACE_BLK, 40 TRACE_BLK,
41 TRACE_KSYM,
40 42
41 __TRACE_LAST_TYPE, 43 __TRACE_LAST_TYPE,
42}; 44};
@@ -98,9 +100,32 @@ struct syscall_trace_enter {
98struct syscall_trace_exit { 100struct syscall_trace_exit {
99 struct trace_entry ent; 101 struct trace_entry ent;
100 int nr; 102 int nr;
101 unsigned long ret; 103 long ret;
102}; 104};
103 105
106struct kprobe_trace_entry {
107 struct trace_entry ent;
108 unsigned long ip;
109 int nargs;
110 unsigned long args[];
111};
112
113#define SIZEOF_KPROBE_TRACE_ENTRY(n) \
114 (offsetof(struct kprobe_trace_entry, args) + \
115 (sizeof(unsigned long) * (n)))
116
117struct kretprobe_trace_entry {
118 struct trace_entry ent;
119 unsigned long func;
120 unsigned long ret_ip;
121 int nargs;
122 unsigned long args[];
123};
124
125#define SIZEOF_KRETPROBE_TRACE_ENTRY(n) \
126 (offsetof(struct kretprobe_trace_entry, args) + \
127 (sizeof(unsigned long) * (n)))
128
104/* 129/*
105 * trace_flag_type is an enumeration that holds different 130 * trace_flag_type is an enumeration that holds different
106 * states when a trace occurs. These are: 131 * states when a trace occurs. These are:
@@ -209,6 +234,7 @@ extern void __ftrace_bad_type(void);
209 TRACE_KMEM_ALLOC); \ 234 TRACE_KMEM_ALLOC); \
210 IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \ 235 IF_ASSIGN(var, ent, struct kmemtrace_free_entry, \
211 TRACE_KMEM_FREE); \ 236 TRACE_KMEM_FREE); \
237 IF_ASSIGN(var, ent, struct ksym_trace_entry, TRACE_KSYM);\
212 __ftrace_bad_type(); \ 238 __ftrace_bad_type(); \
213 } while (0) 239 } while (0)
214 240
@@ -246,6 +272,7 @@ struct tracer_flags {
246 * @pipe_open: called when the trace_pipe file is opened 272 * @pipe_open: called when the trace_pipe file is opened
247 * @wait_pipe: override how the user waits for traces on trace_pipe 273 * @wait_pipe: override how the user waits for traces on trace_pipe
248 * @close: called when the trace file is released 274 * @close: called when the trace file is released
275 * @pipe_close: called when the trace_pipe file is released
249 * @read: override the default read callback on trace_pipe 276 * @read: override the default read callback on trace_pipe
250 * @splice_read: override the default splice_read callback on trace_pipe 277 * @splice_read: override the default splice_read callback on trace_pipe
251 * @selftest: selftest to run on boot (see trace_selftest.c) 278 * @selftest: selftest to run on boot (see trace_selftest.c)
@@ -264,6 +291,7 @@ struct tracer {
264 void (*pipe_open)(struct trace_iterator *iter); 291 void (*pipe_open)(struct trace_iterator *iter);
265 void (*wait_pipe)(struct trace_iterator *iter); 292 void (*wait_pipe)(struct trace_iterator *iter);
266 void (*close)(struct trace_iterator *iter); 293 void (*close)(struct trace_iterator *iter);
294 void (*pipe_close)(struct trace_iterator *iter);
267 ssize_t (*read)(struct trace_iterator *iter, 295 ssize_t (*read)(struct trace_iterator *iter,
268 struct file *filp, char __user *ubuf, 296 struct file *filp, char __user *ubuf,
269 size_t cnt, loff_t *ppos); 297 size_t cnt, loff_t *ppos);
@@ -364,11 +392,14 @@ int register_tracer(struct tracer *type);
364void unregister_tracer(struct tracer *type); 392void unregister_tracer(struct tracer *type);
365int is_tracing_stopped(void); 393int is_tracing_stopped(void);
366 394
395extern int process_new_ksym_entry(char *ksymname, int op, unsigned long addr);
396
367extern unsigned long nsecs_to_usecs(unsigned long nsecs); 397extern unsigned long nsecs_to_usecs(unsigned long nsecs);
368 398
399extern unsigned long tracing_thresh;
400
369#ifdef CONFIG_TRACER_MAX_TRACE 401#ifdef CONFIG_TRACER_MAX_TRACE
370extern unsigned long tracing_max_latency; 402extern unsigned long tracing_max_latency;
371extern unsigned long tracing_thresh;
372 403
373void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu); 404void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu);
374void update_max_tr_single(struct trace_array *tr, 405void update_max_tr_single(struct trace_array *tr,
@@ -413,7 +444,7 @@ extern int DYN_FTRACE_TEST_NAME(void);
413 444
414extern int ring_buffer_expanded; 445extern int ring_buffer_expanded;
415extern bool tracing_selftest_disabled; 446extern bool tracing_selftest_disabled;
416DECLARE_PER_CPU(local_t, ftrace_cpu_disabled); 447DECLARE_PER_CPU(int, ftrace_cpu_disabled);
417 448
418#ifdef CONFIG_FTRACE_STARTUP_TEST 449#ifdef CONFIG_FTRACE_STARTUP_TEST
419extern int trace_selftest_startup_function(struct tracer *trace, 450extern int trace_selftest_startup_function(struct tracer *trace,
@@ -438,6 +469,8 @@ extern int trace_selftest_startup_branch(struct tracer *trace,
438 struct trace_array *tr); 469 struct trace_array *tr);
439extern int trace_selftest_startup_hw_branches(struct tracer *trace, 470extern int trace_selftest_startup_hw_branches(struct tracer *trace,
440 struct trace_array *tr); 471 struct trace_array *tr);
472extern int trace_selftest_startup_ksym(struct tracer *trace,
473 struct trace_array *tr);
441#endif /* CONFIG_FTRACE_STARTUP_TEST */ 474#endif /* CONFIG_FTRACE_STARTUP_TEST */
442 475
443extern void *head_page(struct trace_array_cpu *data); 476extern void *head_page(struct trace_array_cpu *data);
@@ -465,6 +498,7 @@ trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
465#ifdef CONFIG_DYNAMIC_FTRACE 498#ifdef CONFIG_DYNAMIC_FTRACE
466/* TODO: make this variable */ 499/* TODO: make this variable */
467#define FTRACE_GRAPH_MAX_FUNCS 32 500#define FTRACE_GRAPH_MAX_FUNCS 32
501extern int ftrace_graph_filter_enabled;
468extern int ftrace_graph_count; 502extern int ftrace_graph_count;
469extern unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS]; 503extern unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS];
470 504
@@ -472,7 +506,7 @@ static inline int ftrace_graph_addr(unsigned long addr)
472{ 506{
473 int i; 507 int i;
474 508
475 if (!ftrace_graph_count || test_tsk_trace_graph(current)) 509 if (!ftrace_graph_filter_enabled)
476 return 1; 510 return 1;
477 511
478 for (i = 0; i < ftrace_graph_count; i++) { 512 for (i = 0; i < ftrace_graph_count; i++) {
@@ -483,10 +517,6 @@ static inline int ftrace_graph_addr(unsigned long addr)
483 return 0; 517 return 0;
484} 518}
485#else 519#else
486static inline int ftrace_trace_addr(unsigned long addr)
487{
488 return 1;
489}
490static inline int ftrace_graph_addr(unsigned long addr) 520static inline int ftrace_graph_addr(unsigned long addr)
491{ 521{
492 return 1; 522 return 1;
@@ -500,12 +530,12 @@ print_graph_function(struct trace_iterator *iter)
500} 530}
501#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 531#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
502 532
503extern struct pid *ftrace_pid_trace; 533extern struct list_head ftrace_pids;
504 534
505#ifdef CONFIG_FUNCTION_TRACER 535#ifdef CONFIG_FUNCTION_TRACER
506static inline int ftrace_trace_task(struct task_struct *task) 536static inline int ftrace_trace_task(struct task_struct *task)
507{ 537{
508 if (!ftrace_pid_trace) 538 if (list_empty(&ftrace_pids))
509 return 1; 539 return 1;
510 540
511 return test_tsk_trace_trace(task); 541 return test_tsk_trace_trace(task);
@@ -521,7 +551,7 @@ static inline int ftrace_trace_task(struct task_struct *task)
521 * struct trace_parser - servers for reading the user input separated by spaces 551 * 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 552 * @cont: set if the input is not complete - no final space char was found
523 * @buffer: holds the parsed user input 553 * @buffer: holds the parsed user input
524 * @idx: user input lenght 554 * @idx: user input length
525 * @size: buffer size 555 * @size: buffer size
526 */ 556 */
527struct trace_parser { 557struct trace_parser {
@@ -569,18 +599,17 @@ enum trace_iterator_flags {
569 TRACE_ITER_BIN = 0x40, 599 TRACE_ITER_BIN = 0x40,
570 TRACE_ITER_BLOCK = 0x80, 600 TRACE_ITER_BLOCK = 0x80,
571 TRACE_ITER_STACKTRACE = 0x100, 601 TRACE_ITER_STACKTRACE = 0x100,
572 TRACE_ITER_SCHED_TREE = 0x200, 602 TRACE_ITER_PRINTK = 0x200,
573 TRACE_ITER_PRINTK = 0x400, 603 TRACE_ITER_PREEMPTONLY = 0x400,
574 TRACE_ITER_PREEMPTONLY = 0x800, 604 TRACE_ITER_BRANCH = 0x800,
575 TRACE_ITER_BRANCH = 0x1000, 605 TRACE_ITER_ANNOTATE = 0x1000,
576 TRACE_ITER_ANNOTATE = 0x2000, 606 TRACE_ITER_USERSTACKTRACE = 0x2000,
577 TRACE_ITER_USERSTACKTRACE = 0x4000, 607 TRACE_ITER_SYM_USEROBJ = 0x4000,
578 TRACE_ITER_SYM_USEROBJ = 0x8000, 608 TRACE_ITER_PRINTK_MSGONLY = 0x8000,
579 TRACE_ITER_PRINTK_MSGONLY = 0x10000, 609 TRACE_ITER_CONTEXT_INFO = 0x10000, /* Print pid/cpu/time */
580 TRACE_ITER_CONTEXT_INFO = 0x20000, /* Print pid/cpu/time */ 610 TRACE_ITER_LATENCY_FMT = 0x20000,
581 TRACE_ITER_LATENCY_FMT = 0x40000, 611 TRACE_ITER_SLEEP_TIME = 0x40000,
582 TRACE_ITER_SLEEP_TIME = 0x80000, 612 TRACE_ITER_GRAPH_TIME = 0x80000,
583 TRACE_ITER_GRAPH_TIME = 0x100000,
584}; 613};
585 614
586/* 615/*
@@ -687,7 +716,6 @@ struct event_filter {
687 int n_preds; 716 int n_preds;
688 struct filter_pred **preds; 717 struct filter_pred **preds;
689 char *filter_string; 718 char *filter_string;
690 bool no_reset;
691}; 719};
692 720
693struct event_subsystem { 721struct event_subsystem {
@@ -699,22 +727,40 @@ struct event_subsystem {
699}; 727};
700 728
701struct filter_pred; 729struct filter_pred;
730struct regex;
702 731
703typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event, 732typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event,
704 int val1, int val2); 733 int val1, int val2);
705 734
735typedef int (*regex_match_func)(char *str, struct regex *r, int len);
736
737enum regex_type {
738 MATCH_FULL = 0,
739 MATCH_FRONT_ONLY,
740 MATCH_MIDDLE_ONLY,
741 MATCH_END_ONLY,
742};
743
744struct regex {
745 char pattern[MAX_FILTER_STR_VAL];
746 int len;
747 int field_len;
748 regex_match_func match;
749};
750
706struct filter_pred { 751struct filter_pred {
707 filter_pred_fn_t fn; 752 filter_pred_fn_t fn;
708 u64 val; 753 u64 val;
709 char str_val[MAX_FILTER_STR_VAL]; 754 struct regex regex;
710 int str_len; 755 char *field_name;
711 char *field_name; 756 int offset;
712 int offset; 757 int not;
713 int not; 758 int op;
714 int op; 759 int pop_n;
715 int pop_n;
716}; 760};
717 761
762extern enum regex_type
763filter_parse_regex(char *buff, int len, char **search, int *not);
718extern void print_event_filter(struct ftrace_event_call *call, 764extern void print_event_filter(struct ftrace_event_call *call,
719 struct trace_seq *s); 765 struct trace_seq *s);
720extern int apply_event_filter(struct ftrace_event_call *call, 766extern int apply_event_filter(struct ftrace_event_call *call,
@@ -730,7 +776,8 @@ filter_check_discard(struct ftrace_event_call *call, void *rec,
730 struct ring_buffer *buffer, 776 struct ring_buffer *buffer,
731 struct ring_buffer_event *event) 777 struct ring_buffer_event *event)
732{ 778{
733 if (unlikely(call->filter_active) && !filter_match_preds(call, rec)) { 779 if (unlikely(call->filter_active) &&
780 !filter_match_preds(call->filter, rec)) {
734 ring_buffer_discard_commit(buffer, event); 781 ring_buffer_discard_commit(buffer, event);
735 return 1; 782 return 1;
736 } 783 }
@@ -746,7 +793,8 @@ extern const char *__stop___trace_bprintk_fmt[];
746 793
747#undef FTRACE_ENTRY 794#undef FTRACE_ENTRY
748#define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \ 795#define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \
749 extern struct ftrace_event_call event_##call; 796 extern struct ftrace_event_call \
797 __attribute__((__aligned__(4))) event_##call;
750#undef FTRACE_ENTRY_DUP 798#undef FTRACE_ENTRY_DUP
751#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \ 799#define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \
752 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print)) 800 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))