1 #ifndef _LINUX_KERNEL_TRACE_H
2 #define _LINUX_KERNEL_TRACE_H
6 #include <linux/sched.h>
12 #include <linux/hw_breakpoint.h>
38 #define __field(type, item) type item;
41 #define __field_struct(type, item) __field(type, item)
44 #define __field_desc(type, container, item)
47 #define __array(type, item, size) type item[size];
50 #define __array_desc(type, container, item, size)
52 #undef __dynamic_array
53 #define __dynamic_array(type, item) type item[];
56 #define F_STRUCT(args...) args
59 #define FTRACE_ENTRY(name, struct_name, id, tstruct, print, filter) \
60 struct struct_name { \
61 struct trace_entry ent; \
66 #define TP_ARGS(args...) args
68 #undef FTRACE_ENTRY_DUP
69 #define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk, filter)
71 #undef FTRACE_ENTRY_REG
72 #define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, \
74 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print), \
128 #define TRACE_BUF_SIZE 1024
168 #define FTRACE_CMP_TYPE(var, type) \
169 __builtin_types_compatible_p(typeof(var), type *)
172 #define IF_ASSIGN(var, entry, etype, id) \
173 if (FTRACE_CMP_TYPE(var, etype)) { \
174 var = (typeof(var))(entry); \
175 WARN_ON(id && (entry)->type != id); \
195 #define trace_assign_type(var, ent) \
197 IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN); \
198 IF_ASSIGN(var, ent, struct ctx_switch_entry, 0); \
199 IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \
200 IF_ASSIGN(var, ent, struct userstack_entry, TRACE_USER_STACK);\
201 IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \
202 IF_ASSIGN(var, ent, struct bprint_entry, TRACE_BPRINT); \
203 IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \
205 IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \
207 IF_ASSIGN(var, ent, struct trace_branch, TRACE_BRANCH); \
208 IF_ASSIGN(var, ent, struct ftrace_graph_ent_entry, \
210 IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \
212 __ftrace_bad_type(); \
235 #define TRACER_OPT(s, b) .name = #s, .bit = b
271 size_t cnt, loff_t *ppos);
278 #ifdef CONFIG_FTRACE_STARTUP_TEST
294 #define trace_recursion_inc() do { (current)->trace_recursion++; } while (0)
295 #define trace_recursion_dec() do { (current)->trace_recursion--; } while (0)
298 #define trace_recursion_buffer() ((current)->trace_recursion & 0x3ff)
301 #define TRACE_INTERNAL_BIT (1<<11)
302 #define TRACE_GLOBAL_BIT (1<<12)
303 #define TRACE_CONTROL_BIT (1<<13)
312 #define TRACE_IRQ_BIT (1<<13)
314 #define trace_recursion_set(bit) do { (current)->trace_recursion |= (bit); } while (0)
315 #define trace_recursion_clear(bit) do { (current)->trace_recursion &= ~(bit); } while (0)
316 #define trace_recursion_test(bit) ((current)->trace_recursion & (bit))
318 #define TRACE_PIPE_ALL_CPU -1
360 int *ent_cpu,
u64 *ent_ts);
376 unsigned long parent_ip,
389 unsigned long parent_ip,
393 unsigned long parent_ip,
419 #define for_each_tracing_cpu(cpu) \
420 for_each_cpu(cpu, tracing_buffer_mask)
426 #ifdef CONFIG_TRACER_MAX_TRACE
427 extern unsigned long tracing_max_latency;
434 #ifdef CONFIG_STACKTRACE
473 #ifdef CONFIG_DYNAMIC_FTRACE
474 extern unsigned long ftrace_update_tot_cnt;
476 #define DYN_FTRACE_TEST_NAME trace_selftest_dynamic_test_func
478 #define DYN_FTRACE_TEST_NAME2 trace_selftest_dynamic_test_func2
485 #ifdef CONFIG_FTRACE_STARTUP_TEST
486 extern int trace_selftest_startup_function(
struct tracer *
trace,
488 extern int trace_selftest_startup_function_graph(
struct tracer *
trace,
490 extern int trace_selftest_startup_irqsoff(
struct tracer *
trace,
492 extern int trace_selftest_startup_preemptoff(
struct tracer *
trace,
494 extern int trace_selftest_startup_preemptirqsoff(
struct tracer *
trace,
496 extern int trace_selftest_startup_wakeup(
struct tracer *
trace,
498 extern int trace_selftest_startup_nop(
struct tracer *
trace,
500 extern int trace_selftest_startup_sched_switch(
struct tracer *
trace,
502 extern int trace_selftest_startup_branch(
struct tracer *
trace,
516 unsigned long ip,
const char *
fmt, ...);
525 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
528 #define TRACE_GRAPH_PRINT_OVERRUN 0x1
529 #define TRACE_GRAPH_PRINT_CPU 0x2
530 #define TRACE_GRAPH_PRINT_OVERHEAD 0x4
531 #define TRACE_GRAPH_PRINT_PROC 0x8
532 #define TRACE_GRAPH_PRINT_DURATION 0x10
533 #define TRACE_GRAPH_PRINT_ABS_TIME 0x20
550 #ifdef CONFIG_DYNAMIC_FTRACE
552 #define FTRACE_GRAPH_MAX_FUNCS 32
553 extern int ftrace_graph_filter_enabled;
554 extern int ftrace_graph_count;
555 extern unsigned long ftrace_graph_funcs[FTRACE_GRAPH_MAX_FUNCS];
557 static inline int ftrace_graph_addr(
unsigned long addr)
561 if (!ftrace_graph_filter_enabled)
564 for (i = 0; i < ftrace_graph_count; i++) {
565 if (addr == ftrace_graph_funcs[i]) {
582 static inline int ftrace_graph_addr(
unsigned long addr)
597 #ifdef CONFIG_FUNCTION_TRACER
600 if (list_empty(&ftrace_pids))
603 return test_tsk_trace_trace(task);
607 static inline int ftrace_trace_task(
struct task_struct *task)
632 return (parser->
idx != 0);
642 parser->
cont =
false;
649 size_t cnt, loff_t *ppos);
690 #define TRACE_ITER_SYM_MASK \
691 (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR)
695 #ifdef CONFIG_BRANCH_TRACER
697 extern void disable_branch_tracing(
void);
698 static inline int trace_branch_enable(
struct trace_array *
tr)
701 return enable_branch_tracing(tr);
704 static inline void trace_branch_disable(
void)
707 disable_branch_tracing();
710 static inline int trace_branch_enable(
struct trace_array *tr)
714 static inline void trace_branch_disable(
void)
755 #define FILTER_PRED_INVALID ((unsigned short)-1)
756 #define FILTER_PRED_IS_RIGHT (1 << 15)
757 #define FILTER_PRED_FOLD (1 << 15)
766 #define MAX_FILTER_PRED 16384
811 char *filter_string);
813 char *filter_string);
846 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print, filter) \
847 extern struct ftrace_event_call \
848 __attribute__((__aligned__(4))) event_##call;
849 #undef FTRACE_ENTRY_DUP
850 #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print, filter) \
851 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print), \
855 #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER)
859 #define perf_ftrace_event_register NULL