Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 1 | #ifndef _LINUX_FTRACE_H |
| 2 | #define _LINUX_FTRACE_H |
| 3 | |
| 4 | #ifdef CONFIG_FTRACE |
| 5 | |
| 6 | #include <linux/linkage.h> |
Ingo Molnar | d49dbf3 | 2008-05-16 10:41:53 +0200 | [diff] [blame] | 7 | #include <linux/fs.h> |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 8 | |
Steven Rostedt | b0fc494 | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 9 | extern int ftrace_enabled; |
| 10 | extern int |
| 11 | ftrace_enable_sysctl(struct ctl_table *table, int write, |
| 12 | struct file *filp, void __user *buffer, size_t *lenp, |
| 13 | loff_t *ppos); |
| 14 | |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 15 | typedef void (*ftrace_func_t)(unsigned long ip, unsigned long parent_ip); |
| 16 | |
| 17 | struct ftrace_ops { |
| 18 | ftrace_func_t func; |
| 19 | struct ftrace_ops *next; |
| 20 | }; |
| 21 | |
| 22 | /* |
| 23 | * The ftrace_ops must be a static and should also |
| 24 | * be read_mostly. These functions do modify read_mostly variables |
| 25 | * so use them sparely. Never free an ftrace_op or modify the |
| 26 | * next pointer after it has been registered. Even after unregistering |
| 27 | * it, the next pointer may still be used internally. |
| 28 | */ |
| 29 | int register_ftrace_function(struct ftrace_ops *ops); |
| 30 | int unregister_ftrace_function(struct ftrace_ops *ops); |
| 31 | void clear_ftrace_function(void); |
| 32 | |
| 33 | extern void ftrace_stub(unsigned long a0, unsigned long a1); |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 34 | |
| 35 | #else /* !CONFIG_FTRACE */ |
| 36 | # define register_ftrace_function(ops) do { } while (0) |
| 37 | # define unregister_ftrace_function(ops) do { } while (0) |
| 38 | # define clear_ftrace_function(ops) do { } while (0) |
| 39 | #endif /* CONFIG_FTRACE */ |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 40 | |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 41 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 42 | # define FTRACE_HASHBITS 10 |
| 43 | # define FTRACE_HASHSIZE (1<<FTRACE_HASHBITS) |
| 44 | |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 45 | enum { |
Steven Rostedt | 37ad508 | 2008-05-12 21:20:48 +0200 | [diff] [blame] | 46 | FTRACE_FL_FREE = (1 << 0), |
| 47 | FTRACE_FL_FAILED = (1 << 1), |
| 48 | FTRACE_FL_FILTER = (1 << 2), |
| 49 | FTRACE_FL_ENABLED = (1 << 3), |
Steven Rostedt | 41c52c0 | 2008-05-22 11:46:33 -0400 | [diff] [blame] | 50 | FTRACE_FL_NOTRACE = (1 << 4), |
Abhishek Sagar | 0eb9670 | 2008-06-01 21:47:30 +0530 | [diff] [blame] | 51 | FTRACE_FL_CONVERTED = (1 << 5), |
Abhishek Sagar | ecea656 | 2008-06-21 23:47:53 +0530 | [diff] [blame] | 52 | FTRACE_FL_FROZEN = (1 << 6), |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 53 | }; |
| 54 | |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 55 | struct dyn_ftrace { |
| 56 | struct hlist_node node; |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 57 | unsigned long ip; /* address of mcount call-site */ |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 58 | unsigned long flags; |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 59 | }; |
| 60 | |
Steven Rostedt | e1c08bd | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 61 | int ftrace_force_update(void); |
Steven Rostedt | 77a2b37 | 2008-05-12 21:20:45 +0200 | [diff] [blame] | 62 | void ftrace_set_filter(unsigned char *buf, int len, int reset); |
Steven Rostedt | e1c08bd | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 63 | |
Steven Rostedt | 3d08339 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 64 | /* defined in arch */ |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 65 | extern int ftrace_ip_converted(unsigned long ip); |
| 66 | extern unsigned char *ftrace_nop_replace(void); |
| 67 | extern unsigned char *ftrace_call_replace(unsigned long ip, unsigned long addr); |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 68 | extern int ftrace_dyn_arch_init(void *data); |
| 69 | extern int ftrace_mcount_set(unsigned long *data); |
Steven Rostedt | 3c1720f | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 70 | extern int ftrace_modify_code(unsigned long ip, unsigned char *old_code, |
| 71 | unsigned char *new_code); |
Steven Rostedt | d61f82d | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 72 | extern int ftrace_update_ftrace_func(ftrace_func_t func); |
| 73 | extern void ftrace_caller(void); |
| 74 | extern void ftrace_call(void); |
| 75 | extern void mcount_call(void); |
Steven Rostedt | ad90c0e | 2008-05-27 20:48:37 -0400 | [diff] [blame] | 76 | |
Abhishek Sagar | ecea656 | 2008-06-21 23:47:53 +0530 | [diff] [blame] | 77 | extern int skip_trace(unsigned long ip); |
| 78 | |
Steven Rostedt | ad90c0e | 2008-05-27 20:48:37 -0400 | [diff] [blame] | 79 | void ftrace_disable_daemon(void); |
| 80 | void ftrace_enable_daemon(void); |
| 81 | |
Steven Rostedt | e1c08bd | 2008-05-12 21:20:44 +0200 | [diff] [blame] | 82 | #else |
Abhishek Sagar | ecea656 | 2008-06-21 23:47:53 +0530 | [diff] [blame] | 83 | # define skip_trace(ip) ({ 0; }) |
Ingo Molnar | aeaee8a | 2008-05-12 21:20:49 +0200 | [diff] [blame] | 84 | # define ftrace_force_update() ({ 0; }) |
| 85 | # define ftrace_set_filter(buf, len, reset) do { } while (0) |
Steven Rostedt | ad90c0e | 2008-05-27 20:48:37 -0400 | [diff] [blame] | 86 | # define ftrace_disable_daemon() do { } while (0) |
| 87 | # define ftrace_enable_daemon() do { } while (0) |
Abhishek Sagar | ecea656 | 2008-06-21 23:47:53 +0530 | [diff] [blame] | 88 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 89 | |
Ingo Molnar | aeaee8a | 2008-05-12 21:20:49 +0200 | [diff] [blame] | 90 | /* totally disable ftrace - can not re-enable after this */ |
| 91 | void ftrace_kill(void); |
Steven Rostedt | a2bb6a3 | 2008-07-10 20:58:15 -0400 | [diff] [blame] | 92 | void ftrace_kill_atomic(void); |
Ingo Molnar | aeaee8a | 2008-05-12 21:20:49 +0200 | [diff] [blame] | 93 | |
Ingo Molnar | f43fdad | 2008-05-12 21:20:43 +0200 | [diff] [blame] | 94 | static inline void tracer_disable(void) |
| 95 | { |
| 96 | #ifdef CONFIG_FTRACE |
| 97 | ftrace_enabled = 0; |
| 98 | #endif |
| 99 | } |
| 100 | |
Huang Ying | 9bdeb7b | 2008-08-15 00:40:25 -0700 | [diff] [blame] | 101 | /* Ftrace disable/restore without lock. Some synchronization mechanism |
| 102 | * must be used to prevent ftrace_enabled to be changed between |
| 103 | * disable/restore. */ |
| 104 | static inline int __ftrace_enabled_save(void) |
| 105 | { |
| 106 | #ifdef CONFIG_FTRACE |
| 107 | int saved_ftrace_enabled = ftrace_enabled; |
| 108 | ftrace_enabled = 0; |
| 109 | return saved_ftrace_enabled; |
| 110 | #else |
| 111 | return 0; |
| 112 | #endif |
| 113 | } |
| 114 | |
| 115 | static inline void __ftrace_enabled_restore(int enabled) |
| 116 | { |
| 117 | #ifdef CONFIG_FTRACE |
| 118 | ftrace_enabled = enabled; |
| 119 | #endif |
| 120 | } |
| 121 | |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 122 | #ifdef CONFIG_FRAME_POINTER |
| 123 | /* TODO: need to fix this for ARM */ |
| 124 | # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) |
| 125 | # define CALLER_ADDR1 ((unsigned long)__builtin_return_address(1)) |
| 126 | # define CALLER_ADDR2 ((unsigned long)__builtin_return_address(2)) |
| 127 | # define CALLER_ADDR3 ((unsigned long)__builtin_return_address(3)) |
| 128 | # define CALLER_ADDR4 ((unsigned long)__builtin_return_address(4)) |
| 129 | # define CALLER_ADDR5 ((unsigned long)__builtin_return_address(5)) |
Ingo Molnar | 86387f7 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 130 | # define CALLER_ADDR6 ((unsigned long)__builtin_return_address(6)) |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 131 | #else |
| 132 | # define CALLER_ADDR0 ((unsigned long)__builtin_return_address(0)) |
| 133 | # define CALLER_ADDR1 0UL |
| 134 | # define CALLER_ADDR2 0UL |
| 135 | # define CALLER_ADDR3 0UL |
| 136 | # define CALLER_ADDR4 0UL |
| 137 | # define CALLER_ADDR5 0UL |
Ingo Molnar | 86387f7 | 2008-05-12 21:20:51 +0200 | [diff] [blame] | 138 | # define CALLER_ADDR6 0UL |
Steven Rostedt | 352ad25 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 139 | #endif |
| 140 | |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 141 | #ifdef CONFIG_IRQSOFF_TRACER |
Ingo Molnar | 489f139 | 2008-02-25 13:38:05 +0100 | [diff] [blame] | 142 | extern void time_hardirqs_on(unsigned long a0, unsigned long a1); |
| 143 | extern void time_hardirqs_off(unsigned long a0, unsigned long a1); |
Steven Rostedt | 81d68a9 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 144 | #else |
| 145 | # define time_hardirqs_on(a0, a1) do { } while (0) |
| 146 | # define time_hardirqs_off(a0, a1) do { } while (0) |
| 147 | #endif |
| 148 | |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 149 | #ifdef CONFIG_PREEMPT_TRACER |
Ingo Molnar | 489f139 | 2008-02-25 13:38:05 +0100 | [diff] [blame] | 150 | extern void trace_preempt_on(unsigned long a0, unsigned long a1); |
| 151 | extern void trace_preempt_off(unsigned long a0, unsigned long a1); |
Steven Rostedt | 6cd8a4b | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 152 | #else |
| 153 | # define trace_preempt_on(a0, a1) do { } while (0) |
| 154 | # define trace_preempt_off(a0, a1) do { } while (0) |
| 155 | #endif |
| 156 | |
Ingo Molnar | b1829d2 | 2008-05-28 01:22:08 +0200 | [diff] [blame] | 157 | #ifdef CONFIG_TRACING |
Ingo Molnar | 74f4e36 | 2008-05-12 21:21:15 +0200 | [diff] [blame] | 158 | extern void |
| 159 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3); |
Steven Rostedt | 2f2c99d | 2008-08-01 16:45:49 -0400 | [diff] [blame] | 160 | |
| 161 | /** |
| 162 | * ftrace_printk - printf formatting in the ftrace buffer |
| 163 | * @fmt: the printf format for printing |
| 164 | * |
| 165 | * Note: __ftrace_printk is an internal function for ftrace_printk and |
| 166 | * the @ip is passed in via the ftrace_printk macro. |
| 167 | * |
| 168 | * This function allows a kernel developer to debug fast path sections |
| 169 | * that printk is not appropriate for. By scattering in various |
| 170 | * printk like tracing in the code, a developer can quickly see |
| 171 | * where problems are occurring. |
| 172 | * |
| 173 | * This is intended as a debugging tool for the developer only. |
| 174 | * Please refrain from leaving ftrace_printks scattered around in |
| 175 | * your code. |
| 176 | */ |
| 177 | # define ftrace_printk(fmt...) __ftrace_printk(_THIS_IP_, fmt) |
Steven Rostedt | dd0e545 | 2008-08-01 12:26:41 -0400 | [diff] [blame] | 178 | extern int |
| 179 | __ftrace_printk(unsigned long ip, const char *fmt, ...) |
| 180 | __attribute__ ((format (printf, 2, 3))); |
Steven Rostedt | 3f5a54e | 2008-07-30 22:36:46 -0400 | [diff] [blame] | 181 | extern void ftrace_dump(void); |
Ingo Molnar | 74f4e36 | 2008-05-12 21:21:15 +0200 | [diff] [blame] | 182 | #else |
| 183 | static inline void |
| 184 | ftrace_special(unsigned long arg1, unsigned long arg2, unsigned long arg3) { } |
Steven Rostedt | dd0e545 | 2008-08-01 12:26:41 -0400 | [diff] [blame] | 185 | static inline int |
Ingo Molnar | 7b928c2 | 2008-08-15 17:48:02 +0200 | [diff] [blame^] | 186 | ftrace_printk(const char *fmt, ...) __attribute__ ((format (printf, 1, 0))); |
| 187 | |
| 188 | static inline int |
| 189 | ftrace_printk(const char *fmt, ...) |
Steven Rostedt | dd0e545 | 2008-08-01 12:26:41 -0400 | [diff] [blame] | 190 | { |
| 191 | return 0; |
| 192 | } |
Steven Rostedt | 3f5a54e | 2008-07-30 22:36:46 -0400 | [diff] [blame] | 193 | static inline void ftrace_dump(void) { } |
Ingo Molnar | 74f4e36 | 2008-05-12 21:21:15 +0200 | [diff] [blame] | 194 | #endif |
| 195 | |
Steven Rostedt | 68bf21a | 2008-08-14 15:45:08 -0400 | [diff] [blame] | 196 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD |
| 197 | extern void ftrace_init(void); |
Steven Rostedt | 90d595f | 2008-08-14 15:45:09 -0400 | [diff] [blame] | 198 | extern void ftrace_init_module(unsigned long *start, unsigned long *end); |
Steven Rostedt | fed1939 | 2008-08-14 22:47:19 -0400 | [diff] [blame] | 199 | extern void ftrace_release(void *start, unsigned long size); |
Steven Rostedt | 68bf21a | 2008-08-14 15:45:08 -0400 | [diff] [blame] | 200 | #else |
| 201 | static inline void ftrace_init(void) { } |
Steven Rostedt | 90d595f | 2008-08-14 15:45:09 -0400 | [diff] [blame] | 202 | static inline void |
| 203 | ftrace_init_module(unsigned long *start, unsigned long *end) { } |
Steven Rostedt | fed1939 | 2008-08-14 22:47:19 -0400 | [diff] [blame] | 204 | static inline void ftrace_release(void *start, unsigned long size) { } |
Steven Rostedt | 68bf21a | 2008-08-14 15:45:08 -0400 | [diff] [blame] | 205 | #endif |
| 206 | |
Steven Rostedt | dd0e545 | 2008-08-01 12:26:41 -0400 | [diff] [blame] | 207 | |
Arnaldo Carvalho de Melo | 16444a8 | 2008-05-12 21:20:42 +0200 | [diff] [blame] | 208 | #endif /* _LINUX_FTRACE_H */ |