]>
git.proxmox.com Git - mirror_ubuntu-kernels.git/blob - include/linux/ftrace_event.h
1 #ifndef _LINUX_FTRACE_EVENT_H
2 #define _LINUX_FTRACE_EVENT_H
4 #include <linux/trace_seq.h>
5 #include <linux/ring_buffer.h>
13 * The trace entry - the most basic unit of tracing. This is what
14 * is printed in the end as a single line in the trace output, such as:
16 * bash-15816 [01] 235.197585: idle_cpu <- irq_enter
21 unsigned char preempt_count
;
26 #define FTRACE_MAX_EVENT \
27 ((1 << (sizeof(((struct trace_entry *)0)->type) * 8)) - 1)
30 * Trace iterator - used by printout routines who present trace
31 * results to users and which routines might sleep, etc:
33 struct trace_iterator
{
34 struct trace_array
*tr
;
39 struct ring_buffer_iter
*buffer_iter
[NR_CPUS
];
41 /* The below is zeroed out in pipe_read */
43 struct trace_entry
*ent
;
47 unsigned long iter_flags
;
51 cpumask_var_t started
;
55 typedef enum print_line_t (*trace_print_func
)(struct trace_iterator
*iter
,
58 struct hlist_node node
;
59 struct list_head list
;
61 trace_print_func trace
;
64 trace_print_func binary
;
67 extern int register_ftrace_event(struct trace_event
*event
);
68 extern int unregister_ftrace_event(struct trace_event
*event
);
70 /* Return values for print_line callback */
72 TRACE_TYPE_PARTIAL_LINE
= 0, /* Retry after flushing the seq */
73 TRACE_TYPE_HANDLED
= 1,
74 TRACE_TYPE_UNHANDLED
= 2, /* Relay to other output functions */
75 TRACE_TYPE_NO_CONSUME
= 3 /* Handled but ask to not consume */
79 struct ring_buffer_event
*
80 trace_current_buffer_lock_reserve(int type
, unsigned long len
,
81 unsigned long flags
, int pc
);
82 void trace_current_buffer_unlock_commit(struct ring_buffer_event
*event
,
83 unsigned long flags
, int pc
);
84 void trace_nowake_buffer_unlock_commit(struct ring_buffer_event
*event
,
85 unsigned long flags
, int pc
);
86 void trace_current_buffer_discard_commit(struct ring_buffer_event
*event
);
88 void tracing_record_cmdline(struct task_struct
*tsk
);
90 struct ftrace_event_call
{
91 struct list_head list
;
95 struct trace_event
*event
;
98 void (*unregfunc
)(void);
100 int (*raw_init
)(void);
101 int (*show_format
)(struct trace_seq
*s
);
102 int (*define_fields
)(void);
103 struct list_head fields
;
108 #ifdef CONFIG_EVENT_PROFILE
109 atomic_t profile_count
;
110 int (*profile_enable
)(struct ftrace_event_call
*);
111 void (*profile_disable
)(struct ftrace_event_call
*);
115 #define MAX_FILTER_PRED 32
116 #define MAX_FILTER_STR_VAL 128
118 extern int init_preds(struct ftrace_event_call
*call
);
119 extern void destroy_preds(struct ftrace_event_call
*call
);
120 extern int filter_match_preds(struct ftrace_event_call
*call
, void *rec
);
121 extern int filter_current_check_discard(struct ftrace_event_call
*call
,
123 struct ring_buffer_event
*event
);
125 extern int trace_define_field(struct ftrace_event_call
*call
, char *type
,
126 char *name
, int offset
, int size
, int is_signed
);
128 #define is_signed_type(type) (((type)(-1)) < 0)
131 * The double __builtin_constant_p is because gcc will give us an error
132 * if we try to allocate the static variable to fmt if it is not a
133 * constant. Even with the outer if statement optimizing out.
135 #define event_trace_printk(ip, fmt, args...) \
137 __trace_printk_check_format(fmt, ##args); \
138 tracing_record_cmdline(current); \
139 if (__builtin_constant_p(fmt)) { \
140 static const char *trace_printk_fmt \
141 __attribute__((section("__trace_printk_fmt"))) = \
142 __builtin_constant_p(fmt) ? fmt : NULL; \
144 __trace_bprintk(ip, trace_printk_fmt, ##args); \
146 __trace_printk(ip, fmt, ##args); \
149 #define __common_field(type, item, is_signed) \
150 ret = trace_define_field(event_call, #type, "common_" #item, \
151 offsetof(typeof(field.ent), item), \
152 sizeof(field.ent.item), is_signed); \
156 #endif /* _LINUX_FTRACE_EVENT_H */