aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/ftrace.h35
-rw-r--r--kernel/trace/ftrace.c41
2 files changed, 60 insertions, 16 deletions
diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
index 31b9fd7aedcd..aa7559f0a224 100644
--- a/include/linux/ftrace.h
+++ b/include/linux/ftrace.h
@@ -202,6 +202,14 @@ enum {
202 FTRACE_UPDATE_MAKE_NOP, 202 FTRACE_UPDATE_MAKE_NOP,
203}; 203};
204 204
205enum {
206 FTRACE_ITER_FILTER = (1 << 0),
207 FTRACE_ITER_NOTRACE = (1 << 1),
208 FTRACE_ITER_PRINTALL = (1 << 2),
209 FTRACE_ITER_HASH = (1 << 3),
210 FTRACE_ITER_ENABLED = (1 << 4),
211};
212
205void arch_ftrace_update_code(int command); 213void arch_ftrace_update_code(int command);
206 214
207struct ftrace_rec_iter; 215struct ftrace_rec_iter;
@@ -217,6 +225,15 @@ int ftrace_location(unsigned long ip);
217 225
218extern ftrace_func_t ftrace_trace_function; 226extern ftrace_func_t ftrace_trace_function;
219 227
228int ftrace_regex_open(struct ftrace_ops *ops, int flag,
229 struct inode *inode, struct file *file);
230ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
231 size_t cnt, loff_t *ppos);
232ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
233 size_t cnt, loff_t *ppos);
234loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int origin);
235int ftrace_regex_release(struct inode *inode, struct file *file);
236
220/* defined in arch */ 237/* defined in arch */
221extern int ftrace_ip_converted(unsigned long ip); 238extern int ftrace_ip_converted(unsigned long ip);
222extern int ftrace_dyn_arch_init(void *data); 239extern int ftrace_dyn_arch_init(void *data);
@@ -311,6 +328,24 @@ static inline int ftrace_text_reserved(void *start, void *end)
311{ 328{
312 return 0; 329 return 0;
313} 330}
331
332/*
333 * Again users of functions that have ftrace_ops may not
334 * have them defined when ftrace is not enabled, but these
335 * functions may still be called. Use a macro instead of inline.
336 */
337#define ftrace_regex_open(ops, flag, inod, file) ({ -ENODEV; })
338
339static inline ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
340 size_t cnt, loff_t *ppos) { return -ENODEV; }
341static inline ssize_t ftrace_notrace_write(struct file *file, const char __user *ubuf,
342 size_t cnt, loff_t *ppos) { return -ENODEV; }
343static inline loff_t ftrace_regex_lseek(struct file *file, loff_t offset, int origin)
344{
345 return -ENODEV;
346}
347static inline int
348ftrace_regex_release(struct inode *inode, struct file *file) { return -ENODEV; }
314#endif /* CONFIG_DYNAMIC_FTRACE */ 349#endif /* CONFIG_DYNAMIC_FTRACE */
315 350
316/* totally disable ftrace - can not re-enable after this */ 351/* totally disable ftrace - can not re-enable after this */
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index e1ee07f81ca2..5b105c5ddc0c 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -2134,14 +2134,6 @@ static int __init ftrace_dyn_table_alloc(unsigned long num_to_init)
2134 return 0; 2134 return 0;
2135} 2135}
2136 2136
2137enum {
2138 FTRACE_ITER_FILTER = (1 << 0),
2139 FTRACE_ITER_NOTRACE = (1 << 1),
2140 FTRACE_ITER_PRINTALL = (1 << 2),
2141 FTRACE_ITER_HASH = (1 << 3),
2142 FTRACE_ITER_ENABLED = (1 << 4),
2143};
2144
2145#define FTRACE_BUFF_MAX (KSYM_SYMBOL_LEN+4) /* room for wildcards */ 2137#define FTRACE_BUFF_MAX (KSYM_SYMBOL_LEN+4) /* room for wildcards */
2146 2138
2147struct ftrace_iterator { 2139struct ftrace_iterator {
@@ -2249,7 +2241,7 @@ static void *
2249t_next(struct seq_file *m, void *v, loff_t *pos) 2241t_next(struct seq_file *m, void *v, loff_t *pos)
2250{ 2242{
2251 struct ftrace_iterator *iter = m->private; 2243 struct ftrace_iterator *iter = m->private;
2252 struct ftrace_ops *ops = &global_ops; 2244 struct ftrace_ops *ops = iter->ops;
2253 struct dyn_ftrace *rec = NULL; 2245 struct dyn_ftrace *rec = NULL;
2254 2246
2255 if (unlikely(ftrace_disabled)) 2247 if (unlikely(ftrace_disabled))
@@ -2305,7 +2297,7 @@ static void reset_iter_read(struct ftrace_iterator *iter)
2305static void *t_start(struct seq_file *m, loff_t *pos) 2297static void *t_start(struct seq_file *m, loff_t *pos)
2306{ 2298{
2307 struct ftrace_iterator *iter = m->private; 2299 struct ftrace_iterator *iter = m->private;
2308 struct ftrace_ops *ops = &global_ops; 2300 struct ftrace_ops *ops = iter->ops;
2309 void *p = NULL; 2301 void *p = NULL;
2310 loff_t l; 2302 loff_t l;
2311 2303
@@ -2414,6 +2406,7 @@ ftrace_avail_open(struct inode *inode, struct file *file)
2414 return -ENOMEM; 2406 return -ENOMEM;
2415 2407
2416 iter->pg = ftrace_pages_start; 2408 iter->pg = ftrace_pages_start;
2409 iter->ops = &global_ops;
2417 2410
2418 ret = seq_open(file, &show_ftrace_seq_ops); 2411 ret = seq_open(file, &show_ftrace_seq_ops);
2419 if (!ret) { 2412 if (!ret) {
@@ -2442,6 +2435,7 @@ ftrace_enabled_open(struct inode *inode, struct file *file)
2442 2435
2443 iter->pg = ftrace_pages_start; 2436 iter->pg = ftrace_pages_start;
2444 iter->flags = FTRACE_ITER_ENABLED; 2437 iter->flags = FTRACE_ITER_ENABLED;
2438 iter->ops = &global_ops;
2445 2439
2446 ret = seq_open(file, &show_ftrace_seq_ops); 2440 ret = seq_open(file, &show_ftrace_seq_ops);
2447 if (!ret) { 2441 if (!ret) {
@@ -2462,7 +2456,23 @@ static void ftrace_filter_reset(struct ftrace_hash *hash)
2462 mutex_unlock(&ftrace_lock); 2456 mutex_unlock(&ftrace_lock);
2463} 2457}
2464 2458
2465static int 2459/**
2460 * ftrace_regex_open - initialize function tracer filter files
2461 * @ops: The ftrace_ops that hold the hash filters
2462 * @flag: The type of filter to process
2463 * @inode: The inode, usually passed in to your open routine
2464 * @file: The file, usually passed in to your open routine
2465 *
2466 * ftrace_regex_open() initializes the filter files for the
2467 * @ops. Depending on @flag it may process the filter hash or
2468 * the notrace hash of @ops. With this called from the open
2469 * routine, you can use ftrace_filter_write() for the write
2470 * routine if @flag has FTRACE_ITER_FILTER set, or
2471 * ftrace_notrace_write() if @flag has FTRACE_ITER_NOTRACE set.
2472 * ftrace_regex_lseek() should be used as the lseek routine, and
2473 * release must call ftrace_regex_release().
2474 */
2475int
2466ftrace_regex_open(struct ftrace_ops *ops, int flag, 2476ftrace_regex_open(struct ftrace_ops *ops, int flag,
2467 struct inode *inode, struct file *file) 2477 struct inode *inode, struct file *file)
2468{ 2478{
@@ -2542,7 +2552,7 @@ ftrace_notrace_open(struct inode *inode, struct file *file)
2542 inode, file); 2552 inode, file);
2543} 2553}
2544 2554
2545static loff_t 2555loff_t
2546ftrace_regex_lseek(struct file *file, loff_t offset, int origin) 2556ftrace_regex_lseek(struct file *file, loff_t offset, int origin)
2547{ 2557{
2548 loff_t ret; 2558 loff_t ret;
@@ -3095,14 +3105,14 @@ out_unlock:
3095 return ret; 3105 return ret;
3096} 3106}
3097 3107
3098static ssize_t 3108ssize_t
3099ftrace_filter_write(struct file *file, const char __user *ubuf, 3109ftrace_filter_write(struct file *file, const char __user *ubuf,
3100 size_t cnt, loff_t *ppos) 3110 size_t cnt, loff_t *ppos)
3101{ 3111{
3102 return ftrace_regex_write(file, ubuf, cnt, ppos, 1); 3112 return ftrace_regex_write(file, ubuf, cnt, ppos, 1);
3103} 3113}
3104 3114
3105static ssize_t 3115ssize_t
3106ftrace_notrace_write(struct file *file, const char __user *ubuf, 3116ftrace_notrace_write(struct file *file, const char __user *ubuf,
3107 size_t cnt, loff_t *ppos) 3117 size_t cnt, loff_t *ppos)
3108{ 3118{
@@ -3292,8 +3302,7 @@ static void __init set_ftrace_early_filters(void)
3292#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 3302#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
3293} 3303}
3294 3304
3295static int 3305int ftrace_regex_release(struct inode *inode, struct file *file)
3296ftrace_regex_release(struct inode *inode, struct file *file)
3297{ 3306{
3298 struct seq_file *m = (struct seq_file *)file->private_data; 3307 struct seq_file *m = (struct seq_file *)file->private_data;
3299 struct ftrace_iterator *iter; 3308 struct ftrace_iterator *iter;