dt-bindings: pinctrl: add bindings for MediaTek MT6779 SoC
[linux/fpc-iii.git] / kernel / trace / trace.h
blobdef769df5bf12e71e01f5ccf05c0066e976dda10
1 // SPDX-License-Identifier: GPL-2.0
3 #ifndef _LINUX_KERNEL_TRACE_H
4 #define _LINUX_KERNEL_TRACE_H
6 #include <linux/fs.h>
7 #include <linux/atomic.h>
8 #include <linux/sched.h>
9 #include <linux/clocksource.h>
10 #include <linux/ring_buffer.h>
11 #include <linux/mmiotrace.h>
12 #include <linux/tracepoint.h>
13 #include <linux/ftrace.h>
14 #include <linux/trace.h>
15 #include <linux/hw_breakpoint.h>
16 #include <linux/trace_seq.h>
17 #include <linux/trace_events.h>
18 #include <linux/compiler.h>
19 #include <linux/glob.h>
20 #include <linux/irq_work.h>
21 #include <linux/workqueue.h>
23 #ifdef CONFIG_FTRACE_SYSCALLS
24 #include <asm/unistd.h> /* For NR_SYSCALLS */
25 #include <asm/syscall.h> /* some archs define it here */
26 #endif
28 enum trace_type {
29 __TRACE_FIRST_TYPE = 0,
31 TRACE_FN,
32 TRACE_CTX,
33 TRACE_WAKE,
34 TRACE_STACK,
35 TRACE_PRINT,
36 TRACE_BPRINT,
37 TRACE_MMIO_RW,
38 TRACE_MMIO_MAP,
39 TRACE_BRANCH,
40 TRACE_GRAPH_RET,
41 TRACE_GRAPH_ENT,
42 TRACE_USER_STACK,
43 TRACE_BLK,
44 TRACE_BPUTS,
45 TRACE_HWLAT,
46 TRACE_RAW_DATA,
48 __TRACE_LAST_TYPE,
52 #undef __field
53 #define __field(type, item) type item;
55 #undef __field_fn
56 #define __field_fn(type, item) type item;
58 #undef __field_struct
59 #define __field_struct(type, item) __field(type, item)
61 #undef __field_desc
62 #define __field_desc(type, container, item)
64 #undef __array
65 #define __array(type, item, size) type item[size];
67 #undef __array_desc
68 #define __array_desc(type, container, item, size)
70 #undef __dynamic_array
71 #define __dynamic_array(type, item) type item[];
73 #undef F_STRUCT
74 #define F_STRUCT(args...) args
76 #undef FTRACE_ENTRY
77 #define FTRACE_ENTRY(name, struct_name, id, tstruct, print) \
78 struct struct_name { \
79 struct trace_entry ent; \
80 tstruct \
83 #undef FTRACE_ENTRY_DUP
84 #define FTRACE_ENTRY_DUP(name, name_struct, id, tstruct, printk)
86 #undef FTRACE_ENTRY_REG
87 #define FTRACE_ENTRY_REG(name, struct_name, id, tstruct, print, regfn) \
88 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print))
90 #undef FTRACE_ENTRY_PACKED
91 #define FTRACE_ENTRY_PACKED(name, struct_name, id, tstruct, print) \
92 FTRACE_ENTRY(name, struct_name, id, PARAMS(tstruct), PARAMS(print)) __packed
94 #include "trace_entries.h"
96 /* Use this for memory failure errors */
97 #define MEM_FAIL(condition, fmt, ...) ({ \
98 static bool __section(.data.once) __warned; \
99 int __ret_warn_once = !!(condition); \
101 if (unlikely(__ret_warn_once && !__warned)) { \
102 __warned = true; \
103 pr_err("ERROR: " fmt, ##__VA_ARGS__); \
105 unlikely(__ret_warn_once); \
109 * syscalls are special, and need special handling, this is why
110 * they are not included in trace_entries.h
112 struct syscall_trace_enter {
113 struct trace_entry ent;
114 int nr;
115 unsigned long args[];
118 struct syscall_trace_exit {
119 struct trace_entry ent;
120 int nr;
121 long ret;
124 struct kprobe_trace_entry_head {
125 struct trace_entry ent;
126 unsigned long ip;
129 struct kretprobe_trace_entry_head {
130 struct trace_entry ent;
131 unsigned long func;
132 unsigned long ret_ip;
136 * trace_flag_type is an enumeration that holds different
137 * states when a trace occurs. These are:
138 * IRQS_OFF - interrupts were disabled
139 * IRQS_NOSUPPORT - arch does not support irqs_disabled_flags
140 * NEED_RESCHED - reschedule is requested
141 * HARDIRQ - inside an interrupt handler
142 * SOFTIRQ - inside a softirq handler
144 enum trace_flag_type {
145 TRACE_FLAG_IRQS_OFF = 0x01,
146 TRACE_FLAG_IRQS_NOSUPPORT = 0x02,
147 TRACE_FLAG_NEED_RESCHED = 0x04,
148 TRACE_FLAG_HARDIRQ = 0x08,
149 TRACE_FLAG_SOFTIRQ = 0x10,
150 TRACE_FLAG_PREEMPT_RESCHED = 0x20,
151 TRACE_FLAG_NMI = 0x40,
154 #define TRACE_BUF_SIZE 1024
156 struct trace_array;
159 * The CPU trace array - it consists of thousands of trace entries
160 * plus some other descriptor data: (for example which task started
161 * the trace, etc.)
163 struct trace_array_cpu {
164 atomic_t disabled;
165 void *buffer_page; /* ring buffer spare */
167 unsigned long entries;
168 unsigned long saved_latency;
169 unsigned long critical_start;
170 unsigned long critical_end;
171 unsigned long critical_sequence;
172 unsigned long nice;
173 unsigned long policy;
174 unsigned long rt_priority;
175 unsigned long skipped_entries;
176 u64 preempt_timestamp;
177 pid_t pid;
178 kuid_t uid;
179 char comm[TASK_COMM_LEN];
181 #ifdef CONFIG_FUNCTION_TRACER
182 int ftrace_ignore_pid;
183 #endif
184 bool ignore_pid;
187 struct tracer;
188 struct trace_option_dentry;
190 struct array_buffer {
191 struct trace_array *tr;
192 struct trace_buffer *buffer;
193 struct trace_array_cpu __percpu *data;
194 u64 time_start;
195 int cpu;
198 #define TRACE_FLAGS_MAX_SIZE 32
200 struct trace_options {
201 struct tracer *tracer;
202 struct trace_option_dentry *topts;
205 struct trace_pid_list {
206 int pid_max;
207 unsigned long *pids;
210 enum {
211 TRACE_PIDS = BIT(0),
212 TRACE_NO_PIDS = BIT(1),
215 static inline bool pid_type_enabled(int type, struct trace_pid_list *pid_list,
216 struct trace_pid_list *no_pid_list)
218 /* Return true if the pid list in type has pids */
219 return ((type & TRACE_PIDS) && pid_list) ||
220 ((type & TRACE_NO_PIDS) && no_pid_list);
223 static inline bool still_need_pid_events(int type, struct trace_pid_list *pid_list,
224 struct trace_pid_list *no_pid_list)
227 * Turning off what is in @type, return true if the "other"
228 * pid list, still has pids in it.
230 return (!(type & TRACE_PIDS) && pid_list) ||
231 (!(type & TRACE_NO_PIDS) && no_pid_list);
234 typedef bool (*cond_update_fn_t)(struct trace_array *tr, void *cond_data);
237 * struct cond_snapshot - conditional snapshot data and callback
239 * The cond_snapshot structure encapsulates a callback function and
240 * data associated with the snapshot for a given tracing instance.
242 * When a snapshot is taken conditionally, by invoking
243 * tracing_snapshot_cond(tr, cond_data), the cond_data passed in is
244 * passed in turn to the cond_snapshot.update() function. That data
245 * can be compared by the update() implementation with the cond_data
246 * contained wihin the struct cond_snapshot instance associated with
247 * the trace_array. Because the tr->max_lock is held throughout the
248 * update() call, the update() function can directly retrieve the
249 * cond_snapshot and cond_data associated with the per-instance
250 * snapshot associated with the trace_array.
252 * The cond_snapshot.update() implementation can save data to be
253 * associated with the snapshot if it decides to, and returns 'true'
254 * in that case, or it returns 'false' if the conditional snapshot
255 * shouldn't be taken.
257 * The cond_snapshot instance is created and associated with the
258 * user-defined cond_data by tracing_cond_snapshot_enable().
259 * Likewise, the cond_snapshot instance is destroyed and is no longer
260 * associated with the trace instance by
261 * tracing_cond_snapshot_disable().
263 * The method below is required.
265 * @update: When a conditional snapshot is invoked, the update()
266 * callback function is invoked with the tr->max_lock held. The
267 * update() implementation signals whether or not to actually
268 * take the snapshot, by returning 'true' if so, 'false' if no
269 * snapshot should be taken. Because the max_lock is held for
270 * the duration of update(), the implementation is safe to
271 * directly retrieven and save any implementation data it needs
272 * to in association with the snapshot.
274 struct cond_snapshot {
275 void *cond_data;
276 cond_update_fn_t update;
280 * The trace array - an array of per-CPU trace arrays. This is the
281 * highest level data structure that individual tracers deal with.
282 * They have on/off state as well:
284 struct trace_array {
285 struct list_head list;
286 char *name;
287 struct array_buffer array_buffer;
288 #ifdef CONFIG_TRACER_MAX_TRACE
290 * The max_buffer is used to snapshot the trace when a maximum
291 * latency is reached, or when the user initiates a snapshot.
292 * Some tracers will use this to store a maximum trace while
293 * it continues examining live traces.
295 * The buffers for the max_buffer are set up the same as the array_buffer
296 * When a snapshot is taken, the buffer of the max_buffer is swapped
297 * with the buffer of the array_buffer and the buffers are reset for
298 * the array_buffer so the tracing can continue.
300 struct array_buffer max_buffer;
301 bool allocated_snapshot;
302 #endif
303 #if defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)
304 unsigned long max_latency;
305 #ifdef CONFIG_FSNOTIFY
306 struct dentry *d_max_latency;
307 struct work_struct fsnotify_work;
308 struct irq_work fsnotify_irqwork;
309 #endif
310 #endif
311 struct trace_pid_list __rcu *filtered_pids;
312 struct trace_pid_list __rcu *filtered_no_pids;
314 * max_lock is used to protect the swapping of buffers
315 * when taking a max snapshot. The buffers themselves are
316 * protected by per_cpu spinlocks. But the action of the swap
317 * needs its own lock.
319 * This is defined as a arch_spinlock_t in order to help
320 * with performance when lockdep debugging is enabled.
322 * It is also used in other places outside the update_max_tr
323 * so it needs to be defined outside of the
324 * CONFIG_TRACER_MAX_TRACE.
326 arch_spinlock_t max_lock;
327 int buffer_disabled;
328 #ifdef CONFIG_FTRACE_SYSCALLS
329 int sys_refcount_enter;
330 int sys_refcount_exit;
331 struct trace_event_file __rcu *enter_syscall_files[NR_syscalls];
332 struct trace_event_file __rcu *exit_syscall_files[NR_syscalls];
333 #endif
334 int stop_count;
335 int clock_id;
336 int nr_topts;
337 bool clear_trace;
338 int buffer_percent;
339 unsigned int n_err_log_entries;
340 struct tracer *current_trace;
341 unsigned int trace_flags;
342 unsigned char trace_flags_index[TRACE_FLAGS_MAX_SIZE];
343 unsigned int flags;
344 raw_spinlock_t start_lock;
345 struct list_head err_log;
346 struct dentry *dir;
347 struct dentry *options;
348 struct dentry *percpu_dir;
349 struct dentry *event_dir;
350 struct trace_options *topts;
351 struct list_head systems;
352 struct list_head events;
353 struct trace_event_file *trace_marker_file;
354 cpumask_var_t tracing_cpumask; /* only trace on set CPUs */
355 int ref;
356 #ifdef CONFIG_FUNCTION_TRACER
357 struct ftrace_ops *ops;
358 struct trace_pid_list __rcu *function_pids;
359 struct trace_pid_list __rcu *function_no_pids;
360 #ifdef CONFIG_DYNAMIC_FTRACE
361 /* All of these are protected by the ftrace_lock */
362 struct list_head func_probes;
363 struct list_head mod_trace;
364 struct list_head mod_notrace;
365 #endif
366 /* function tracing enabled */
367 int function_enabled;
368 #endif
369 int time_stamp_abs_ref;
370 struct list_head hist_vars;
371 #ifdef CONFIG_TRACER_SNAPSHOT
372 struct cond_snapshot *cond_snapshot;
373 #endif
376 enum {
377 TRACE_ARRAY_FL_GLOBAL = (1 << 0)
380 extern struct list_head ftrace_trace_arrays;
382 extern struct mutex trace_types_lock;
384 extern int trace_array_get(struct trace_array *tr);
385 extern int tracing_check_open_get_tr(struct trace_array *tr);
386 extern struct trace_array *trace_array_find(const char *instance);
387 extern struct trace_array *trace_array_find_get(const char *instance);
389 extern int tracing_set_time_stamp_abs(struct trace_array *tr, bool abs);
390 extern int tracing_set_clock(struct trace_array *tr, const char *clockstr);
392 extern bool trace_clock_in_ns(struct trace_array *tr);
395 * The global tracer (top) should be the first trace array added,
396 * but we check the flag anyway.
398 static inline struct trace_array *top_trace_array(void)
400 struct trace_array *tr;
402 if (list_empty(&ftrace_trace_arrays))
403 return NULL;
405 tr = list_entry(ftrace_trace_arrays.prev,
406 typeof(*tr), list);
407 WARN_ON(!(tr->flags & TRACE_ARRAY_FL_GLOBAL));
408 return tr;
411 #define FTRACE_CMP_TYPE(var, type) \
412 __builtin_types_compatible_p(typeof(var), type *)
414 #undef IF_ASSIGN
415 #define IF_ASSIGN(var, entry, etype, id) \
416 if (FTRACE_CMP_TYPE(var, etype)) { \
417 var = (typeof(var))(entry); \
418 WARN_ON(id != 0 && (entry)->type != id); \
419 break; \
422 /* Will cause compile errors if type is not found. */
423 extern void __ftrace_bad_type(void);
426 * The trace_assign_type is a verifier that the entry type is
427 * the same as the type being assigned. To add new types simply
428 * add a line with the following format:
430 * IF_ASSIGN(var, ent, type, id);
432 * Where "type" is the trace type that includes the trace_entry
433 * as the "ent" item. And "id" is the trace identifier that is
434 * used in the trace_type enum.
436 * If the type can have more than one id, then use zero.
438 #define trace_assign_type(var, ent) \
439 do { \
440 IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN); \
441 IF_ASSIGN(var, ent, struct ctx_switch_entry, 0); \
442 IF_ASSIGN(var, ent, struct stack_entry, TRACE_STACK); \
443 IF_ASSIGN(var, ent, struct userstack_entry, TRACE_USER_STACK);\
444 IF_ASSIGN(var, ent, struct print_entry, TRACE_PRINT); \
445 IF_ASSIGN(var, ent, struct bprint_entry, TRACE_BPRINT); \
446 IF_ASSIGN(var, ent, struct bputs_entry, TRACE_BPUTS); \
447 IF_ASSIGN(var, ent, struct hwlat_entry, TRACE_HWLAT); \
448 IF_ASSIGN(var, ent, struct raw_data_entry, TRACE_RAW_DATA);\
449 IF_ASSIGN(var, ent, struct trace_mmiotrace_rw, \
450 TRACE_MMIO_RW); \
451 IF_ASSIGN(var, ent, struct trace_mmiotrace_map, \
452 TRACE_MMIO_MAP); \
453 IF_ASSIGN(var, ent, struct trace_branch, TRACE_BRANCH); \
454 IF_ASSIGN(var, ent, struct ftrace_graph_ent_entry, \
455 TRACE_GRAPH_ENT); \
456 IF_ASSIGN(var, ent, struct ftrace_graph_ret_entry, \
457 TRACE_GRAPH_RET); \
458 __ftrace_bad_type(); \
459 } while (0)
462 * An option specific to a tracer. This is a boolean value.
463 * The bit is the bit index that sets its value on the
464 * flags value in struct tracer_flags.
466 struct tracer_opt {
467 const char *name; /* Will appear on the trace_options file */
468 u32 bit; /* Mask assigned in val field in tracer_flags */
472 * The set of specific options for a tracer. Your tracer
473 * have to set the initial value of the flags val.
475 struct tracer_flags {
476 u32 val;
477 struct tracer_opt *opts;
478 struct tracer *trace;
481 /* Makes more easy to define a tracer opt */
482 #define TRACER_OPT(s, b) .name = #s, .bit = b
485 struct trace_option_dentry {
486 struct tracer_opt *opt;
487 struct tracer_flags *flags;
488 struct trace_array *tr;
489 struct dentry *entry;
493 * struct tracer - a specific tracer and its callbacks to interact with tracefs
494 * @name: the name chosen to select it on the available_tracers file
495 * @init: called when one switches to this tracer (echo name > current_tracer)
496 * @reset: called when one switches to another tracer
497 * @start: called when tracing is unpaused (echo 1 > tracing_on)
498 * @stop: called when tracing is paused (echo 0 > tracing_on)
499 * @update_thresh: called when tracing_thresh is updated
500 * @open: called when the trace file is opened
501 * @pipe_open: called when the trace_pipe file is opened
502 * @close: called when the trace file is released
503 * @pipe_close: called when the trace_pipe file is released
504 * @read: override the default read callback on trace_pipe
505 * @splice_read: override the default splice_read callback on trace_pipe
506 * @selftest: selftest to run on boot (see trace_selftest.c)
507 * @print_headers: override the first lines that describe your columns
508 * @print_line: callback that prints a trace
509 * @set_flag: signals one of your private flags changed (trace_options file)
510 * @flags: your private flags
512 struct tracer {
513 const char *name;
514 int (*init)(struct trace_array *tr);
515 void (*reset)(struct trace_array *tr);
516 void (*start)(struct trace_array *tr);
517 void (*stop)(struct trace_array *tr);
518 int (*update_thresh)(struct trace_array *tr);
519 void (*open)(struct trace_iterator *iter);
520 void (*pipe_open)(struct trace_iterator *iter);
521 void (*close)(struct trace_iterator *iter);
522 void (*pipe_close)(struct trace_iterator *iter);
523 ssize_t (*read)(struct trace_iterator *iter,
524 struct file *filp, char __user *ubuf,
525 size_t cnt, loff_t *ppos);
526 ssize_t (*splice_read)(struct trace_iterator *iter,
527 struct file *filp,
528 loff_t *ppos,
529 struct pipe_inode_info *pipe,
530 size_t len,
531 unsigned int flags);
532 #ifdef CONFIG_FTRACE_STARTUP_TEST
533 int (*selftest)(struct tracer *trace,
534 struct trace_array *tr);
535 #endif
536 void (*print_header)(struct seq_file *m);
537 enum print_line_t (*print_line)(struct trace_iterator *iter);
538 /* If you handled the flag setting, return 0 */
539 int (*set_flag)(struct trace_array *tr,
540 u32 old_flags, u32 bit, int set);
541 /* Return 0 if OK with change, else return non-zero */
542 int (*flag_changed)(struct trace_array *tr,
543 u32 mask, int set);
544 struct tracer *next;
545 struct tracer_flags *flags;
546 int enabled;
547 int ref;
548 bool print_max;
549 bool allow_instances;
550 #ifdef CONFIG_TRACER_MAX_TRACE
551 bool use_max_tr;
552 #endif
553 /* True if tracer cannot be enabled in kernel param */
554 bool noboot;
558 /* Only current can touch trace_recursion */
561 * For function tracing recursion:
562 * The order of these bits are important.
564 * When function tracing occurs, the following steps are made:
565 * If arch does not support a ftrace feature:
566 * call internal function (uses INTERNAL bits) which calls...
567 * If callback is registered to the "global" list, the list
568 * function is called and recursion checks the GLOBAL bits.
569 * then this function calls...
570 * The function callback, which can use the FTRACE bits to
571 * check for recursion.
573 * Now if the arch does not suppport a feature, and it calls
574 * the global list function which calls the ftrace callback
575 * all three of these steps will do a recursion protection.
576 * There's no reason to do one if the previous caller already
577 * did. The recursion that we are protecting against will
578 * go through the same steps again.
580 * To prevent the multiple recursion checks, if a recursion
581 * bit is set that is higher than the MAX bit of the current
582 * check, then we know that the check was made by the previous
583 * caller, and we can skip the current check.
585 enum {
586 /* Function recursion bits */
587 TRACE_FTRACE_BIT,
588 TRACE_FTRACE_NMI_BIT,
589 TRACE_FTRACE_IRQ_BIT,
590 TRACE_FTRACE_SIRQ_BIT,
592 /* INTERNAL_BITs must be greater than FTRACE_BITs */
593 TRACE_INTERNAL_BIT,
594 TRACE_INTERNAL_NMI_BIT,
595 TRACE_INTERNAL_IRQ_BIT,
596 TRACE_INTERNAL_SIRQ_BIT,
598 TRACE_BRANCH_BIT,
600 * Abuse of the trace_recursion.
601 * As we need a way to maintain state if we are tracing the function
602 * graph in irq because we want to trace a particular function that
603 * was called in irq context but we have irq tracing off. Since this
604 * can only be modified by current, we can reuse trace_recursion.
606 TRACE_IRQ_BIT,
608 /* Set if the function is in the set_graph_function file */
609 TRACE_GRAPH_BIT,
612 * In the very unlikely case that an interrupt came in
613 * at a start of graph tracing, and we want to trace
614 * the function in that interrupt, the depth can be greater
615 * than zero, because of the preempted start of a previous
616 * trace. In an even more unlikely case, depth could be 2
617 * if a softirq interrupted the start of graph tracing,
618 * followed by an interrupt preempting a start of graph
619 * tracing in the softirq, and depth can even be 3
620 * if an NMI came in at the start of an interrupt function
621 * that preempted a softirq start of a function that
622 * preempted normal context!!!! Luckily, it can't be
623 * greater than 3, so the next two bits are a mask
624 * of what the depth is when we set TRACE_GRAPH_BIT
627 TRACE_GRAPH_DEPTH_START_BIT,
628 TRACE_GRAPH_DEPTH_END_BIT,
631 * To implement set_graph_notrace, if this bit is set, we ignore
632 * function graph tracing of called functions, until the return
633 * function is called to clear it.
635 TRACE_GRAPH_NOTRACE_BIT,
638 #define trace_recursion_set(bit) do { (current)->trace_recursion |= (1<<(bit)); } while (0)
639 #define trace_recursion_clear(bit) do { (current)->trace_recursion &= ~(1<<(bit)); } while (0)
640 #define trace_recursion_test(bit) ((current)->trace_recursion & (1<<(bit)))
642 #define trace_recursion_depth() \
643 (((current)->trace_recursion >> TRACE_GRAPH_DEPTH_START_BIT) & 3)
644 #define trace_recursion_set_depth(depth) \
645 do { \
646 current->trace_recursion &= \
647 ~(3 << TRACE_GRAPH_DEPTH_START_BIT); \
648 current->trace_recursion |= \
649 ((depth) & 3) << TRACE_GRAPH_DEPTH_START_BIT; \
650 } while (0)
652 #define TRACE_CONTEXT_BITS 4
654 #define TRACE_FTRACE_START TRACE_FTRACE_BIT
655 #define TRACE_FTRACE_MAX ((1 << (TRACE_FTRACE_START + TRACE_CONTEXT_BITS)) - 1)
657 #define TRACE_LIST_START TRACE_INTERNAL_BIT
658 #define TRACE_LIST_MAX ((1 << (TRACE_LIST_START + TRACE_CONTEXT_BITS)) - 1)
660 #define TRACE_CONTEXT_MASK TRACE_LIST_MAX
662 static __always_inline int trace_get_context_bit(void)
664 int bit;
666 if (in_interrupt()) {
667 if (in_nmi())
668 bit = 0;
670 else if (in_irq())
671 bit = 1;
672 else
673 bit = 2;
674 } else
675 bit = 3;
677 return bit;
680 static __always_inline int trace_test_and_set_recursion(int start, int max)
682 unsigned int val = current->trace_recursion;
683 int bit;
685 /* A previous recursion check was made */
686 if ((val & TRACE_CONTEXT_MASK) > max)
687 return 0;
689 bit = trace_get_context_bit() + start;
690 if (unlikely(val & (1 << bit)))
691 return -1;
693 val |= 1 << bit;
694 current->trace_recursion = val;
695 barrier();
697 return bit;
700 static __always_inline void trace_clear_recursion(int bit)
702 unsigned int val = current->trace_recursion;
704 if (!bit)
705 return;
707 bit = 1 << bit;
708 val &= ~bit;
710 barrier();
711 current->trace_recursion = val;
714 static inline struct ring_buffer_iter *
715 trace_buffer_iter(struct trace_iterator *iter, int cpu)
717 return iter->buffer_iter ? iter->buffer_iter[cpu] : NULL;
720 int tracer_init(struct tracer *t, struct trace_array *tr);
721 int tracing_is_enabled(void);
722 void tracing_reset_online_cpus(struct array_buffer *buf);
723 void tracing_reset_current(int cpu);
724 void tracing_reset_all_online_cpus(void);
725 int tracing_open_generic(struct inode *inode, struct file *filp);
726 int tracing_open_generic_tr(struct inode *inode, struct file *filp);
727 bool tracing_is_disabled(void);
728 bool tracer_tracing_is_on(struct trace_array *tr);
729 void tracer_tracing_on(struct trace_array *tr);
730 void tracer_tracing_off(struct trace_array *tr);
731 struct dentry *trace_create_file(const char *name,
732 umode_t mode,
733 struct dentry *parent,
734 void *data,
735 const struct file_operations *fops);
737 struct dentry *tracing_init_dentry(void);
739 struct ring_buffer_event;
741 struct ring_buffer_event *
742 trace_buffer_lock_reserve(struct trace_buffer *buffer,
743 int type,
744 unsigned long len,
745 unsigned long flags,
746 int pc);
748 struct trace_entry *tracing_get_trace_entry(struct trace_array *tr,
749 struct trace_array_cpu *data);
751 struct trace_entry *trace_find_next_entry(struct trace_iterator *iter,
752 int *ent_cpu, u64 *ent_ts);
754 void trace_buffer_unlock_commit_nostack(struct trace_buffer *buffer,
755 struct ring_buffer_event *event);
757 int trace_empty(struct trace_iterator *iter);
759 void *trace_find_next_entry_inc(struct trace_iterator *iter);
761 void trace_init_global_iter(struct trace_iterator *iter);
763 void tracing_iter_reset(struct trace_iterator *iter, int cpu);
765 unsigned long trace_total_entries_cpu(struct trace_array *tr, int cpu);
766 unsigned long trace_total_entries(struct trace_array *tr);
768 void trace_function(struct trace_array *tr,
769 unsigned long ip,
770 unsigned long parent_ip,
771 unsigned long flags, int pc);
772 void trace_graph_function(struct trace_array *tr,
773 unsigned long ip,
774 unsigned long parent_ip,
775 unsigned long flags, int pc);
776 void trace_latency_header(struct seq_file *m);
777 void trace_default_header(struct seq_file *m);
778 void print_trace_header(struct seq_file *m, struct trace_iterator *iter);
779 int trace_empty(struct trace_iterator *iter);
781 void trace_graph_return(struct ftrace_graph_ret *trace);
782 int trace_graph_entry(struct ftrace_graph_ent *trace);
783 void set_graph_array(struct trace_array *tr);
785 void tracing_start_cmdline_record(void);
786 void tracing_stop_cmdline_record(void);
787 void tracing_start_tgid_record(void);
788 void tracing_stop_tgid_record(void);
790 int register_tracer(struct tracer *type);
791 int is_tracing_stopped(void);
793 loff_t tracing_lseek(struct file *file, loff_t offset, int whence);
795 extern cpumask_var_t __read_mostly tracing_buffer_mask;
797 #define for_each_tracing_cpu(cpu) \
798 for_each_cpu(cpu, tracing_buffer_mask)
800 extern unsigned long nsecs_to_usecs(unsigned long nsecs);
802 extern unsigned long tracing_thresh;
804 /* PID filtering */
806 extern int pid_max;
808 bool trace_find_filtered_pid(struct trace_pid_list *filtered_pids,
809 pid_t search_pid);
810 bool trace_ignore_this_task(struct trace_pid_list *filtered_pids,
811 struct trace_pid_list *filtered_no_pids,
812 struct task_struct *task);
813 void trace_filter_add_remove_task(struct trace_pid_list *pid_list,
814 struct task_struct *self,
815 struct task_struct *task);
816 void *trace_pid_next(struct trace_pid_list *pid_list, void *v, loff_t *pos);
817 void *trace_pid_start(struct trace_pid_list *pid_list, loff_t *pos);
818 int trace_pid_show(struct seq_file *m, void *v);
819 void trace_free_pid_list(struct trace_pid_list *pid_list);
820 int trace_pid_write(struct trace_pid_list *filtered_pids,
821 struct trace_pid_list **new_pid_list,
822 const char __user *ubuf, size_t cnt);
824 #ifdef CONFIG_TRACER_MAX_TRACE
825 void update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu,
826 void *cond_data);
827 void update_max_tr_single(struct trace_array *tr,
828 struct task_struct *tsk, int cpu);
829 #endif /* CONFIG_TRACER_MAX_TRACE */
831 #if (defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)) && \
832 defined(CONFIG_FSNOTIFY)
834 void latency_fsnotify(struct trace_array *tr);
836 #else
838 static inline void latency_fsnotify(struct trace_array *tr) { }
840 #endif
842 #ifdef CONFIG_STACKTRACE
843 void __trace_stack(struct trace_array *tr, unsigned long flags, int skip,
844 int pc);
845 #else
846 static inline void __trace_stack(struct trace_array *tr, unsigned long flags,
847 int skip, int pc)
850 #endif /* CONFIG_STACKTRACE */
852 extern u64 ftrace_now(int cpu);
854 extern void trace_find_cmdline(int pid, char comm[]);
855 extern int trace_find_tgid(int pid);
856 extern void trace_event_follow_fork(struct trace_array *tr, bool enable);
858 #ifdef CONFIG_DYNAMIC_FTRACE
859 extern unsigned long ftrace_update_tot_cnt;
860 extern unsigned long ftrace_number_of_pages;
861 extern unsigned long ftrace_number_of_groups;
862 void ftrace_init_trace_array(struct trace_array *tr);
863 #else
864 static inline void ftrace_init_trace_array(struct trace_array *tr) { }
865 #endif
866 #define DYN_FTRACE_TEST_NAME trace_selftest_dynamic_test_func
867 extern int DYN_FTRACE_TEST_NAME(void);
868 #define DYN_FTRACE_TEST_NAME2 trace_selftest_dynamic_test_func2
869 extern int DYN_FTRACE_TEST_NAME2(void);
871 extern bool ring_buffer_expanded;
872 extern bool tracing_selftest_disabled;
874 #ifdef CONFIG_FTRACE_STARTUP_TEST
875 extern int trace_selftest_startup_function(struct tracer *trace,
876 struct trace_array *tr);
877 extern int trace_selftest_startup_function_graph(struct tracer *trace,
878 struct trace_array *tr);
879 extern int trace_selftest_startup_irqsoff(struct tracer *trace,
880 struct trace_array *tr);
881 extern int trace_selftest_startup_preemptoff(struct tracer *trace,
882 struct trace_array *tr);
883 extern int trace_selftest_startup_preemptirqsoff(struct tracer *trace,
884 struct trace_array *tr);
885 extern int trace_selftest_startup_wakeup(struct tracer *trace,
886 struct trace_array *tr);
887 extern int trace_selftest_startup_nop(struct tracer *trace,
888 struct trace_array *tr);
889 extern int trace_selftest_startup_branch(struct tracer *trace,
890 struct trace_array *tr);
892 * Tracer data references selftest functions that only occur
893 * on boot up. These can be __init functions. Thus, when selftests
894 * are enabled, then the tracers need to reference __init functions.
896 #define __tracer_data __refdata
897 #else
898 /* Tracers are seldom changed. Optimize when selftests are disabled. */
899 #define __tracer_data __read_mostly
900 #endif /* CONFIG_FTRACE_STARTUP_TEST */
902 extern void *head_page(struct trace_array_cpu *data);
903 extern unsigned long long ns2usecs(u64 nsec);
904 extern int
905 trace_vbprintk(unsigned long ip, const char *fmt, va_list args);
906 extern int
907 trace_vprintk(unsigned long ip, const char *fmt, va_list args);
908 extern int
909 trace_array_vprintk(struct trace_array *tr,
910 unsigned long ip, const char *fmt, va_list args);
911 int trace_array_printk_buf(struct trace_buffer *buffer,
912 unsigned long ip, const char *fmt, ...);
913 void trace_printk_seq(struct trace_seq *s);
914 enum print_line_t print_trace_line(struct trace_iterator *iter);
916 extern char trace_find_mark(unsigned long long duration);
918 struct ftrace_hash;
920 struct ftrace_mod_load {
921 struct list_head list;
922 char *func;
923 char *module;
924 int enable;
927 enum {
928 FTRACE_HASH_FL_MOD = (1 << 0),
931 struct ftrace_hash {
932 unsigned long size_bits;
933 struct hlist_head *buckets;
934 unsigned long count;
935 unsigned long flags;
936 struct rcu_head rcu;
939 struct ftrace_func_entry *
940 ftrace_lookup_ip(struct ftrace_hash *hash, unsigned long ip);
942 static __always_inline bool ftrace_hash_empty(struct ftrace_hash *hash)
944 return !hash || !(hash->count || (hash->flags & FTRACE_HASH_FL_MOD));
947 /* Standard output formatting function used for function return traces */
948 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
950 /* Flag options */
951 #define TRACE_GRAPH_PRINT_OVERRUN 0x1
952 #define TRACE_GRAPH_PRINT_CPU 0x2
953 #define TRACE_GRAPH_PRINT_OVERHEAD 0x4
954 #define TRACE_GRAPH_PRINT_PROC 0x8
955 #define TRACE_GRAPH_PRINT_DURATION 0x10
956 #define TRACE_GRAPH_PRINT_ABS_TIME 0x20
957 #define TRACE_GRAPH_PRINT_REL_TIME 0x40
958 #define TRACE_GRAPH_PRINT_IRQS 0x80
959 #define TRACE_GRAPH_PRINT_TAIL 0x100
960 #define TRACE_GRAPH_SLEEP_TIME 0x200
961 #define TRACE_GRAPH_GRAPH_TIME 0x400
962 #define TRACE_GRAPH_PRINT_FILL_SHIFT 28
963 #define TRACE_GRAPH_PRINT_FILL_MASK (0x3 << TRACE_GRAPH_PRINT_FILL_SHIFT)
965 extern void ftrace_graph_sleep_time_control(bool enable);
967 #ifdef CONFIG_FUNCTION_PROFILER
968 extern void ftrace_graph_graph_time_control(bool enable);
969 #else
970 static inline void ftrace_graph_graph_time_control(bool enable) { }
971 #endif
973 extern enum print_line_t
974 print_graph_function_flags(struct trace_iterator *iter, u32 flags);
975 extern void print_graph_headers_flags(struct seq_file *s, u32 flags);
976 extern void
977 trace_print_graph_duration(unsigned long long duration, struct trace_seq *s);
978 extern void graph_trace_open(struct trace_iterator *iter);
979 extern void graph_trace_close(struct trace_iterator *iter);
980 extern int __trace_graph_entry(struct trace_array *tr,
981 struct ftrace_graph_ent *trace,
982 unsigned long flags, int pc);
983 extern void __trace_graph_return(struct trace_array *tr,
984 struct ftrace_graph_ret *trace,
985 unsigned long flags, int pc);
987 #ifdef CONFIG_DYNAMIC_FTRACE
988 extern struct ftrace_hash __rcu *ftrace_graph_hash;
989 extern struct ftrace_hash __rcu *ftrace_graph_notrace_hash;
991 static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)
993 unsigned long addr = trace->func;
994 int ret = 0;
995 struct ftrace_hash *hash;
997 preempt_disable_notrace();
1000 * Have to open code "rcu_dereference_sched()" because the
1001 * function graph tracer can be called when RCU is not
1002 * "watching".
1003 * Protected with schedule_on_each_cpu(ftrace_sync)
1005 hash = rcu_dereference_protected(ftrace_graph_hash, !preemptible());
1007 if (ftrace_hash_empty(hash)) {
1008 ret = 1;
1009 goto out;
1012 if (ftrace_lookup_ip(hash, addr)) {
1015 * This needs to be cleared on the return functions
1016 * when the depth is zero.
1018 trace_recursion_set(TRACE_GRAPH_BIT);
1019 trace_recursion_set_depth(trace->depth);
1022 * If no irqs are to be traced, but a set_graph_function
1023 * is set, and called by an interrupt handler, we still
1024 * want to trace it.
1026 if (in_irq())
1027 trace_recursion_set(TRACE_IRQ_BIT);
1028 else
1029 trace_recursion_clear(TRACE_IRQ_BIT);
1030 ret = 1;
1033 out:
1034 preempt_enable_notrace();
1035 return ret;
1038 static inline void ftrace_graph_addr_finish(struct ftrace_graph_ret *trace)
1040 if (trace_recursion_test(TRACE_GRAPH_BIT) &&
1041 trace->depth == trace_recursion_depth())
1042 trace_recursion_clear(TRACE_GRAPH_BIT);
1045 static inline int ftrace_graph_notrace_addr(unsigned long addr)
1047 int ret = 0;
1048 struct ftrace_hash *notrace_hash;
1050 preempt_disable_notrace();
1053 * Have to open code "rcu_dereference_sched()" because the
1054 * function graph tracer can be called when RCU is not
1055 * "watching".
1056 * Protected with schedule_on_each_cpu(ftrace_sync)
1058 notrace_hash = rcu_dereference_protected(ftrace_graph_notrace_hash,
1059 !preemptible());
1061 if (ftrace_lookup_ip(notrace_hash, addr))
1062 ret = 1;
1064 preempt_enable_notrace();
1065 return ret;
1067 #else
1068 static inline int ftrace_graph_addr(struct ftrace_graph_ent *trace)
1070 return 1;
1073 static inline int ftrace_graph_notrace_addr(unsigned long addr)
1075 return 0;
1077 static inline void ftrace_graph_addr_finish(struct ftrace_graph_ret *trace)
1079 #endif /* CONFIG_DYNAMIC_FTRACE */
1081 extern unsigned int fgraph_max_depth;
1083 static inline bool ftrace_graph_ignore_func(struct ftrace_graph_ent *trace)
1085 /* trace it when it is-nested-in or is a function enabled. */
1086 return !(trace_recursion_test(TRACE_GRAPH_BIT) ||
1087 ftrace_graph_addr(trace)) ||
1088 (trace->depth < 0) ||
1089 (fgraph_max_depth && trace->depth >= fgraph_max_depth);
1092 #else /* CONFIG_FUNCTION_GRAPH_TRACER */
1093 static inline enum print_line_t
1094 print_graph_function_flags(struct trace_iterator *iter, u32 flags)
1096 return TRACE_TYPE_UNHANDLED;
1098 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
1100 extern struct list_head ftrace_pids;
1102 #ifdef CONFIG_FUNCTION_TRACER
1103 struct ftrace_func_command {
1104 struct list_head list;
1105 char *name;
1106 int (*func)(struct trace_array *tr,
1107 struct ftrace_hash *hash,
1108 char *func, char *cmd,
1109 char *params, int enable);
1111 extern bool ftrace_filter_param __initdata;
1112 static inline int ftrace_trace_task(struct trace_array *tr)
1114 return !this_cpu_read(tr->array_buffer.data->ftrace_ignore_pid);
1116 extern int ftrace_is_dead(void);
1117 int ftrace_create_function_files(struct trace_array *tr,
1118 struct dentry *parent);
1119 void ftrace_destroy_function_files(struct trace_array *tr);
1120 void ftrace_init_global_array_ops(struct trace_array *tr);
1121 void ftrace_init_array_ops(struct trace_array *tr, ftrace_func_t func);
1122 void ftrace_reset_array_ops(struct trace_array *tr);
1123 void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d_tracer);
1124 void ftrace_init_tracefs_toplevel(struct trace_array *tr,
1125 struct dentry *d_tracer);
1126 void ftrace_clear_pids(struct trace_array *tr);
1127 int init_function_trace(void);
1128 void ftrace_pid_follow_fork(struct trace_array *tr, bool enable);
1129 #else
1130 static inline int ftrace_trace_task(struct trace_array *tr)
1132 return 1;
1134 static inline int ftrace_is_dead(void) { return 0; }
1135 static inline int
1136 ftrace_create_function_files(struct trace_array *tr,
1137 struct dentry *parent)
1139 return 0;
1141 static inline void ftrace_destroy_function_files(struct trace_array *tr) { }
1142 static inline __init void
1143 ftrace_init_global_array_ops(struct trace_array *tr) { }
1144 static inline void ftrace_reset_array_ops(struct trace_array *tr) { }
1145 static inline void ftrace_init_tracefs(struct trace_array *tr, struct dentry *d) { }
1146 static inline void ftrace_init_tracefs_toplevel(struct trace_array *tr, struct dentry *d) { }
1147 static inline void ftrace_clear_pids(struct trace_array *tr) { }
1148 static inline int init_function_trace(void) { return 0; }
1149 static inline void ftrace_pid_follow_fork(struct trace_array *tr, bool enable) { }
1150 /* ftace_func_t type is not defined, use macro instead of static inline */
1151 #define ftrace_init_array_ops(tr, func) do { } while (0)
1152 #endif /* CONFIG_FUNCTION_TRACER */
1154 #if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_DYNAMIC_FTRACE)
1156 struct ftrace_probe_ops {
1157 void (*func)(unsigned long ip,
1158 unsigned long parent_ip,
1159 struct trace_array *tr,
1160 struct ftrace_probe_ops *ops,
1161 void *data);
1162 int (*init)(struct ftrace_probe_ops *ops,
1163 struct trace_array *tr,
1164 unsigned long ip, void *init_data,
1165 void **data);
1166 void (*free)(struct ftrace_probe_ops *ops,
1167 struct trace_array *tr,
1168 unsigned long ip, void *data);
1169 int (*print)(struct seq_file *m,
1170 unsigned long ip,
1171 struct ftrace_probe_ops *ops,
1172 void *data);
1175 struct ftrace_func_mapper;
1176 typedef int (*ftrace_mapper_func)(void *data);
1178 struct ftrace_func_mapper *allocate_ftrace_func_mapper(void);
1179 void **ftrace_func_mapper_find_ip(struct ftrace_func_mapper *mapper,
1180 unsigned long ip);
1181 int ftrace_func_mapper_add_ip(struct ftrace_func_mapper *mapper,
1182 unsigned long ip, void *data);
1183 void *ftrace_func_mapper_remove_ip(struct ftrace_func_mapper *mapper,
1184 unsigned long ip);
1185 void free_ftrace_func_mapper(struct ftrace_func_mapper *mapper,
1186 ftrace_mapper_func free_func);
1188 extern int
1189 register_ftrace_function_probe(char *glob, struct trace_array *tr,
1190 struct ftrace_probe_ops *ops, void *data);
1191 extern int
1192 unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr,
1193 struct ftrace_probe_ops *ops);
1194 extern void clear_ftrace_function_probes(struct trace_array *tr);
1196 int register_ftrace_command(struct ftrace_func_command *cmd);
1197 int unregister_ftrace_command(struct ftrace_func_command *cmd);
1199 void ftrace_create_filter_files(struct ftrace_ops *ops,
1200 struct dentry *parent);
1201 void ftrace_destroy_filter_files(struct ftrace_ops *ops);
1203 extern int ftrace_set_filter(struct ftrace_ops *ops, unsigned char *buf,
1204 int len, int reset);
1205 extern int ftrace_set_notrace(struct ftrace_ops *ops, unsigned char *buf,
1206 int len, int reset);
1207 #else
1208 struct ftrace_func_command;
1210 static inline __init int register_ftrace_command(struct ftrace_func_command *cmd)
1212 return -EINVAL;
1214 static inline __init int unregister_ftrace_command(char *cmd_name)
1216 return -EINVAL;
1218 static inline void clear_ftrace_function_probes(struct trace_array *tr)
1223 * The ops parameter passed in is usually undefined.
1224 * This must be a macro.
1226 #define ftrace_create_filter_files(ops, parent) do { } while (0)
1227 #define ftrace_destroy_filter_files(ops) do { } while (0)
1228 #endif /* CONFIG_FUNCTION_TRACER && CONFIG_DYNAMIC_FTRACE */
1230 bool ftrace_event_is_function(struct trace_event_call *call);
1233 * struct trace_parser - servers for reading the user input separated by spaces
1234 * @cont: set if the input is not complete - no final space char was found
1235 * @buffer: holds the parsed user input
1236 * @idx: user input length
1237 * @size: buffer size
1239 struct trace_parser {
1240 bool cont;
1241 char *buffer;
1242 unsigned idx;
1243 unsigned size;
1246 static inline bool trace_parser_loaded(struct trace_parser *parser)
1248 return (parser->idx != 0);
1251 static inline bool trace_parser_cont(struct trace_parser *parser)
1253 return parser->cont;
1256 static inline void trace_parser_clear(struct trace_parser *parser)
1258 parser->cont = false;
1259 parser->idx = 0;
1262 extern int trace_parser_get_init(struct trace_parser *parser, int size);
1263 extern void trace_parser_put(struct trace_parser *parser);
1264 extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
1265 size_t cnt, loff_t *ppos);
1268 * Only create function graph options if function graph is configured.
1270 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
1271 # define FGRAPH_FLAGS \
1272 C(DISPLAY_GRAPH, "display-graph"),
1273 #else
1274 # define FGRAPH_FLAGS
1275 #endif
1277 #ifdef CONFIG_BRANCH_TRACER
1278 # define BRANCH_FLAGS \
1279 C(BRANCH, "branch"),
1280 #else
1281 # define BRANCH_FLAGS
1282 #endif
1284 #ifdef CONFIG_FUNCTION_TRACER
1285 # define FUNCTION_FLAGS \
1286 C(FUNCTION, "function-trace"), \
1287 C(FUNC_FORK, "function-fork"),
1288 # define FUNCTION_DEFAULT_FLAGS TRACE_ITER_FUNCTION
1289 #else
1290 # define FUNCTION_FLAGS
1291 # define FUNCTION_DEFAULT_FLAGS 0UL
1292 # define TRACE_ITER_FUNC_FORK 0UL
1293 #endif
1295 #ifdef CONFIG_STACKTRACE
1296 # define STACK_FLAGS \
1297 C(STACKTRACE, "stacktrace"),
1298 #else
1299 # define STACK_FLAGS
1300 #endif
1303 * trace_iterator_flags is an enumeration that defines bit
1304 * positions into trace_flags that controls the output.
1306 * NOTE: These bits must match the trace_options array in
1307 * trace.c (this macro guarantees it).
1309 #define TRACE_FLAGS \
1310 C(PRINT_PARENT, "print-parent"), \
1311 C(SYM_OFFSET, "sym-offset"), \
1312 C(SYM_ADDR, "sym-addr"), \
1313 C(VERBOSE, "verbose"), \
1314 C(RAW, "raw"), \
1315 C(HEX, "hex"), \
1316 C(BIN, "bin"), \
1317 C(BLOCK, "block"), \
1318 C(PRINTK, "trace_printk"), \
1319 C(ANNOTATE, "annotate"), \
1320 C(USERSTACKTRACE, "userstacktrace"), \
1321 C(SYM_USEROBJ, "sym-userobj"), \
1322 C(PRINTK_MSGONLY, "printk-msg-only"), \
1323 C(CONTEXT_INFO, "context-info"), /* Print pid/cpu/time */ \
1324 C(LATENCY_FMT, "latency-format"), \
1325 C(RECORD_CMD, "record-cmd"), \
1326 C(RECORD_TGID, "record-tgid"), \
1327 C(OVERWRITE, "overwrite"), \
1328 C(STOP_ON_FREE, "disable_on_free"), \
1329 C(IRQ_INFO, "irq-info"), \
1330 C(MARKERS, "markers"), \
1331 C(EVENT_FORK, "event-fork"), \
1332 C(PAUSE_ON_TRACE, "pause-on-trace"), \
1333 FUNCTION_FLAGS \
1334 FGRAPH_FLAGS \
1335 STACK_FLAGS \
1336 BRANCH_FLAGS
1339 * By defining C, we can make TRACE_FLAGS a list of bit names
1340 * that will define the bits for the flag masks.
1342 #undef C
1343 #define C(a, b) TRACE_ITER_##a##_BIT
1345 enum trace_iterator_bits {
1346 TRACE_FLAGS
1347 /* Make sure we don't go more than we have bits for */
1348 TRACE_ITER_LAST_BIT
1352 * By redefining C, we can make TRACE_FLAGS a list of masks that
1353 * use the bits as defined above.
1355 #undef C
1356 #define C(a, b) TRACE_ITER_##a = (1 << TRACE_ITER_##a##_BIT)
1358 enum trace_iterator_flags { TRACE_FLAGS };
1361 * TRACE_ITER_SYM_MASK masks the options in trace_flags that
1362 * control the output of kernel symbols.
1364 #define TRACE_ITER_SYM_MASK \
1365 (TRACE_ITER_PRINT_PARENT|TRACE_ITER_SYM_OFFSET|TRACE_ITER_SYM_ADDR)
1367 extern struct tracer nop_trace;
1369 #ifdef CONFIG_BRANCH_TRACER
1370 extern int enable_branch_tracing(struct trace_array *tr);
1371 extern void disable_branch_tracing(void);
1372 static inline int trace_branch_enable(struct trace_array *tr)
1374 if (tr->trace_flags & TRACE_ITER_BRANCH)
1375 return enable_branch_tracing(tr);
1376 return 0;
1378 static inline void trace_branch_disable(void)
1380 /* due to races, always disable */
1381 disable_branch_tracing();
1383 #else
1384 static inline int trace_branch_enable(struct trace_array *tr)
1386 return 0;
1388 static inline void trace_branch_disable(void)
1391 #endif /* CONFIG_BRANCH_TRACER */
1393 /* set ring buffers to default size if not already done so */
1394 int tracing_update_buffers(void);
1396 struct ftrace_event_field {
1397 struct list_head link;
1398 const char *name;
1399 const char *type;
1400 int filter_type;
1401 int offset;
1402 int size;
1403 int is_signed;
1406 struct prog_entry;
1408 struct event_filter {
1409 struct prog_entry __rcu *prog;
1410 char *filter_string;
1413 struct event_subsystem {
1414 struct list_head list;
1415 const char *name;
1416 struct event_filter *filter;
1417 int ref_count;
1420 struct trace_subsystem_dir {
1421 struct list_head list;
1422 struct event_subsystem *subsystem;
1423 struct trace_array *tr;
1424 struct dentry *entry;
1425 int ref_count;
1426 int nr_events;
1429 extern int call_filter_check_discard(struct trace_event_call *call, void *rec,
1430 struct trace_buffer *buffer,
1431 struct ring_buffer_event *event);
1433 void trace_buffer_unlock_commit_regs(struct trace_array *tr,
1434 struct trace_buffer *buffer,
1435 struct ring_buffer_event *event,
1436 unsigned long flags, int pc,
1437 struct pt_regs *regs);
1439 static inline void trace_buffer_unlock_commit(struct trace_array *tr,
1440 struct trace_buffer *buffer,
1441 struct ring_buffer_event *event,
1442 unsigned long flags, int pc)
1444 trace_buffer_unlock_commit_regs(tr, buffer, event, flags, pc, NULL);
1447 DECLARE_PER_CPU(struct ring_buffer_event *, trace_buffered_event);
1448 DECLARE_PER_CPU(int, trace_buffered_event_cnt);
1449 void trace_buffered_event_disable(void);
1450 void trace_buffered_event_enable(void);
1452 static inline void
1453 __trace_event_discard_commit(struct trace_buffer *buffer,
1454 struct ring_buffer_event *event)
1456 if (this_cpu_read(trace_buffered_event) == event) {
1457 /* Simply release the temp buffer */
1458 this_cpu_dec(trace_buffered_event_cnt);
1459 return;
1461 ring_buffer_discard_commit(buffer, event);
1465 * Helper function for event_trigger_unlock_commit{_regs}().
1466 * If there are event triggers attached to this event that requires
1467 * filtering against its fields, then they wil be called as the
1468 * entry already holds the field information of the current event.
1470 * It also checks if the event should be discarded or not.
1471 * It is to be discarded if the event is soft disabled and the
1472 * event was only recorded to process triggers, or if the event
1473 * filter is active and this event did not match the filters.
1475 * Returns true if the event is discarded, false otherwise.
1477 static inline bool
1478 __event_trigger_test_discard(struct trace_event_file *file,
1479 struct trace_buffer *buffer,
1480 struct ring_buffer_event *event,
1481 void *entry,
1482 enum event_trigger_type *tt)
1484 unsigned long eflags = file->flags;
1486 if (eflags & EVENT_FILE_FL_TRIGGER_COND)
1487 *tt = event_triggers_call(file, entry, event);
1489 if (test_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &file->flags) ||
1490 (unlikely(file->flags & EVENT_FILE_FL_FILTERED) &&
1491 !filter_match_preds(file->filter, entry))) {
1492 __trace_event_discard_commit(buffer, event);
1493 return true;
1496 return false;
1500 * event_trigger_unlock_commit - handle triggers and finish event commit
1501 * @file: The file pointer assoctiated to the event
1502 * @buffer: The ring buffer that the event is being written to
1503 * @event: The event meta data in the ring buffer
1504 * @entry: The event itself
1505 * @irq_flags: The state of the interrupts at the start of the event
1506 * @pc: The state of the preempt count at the start of the event.
1508 * This is a helper function to handle triggers that require data
1509 * from the event itself. It also tests the event against filters and
1510 * if the event is soft disabled and should be discarded.
1512 static inline void
1513 event_trigger_unlock_commit(struct trace_event_file *file,
1514 struct trace_buffer *buffer,
1515 struct ring_buffer_event *event,
1516 void *entry, unsigned long irq_flags, int pc)
1518 enum event_trigger_type tt = ETT_NONE;
1520 if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
1521 trace_buffer_unlock_commit(file->tr, buffer, event, irq_flags, pc);
1523 if (tt)
1524 event_triggers_post_call(file, tt);
1528 * event_trigger_unlock_commit_regs - handle triggers and finish event commit
1529 * @file: The file pointer assoctiated to the event
1530 * @buffer: The ring buffer that the event is being written to
1531 * @event: The event meta data in the ring buffer
1532 * @entry: The event itself
1533 * @irq_flags: The state of the interrupts at the start of the event
1534 * @pc: The state of the preempt count at the start of the event.
1536 * This is a helper function to handle triggers that require data
1537 * from the event itself. It also tests the event against filters and
1538 * if the event is soft disabled and should be discarded.
1540 * Same as event_trigger_unlock_commit() but calls
1541 * trace_buffer_unlock_commit_regs() instead of trace_buffer_unlock_commit().
1543 static inline void
1544 event_trigger_unlock_commit_regs(struct trace_event_file *file,
1545 struct trace_buffer *buffer,
1546 struct ring_buffer_event *event,
1547 void *entry, unsigned long irq_flags, int pc,
1548 struct pt_regs *regs)
1550 enum event_trigger_type tt = ETT_NONE;
1552 if (!__event_trigger_test_discard(file, buffer, event, entry, &tt))
1553 trace_buffer_unlock_commit_regs(file->tr, buffer, event,
1554 irq_flags, pc, regs);
1556 if (tt)
1557 event_triggers_post_call(file, tt);
1560 #define FILTER_PRED_INVALID ((unsigned short)-1)
1561 #define FILTER_PRED_IS_RIGHT (1 << 15)
1562 #define FILTER_PRED_FOLD (1 << 15)
1565 * The max preds is the size of unsigned short with
1566 * two flags at the MSBs. One bit is used for both the IS_RIGHT
1567 * and FOLD flags. The other is reserved.
1569 * 2^14 preds is way more than enough.
1571 #define MAX_FILTER_PRED 16384
1573 struct filter_pred;
1574 struct regex;
1576 typedef int (*filter_pred_fn_t) (struct filter_pred *pred, void *event);
1578 typedef int (*regex_match_func)(char *str, struct regex *r, int len);
1580 enum regex_type {
1581 MATCH_FULL = 0,
1582 MATCH_FRONT_ONLY,
1583 MATCH_MIDDLE_ONLY,
1584 MATCH_END_ONLY,
1585 MATCH_GLOB,
1586 MATCH_INDEX,
1589 struct regex {
1590 char pattern[MAX_FILTER_STR_VAL];
1591 int len;
1592 int field_len;
1593 regex_match_func match;
1596 struct filter_pred {
1597 filter_pred_fn_t fn;
1598 u64 val;
1599 struct regex regex;
1600 unsigned short *ops;
1601 struct ftrace_event_field *field;
1602 int offset;
1603 int not;
1604 int op;
1607 static inline bool is_string_field(struct ftrace_event_field *field)
1609 return field->filter_type == FILTER_DYN_STRING ||
1610 field->filter_type == FILTER_STATIC_STRING ||
1611 field->filter_type == FILTER_PTR_STRING ||
1612 field->filter_type == FILTER_COMM;
1615 static inline bool is_function_field(struct ftrace_event_field *field)
1617 return field->filter_type == FILTER_TRACE_FN;
1620 extern enum regex_type
1621 filter_parse_regex(char *buff, int len, char **search, int *not);
1622 extern void print_event_filter(struct trace_event_file *file,
1623 struct trace_seq *s);
1624 extern int apply_event_filter(struct trace_event_file *file,
1625 char *filter_string);
1626 extern int apply_subsystem_event_filter(struct trace_subsystem_dir *dir,
1627 char *filter_string);
1628 extern void print_subsystem_event_filter(struct event_subsystem *system,
1629 struct trace_seq *s);
1630 extern int filter_assign_type(const char *type);
1631 extern int create_event_filter(struct trace_array *tr,
1632 struct trace_event_call *call,
1633 char *filter_str, bool set_str,
1634 struct event_filter **filterp);
1635 extern void free_event_filter(struct event_filter *filter);
1637 struct ftrace_event_field *
1638 trace_find_event_field(struct trace_event_call *call, char *name);
1640 extern void trace_event_enable_cmd_record(bool enable);
1641 extern void trace_event_enable_tgid_record(bool enable);
1643 extern int event_trace_init(void);
1644 extern int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr);
1645 extern int event_trace_del_tracer(struct trace_array *tr);
1647 extern struct trace_event_file *__find_event_file(struct trace_array *tr,
1648 const char *system,
1649 const char *event);
1650 extern struct trace_event_file *find_event_file(struct trace_array *tr,
1651 const char *system,
1652 const char *event);
1654 static inline void *event_file_data(struct file *filp)
1656 return READ_ONCE(file_inode(filp)->i_private);
1659 extern struct mutex event_mutex;
1660 extern struct list_head ftrace_events;
1662 extern const struct file_operations event_trigger_fops;
1663 extern const struct file_operations event_hist_fops;
1664 extern const struct file_operations event_hist_debug_fops;
1665 extern const struct file_operations event_inject_fops;
1667 #ifdef CONFIG_HIST_TRIGGERS
1668 extern int register_trigger_hist_cmd(void);
1669 extern int register_trigger_hist_enable_disable_cmds(void);
1670 #else
1671 static inline int register_trigger_hist_cmd(void) { return 0; }
1672 static inline int register_trigger_hist_enable_disable_cmds(void) { return 0; }
1673 #endif
1675 extern int register_trigger_cmds(void);
1676 extern void clear_event_triggers(struct trace_array *tr);
1678 struct event_trigger_data {
1679 unsigned long count;
1680 int ref;
1681 struct event_trigger_ops *ops;
1682 struct event_command *cmd_ops;
1683 struct event_filter __rcu *filter;
1684 char *filter_str;
1685 void *private_data;
1686 bool paused;
1687 bool paused_tmp;
1688 struct list_head list;
1689 char *name;
1690 struct list_head named_list;
1691 struct event_trigger_data *named_data;
1694 /* Avoid typos */
1695 #define ENABLE_EVENT_STR "enable_event"
1696 #define DISABLE_EVENT_STR "disable_event"
1697 #define ENABLE_HIST_STR "enable_hist"
1698 #define DISABLE_HIST_STR "disable_hist"
1700 struct enable_trigger_data {
1701 struct trace_event_file *file;
1702 bool enable;
1703 bool hist;
1706 extern int event_enable_trigger_print(struct seq_file *m,
1707 struct event_trigger_ops *ops,
1708 struct event_trigger_data *data);
1709 extern void event_enable_trigger_free(struct event_trigger_ops *ops,
1710 struct event_trigger_data *data);
1711 extern int event_enable_trigger_func(struct event_command *cmd_ops,
1712 struct trace_event_file *file,
1713 char *glob, char *cmd, char *param);
1714 extern int event_enable_register_trigger(char *glob,
1715 struct event_trigger_ops *ops,
1716 struct event_trigger_data *data,
1717 struct trace_event_file *file);
1718 extern void event_enable_unregister_trigger(char *glob,
1719 struct event_trigger_ops *ops,
1720 struct event_trigger_data *test,
1721 struct trace_event_file *file);
1722 extern void trigger_data_free(struct event_trigger_data *data);
1723 extern int event_trigger_init(struct event_trigger_ops *ops,
1724 struct event_trigger_data *data);
1725 extern int trace_event_trigger_enable_disable(struct trace_event_file *file,
1726 int trigger_enable);
1727 extern void update_cond_flag(struct trace_event_file *file);
1728 extern int set_trigger_filter(char *filter_str,
1729 struct event_trigger_data *trigger_data,
1730 struct trace_event_file *file);
1731 extern struct event_trigger_data *find_named_trigger(const char *name);
1732 extern bool is_named_trigger(struct event_trigger_data *test);
1733 extern int save_named_trigger(const char *name,
1734 struct event_trigger_data *data);
1735 extern void del_named_trigger(struct event_trigger_data *data);
1736 extern void pause_named_trigger(struct event_trigger_data *data);
1737 extern void unpause_named_trigger(struct event_trigger_data *data);
1738 extern void set_named_trigger_data(struct event_trigger_data *data,
1739 struct event_trigger_data *named_data);
1740 extern struct event_trigger_data *
1741 get_named_trigger_data(struct event_trigger_data *data);
1742 extern int register_event_command(struct event_command *cmd);
1743 extern int unregister_event_command(struct event_command *cmd);
1744 extern int register_trigger_hist_enable_disable_cmds(void);
1747 * struct event_trigger_ops - callbacks for trace event triggers
1749 * The methods in this structure provide per-event trigger hooks for
1750 * various trigger operations.
1752 * All the methods below, except for @init() and @free(), must be
1753 * implemented.
1755 * @func: The trigger 'probe' function called when the triggering
1756 * event occurs. The data passed into this callback is the data
1757 * that was supplied to the event_command @reg() function that
1758 * registered the trigger (see struct event_command) along with
1759 * the trace record, rec.
1761 * @init: An optional initialization function called for the trigger
1762 * when the trigger is registered (via the event_command reg()
1763 * function). This can be used to perform per-trigger
1764 * initialization such as incrementing a per-trigger reference
1765 * count, for instance. This is usually implemented by the
1766 * generic utility function @event_trigger_init() (see
1767 * trace_event_triggers.c).
1769 * @free: An optional de-initialization function called for the
1770 * trigger when the trigger is unregistered (via the
1771 * event_command @reg() function). This can be used to perform
1772 * per-trigger de-initialization such as decrementing a
1773 * per-trigger reference count and freeing corresponding trigger
1774 * data, for instance. This is usually implemented by the
1775 * generic utility function @event_trigger_free() (see
1776 * trace_event_triggers.c).
1778 * @print: The callback function invoked to have the trigger print
1779 * itself. This is usually implemented by a wrapper function
1780 * that calls the generic utility function @event_trigger_print()
1781 * (see trace_event_triggers.c).
1783 struct event_trigger_ops {
1784 void (*func)(struct event_trigger_data *data,
1785 void *rec,
1786 struct ring_buffer_event *rbe);
1787 int (*init)(struct event_trigger_ops *ops,
1788 struct event_trigger_data *data);
1789 void (*free)(struct event_trigger_ops *ops,
1790 struct event_trigger_data *data);
1791 int (*print)(struct seq_file *m,
1792 struct event_trigger_ops *ops,
1793 struct event_trigger_data *data);
1797 * struct event_command - callbacks and data members for event commands
1799 * Event commands are invoked by users by writing the command name
1800 * into the 'trigger' file associated with a trace event. The
1801 * parameters associated with a specific invocation of an event
1802 * command are used to create an event trigger instance, which is
1803 * added to the list of trigger instances associated with that trace
1804 * event. When the event is hit, the set of triggers associated with
1805 * that event is invoked.
1807 * The data members in this structure provide per-event command data
1808 * for various event commands.
1810 * All the data members below, except for @post_trigger, must be set
1811 * for each event command.
1813 * @name: The unique name that identifies the event command. This is
1814 * the name used when setting triggers via trigger files.
1816 * @trigger_type: A unique id that identifies the event command
1817 * 'type'. This value has two purposes, the first to ensure that
1818 * only one trigger of the same type can be set at a given time
1819 * for a particular event e.g. it doesn't make sense to have both
1820 * a traceon and traceoff trigger attached to a single event at
1821 * the same time, so traceon and traceoff have the same type
1822 * though they have different names. The @trigger_type value is
1823 * also used as a bit value for deferring the actual trigger
1824 * action until after the current event is finished. Some
1825 * commands need to do this if they themselves log to the trace
1826 * buffer (see the @post_trigger() member below). @trigger_type
1827 * values are defined by adding new values to the trigger_type
1828 * enum in include/linux/trace_events.h.
1830 * @flags: See the enum event_command_flags below.
1832 * All the methods below, except for @set_filter() and @unreg_all(),
1833 * must be implemented.
1835 * @func: The callback function responsible for parsing and
1836 * registering the trigger written to the 'trigger' file by the
1837 * user. It allocates the trigger instance and registers it with
1838 * the appropriate trace event. It makes use of the other
1839 * event_command callback functions to orchestrate this, and is
1840 * usually implemented by the generic utility function
1841 * @event_trigger_callback() (see trace_event_triggers.c).
1843 * @reg: Adds the trigger to the list of triggers associated with the
1844 * event, and enables the event trigger itself, after
1845 * initializing it (via the event_trigger_ops @init() function).
1846 * This is also where commands can use the @trigger_type value to
1847 * make the decision as to whether or not multiple instances of
1848 * the trigger should be allowed. This is usually implemented by
1849 * the generic utility function @register_trigger() (see
1850 * trace_event_triggers.c).
1852 * @unreg: Removes the trigger from the list of triggers associated
1853 * with the event, and disables the event trigger itself, after
1854 * initializing it (via the event_trigger_ops @free() function).
1855 * This is usually implemented by the generic utility function
1856 * @unregister_trigger() (see trace_event_triggers.c).
1858 * @unreg_all: An optional function called to remove all the triggers
1859 * from the list of triggers associated with the event. Called
1860 * when a trigger file is opened in truncate mode.
1862 * @set_filter: An optional function called to parse and set a filter
1863 * for the trigger. If no @set_filter() method is set for the
1864 * event command, filters set by the user for the command will be
1865 * ignored. This is usually implemented by the generic utility
1866 * function @set_trigger_filter() (see trace_event_triggers.c).
1868 * @get_trigger_ops: The callback function invoked to retrieve the
1869 * event_trigger_ops implementation associated with the command.
1871 struct event_command {
1872 struct list_head list;
1873 char *name;
1874 enum event_trigger_type trigger_type;
1875 int flags;
1876 int (*func)(struct event_command *cmd_ops,
1877 struct trace_event_file *file,
1878 char *glob, char *cmd, char *params);
1879 int (*reg)(char *glob,
1880 struct event_trigger_ops *ops,
1881 struct event_trigger_data *data,
1882 struct trace_event_file *file);
1883 void (*unreg)(char *glob,
1884 struct event_trigger_ops *ops,
1885 struct event_trigger_data *data,
1886 struct trace_event_file *file);
1887 void (*unreg_all)(struct trace_event_file *file);
1888 int (*set_filter)(char *filter_str,
1889 struct event_trigger_data *data,
1890 struct trace_event_file *file);
1891 struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
1895 * enum event_command_flags - flags for struct event_command
1897 * @POST_TRIGGER: A flag that says whether or not this command needs
1898 * to have its action delayed until after the current event has
1899 * been closed. Some triggers need to avoid being invoked while
1900 * an event is currently in the process of being logged, since
1901 * the trigger may itself log data into the trace buffer. Thus
1902 * we make sure the current event is committed before invoking
1903 * those triggers. To do that, the trigger invocation is split
1904 * in two - the first part checks the filter using the current
1905 * trace record; if a command has the @post_trigger flag set, it
1906 * sets a bit for itself in the return value, otherwise it
1907 * directly invokes the trigger. Once all commands have been
1908 * either invoked or set their return flag, the current record is
1909 * either committed or discarded. At that point, if any commands
1910 * have deferred their triggers, those commands are finally
1911 * invoked following the close of the current event. In other
1912 * words, if the event_trigger_ops @func() probe implementation
1913 * itself logs to the trace buffer, this flag should be set,
1914 * otherwise it can be left unspecified.
1916 * @NEEDS_REC: A flag that says whether or not this command needs
1917 * access to the trace record in order to perform its function,
1918 * regardless of whether or not it has a filter associated with
1919 * it (filters make a trigger require access to the trace record
1920 * but are not always present).
1922 enum event_command_flags {
1923 EVENT_CMD_FL_POST_TRIGGER = 1,
1924 EVENT_CMD_FL_NEEDS_REC = 2,
1927 static inline bool event_command_post_trigger(struct event_command *cmd_ops)
1929 return cmd_ops->flags & EVENT_CMD_FL_POST_TRIGGER;
1932 static inline bool event_command_needs_rec(struct event_command *cmd_ops)
1934 return cmd_ops->flags & EVENT_CMD_FL_NEEDS_REC;
1937 extern int trace_event_enable_disable(struct trace_event_file *file,
1938 int enable, int soft_disable);
1939 extern int tracing_alloc_snapshot(void);
1940 extern void tracing_snapshot_cond(struct trace_array *tr, void *cond_data);
1941 extern int tracing_snapshot_cond_enable(struct trace_array *tr, void *cond_data, cond_update_fn_t update);
1943 extern int tracing_snapshot_cond_disable(struct trace_array *tr);
1944 extern void *tracing_cond_snapshot_data(struct trace_array *tr);
1946 extern const char *__start___trace_bprintk_fmt[];
1947 extern const char *__stop___trace_bprintk_fmt[];
1949 extern const char *__start___tracepoint_str[];
1950 extern const char *__stop___tracepoint_str[];
1952 void trace_printk_control(bool enabled);
1953 void trace_printk_start_comm(void);
1954 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
1955 int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
1957 /* Used from boot time tracer */
1958 extern int trace_set_options(struct trace_array *tr, char *option);
1959 extern int tracing_set_tracer(struct trace_array *tr, const char *buf);
1960 extern ssize_t tracing_resize_ring_buffer(struct trace_array *tr,
1961 unsigned long size, int cpu_id);
1962 extern int tracing_set_cpumask(struct trace_array *tr,
1963 cpumask_var_t tracing_cpumask_new);
1966 #define MAX_EVENT_NAME_LEN 64
1968 extern int trace_run_command(const char *buf, int (*createfn)(int, char**));
1969 extern ssize_t trace_parse_run_command(struct file *file,
1970 const char __user *buffer, size_t count, loff_t *ppos,
1971 int (*createfn)(int, char**));
1973 extern unsigned int err_pos(char *cmd, const char *str);
1974 extern void tracing_log_err(struct trace_array *tr,
1975 const char *loc, const char *cmd,
1976 const char **errs, u8 type, u8 pos);
1979 * Normal trace_printk() and friends allocates special buffers
1980 * to do the manipulation, as well as saves the print formats
1981 * into sections to display. But the trace infrastructure wants
1982 * to use these without the added overhead at the price of being
1983 * a bit slower (used mainly for warnings, where we don't care
1984 * about performance). The internal_trace_puts() is for such
1985 * a purpose.
1987 #define internal_trace_puts(str) __trace_puts(_THIS_IP_, str, strlen(str))
1989 #undef FTRACE_ENTRY
1990 #define FTRACE_ENTRY(call, struct_name, id, tstruct, print) \
1991 extern struct trace_event_call \
1992 __aligned(4) event_##call;
1993 #undef FTRACE_ENTRY_DUP
1994 #define FTRACE_ENTRY_DUP(call, struct_name, id, tstruct, print) \
1995 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))
1996 #undef FTRACE_ENTRY_PACKED
1997 #define FTRACE_ENTRY_PACKED(call, struct_name, id, tstruct, print) \
1998 FTRACE_ENTRY(call, struct_name, id, PARAMS(tstruct), PARAMS(print))
2000 #include "trace_entries.h"
2002 #if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_FUNCTION_TRACER)
2003 int perf_ftrace_event_register(struct trace_event_call *call,
2004 enum trace_reg type, void *data);
2005 #else
2006 #define perf_ftrace_event_register NULL
2007 #endif
2009 #ifdef CONFIG_FTRACE_SYSCALLS
2010 void init_ftrace_syscalls(void);
2011 const char *get_syscall_name(int syscall);
2012 #else
2013 static inline void init_ftrace_syscalls(void) { }
2014 static inline const char *get_syscall_name(int syscall)
2016 return NULL;
2018 #endif
2020 #ifdef CONFIG_EVENT_TRACING
2021 void trace_event_init(void);
2022 void trace_event_eval_update(struct trace_eval_map **map, int len);
2023 /* Used from boot time tracer */
2024 extern int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
2025 extern int trigger_process_regex(struct trace_event_file *file, char *buff);
2026 #else
2027 static inline void __init trace_event_init(void) { }
2028 static inline void trace_event_eval_update(struct trace_eval_map **map, int len) { }
2029 #endif
2031 #ifdef CONFIG_TRACER_SNAPSHOT
2032 void tracing_snapshot_instance(struct trace_array *tr);
2033 int tracing_alloc_snapshot_instance(struct trace_array *tr);
2034 #else
2035 static inline void tracing_snapshot_instance(struct trace_array *tr) { }
2036 static inline int tracing_alloc_snapshot_instance(struct trace_array *tr)
2038 return 0;
2040 #endif
2042 #ifdef CONFIG_PREEMPT_TRACER
2043 void tracer_preempt_on(unsigned long a0, unsigned long a1);
2044 void tracer_preempt_off(unsigned long a0, unsigned long a1);
2045 #else
2046 static inline void tracer_preempt_on(unsigned long a0, unsigned long a1) { }
2047 static inline void tracer_preempt_off(unsigned long a0, unsigned long a1) { }
2048 #endif
2049 #ifdef CONFIG_IRQSOFF_TRACER
2050 void tracer_hardirqs_on(unsigned long a0, unsigned long a1);
2051 void tracer_hardirqs_off(unsigned long a0, unsigned long a1);
2052 #else
2053 static inline void tracer_hardirqs_on(unsigned long a0, unsigned long a1) { }
2054 static inline void tracer_hardirqs_off(unsigned long a0, unsigned long a1) { }
2055 #endif
2057 extern struct trace_iterator *tracepoint_print_iter;
2060 * Reset the state of the trace_iterator so that it can read consumed data.
2061 * Normally, the trace_iterator is used for reading the data when it is not
2062 * consumed, and must retain state.
2064 static __always_inline void trace_iterator_reset(struct trace_iterator *iter)
2066 const size_t offset = offsetof(struct trace_iterator, seq);
2069 * Keep gcc from complaining about overwriting more than just one
2070 * member in the structure.
2072 memset((char *)iter + offset, 0, sizeof(struct trace_iterator) - offset);
2074 iter->pos = -1;
2077 #endif /* _LINUX_KERNEL_TRACE_H */