aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2011-04-21 23:16:46 -0400
committerSteven Rostedt <rostedt@goodmis.org>2011-04-29 22:53:01 -0400
commit45a4a2372b364107cabea79f255b333236626416 (patch)
treedfe3e1c3b55451fedc8896aaa8359677d583a0e5 /kernel/trace
parent3499e461147636bf55c41128d83b679ac6ab2d86 (diff)
ftrace: Remove FTRACE_FL_FAILED flag
Since we disable all function tracer processing if we detect that a modification of a instruction had failed, we do not need to track that the record has failed. No more ftrace processing is allowed, and the FTRACE_FL_FAILED flag is pointless. Removing this flag simplifies some of the code, but some ftrace_disabled checks needed to be added or move around a little. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/ftrace.c76
1 files changed, 47 insertions, 29 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 97b30f818642..eb19fae2c54a 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1083,19 +1083,20 @@ static void ftrace_replace_code(int enable)
1083 struct ftrace_page *pg; 1083 struct ftrace_page *pg;
1084 int failed; 1084 int failed;
1085 1085
1086 if (unlikely(ftrace_disabled))
1087 return;
1088
1086 do_for_each_ftrace_rec(pg, rec) { 1089 do_for_each_ftrace_rec(pg, rec) {
1087 /* 1090 /*
1088 * Skip over free records, records that have 1091 * Skip over free records, records that have
1089 * failed and not converted. 1092 * failed and not converted.
1090 */ 1093 */
1091 if (rec->flags & FTRACE_FL_FREE || 1094 if (rec->flags & FTRACE_FL_FREE ||
1092 rec->flags & FTRACE_FL_FAILED ||
1093 !(rec->flags & FTRACE_FL_CONVERTED)) 1095 !(rec->flags & FTRACE_FL_CONVERTED))
1094 continue; 1096 continue;
1095 1097
1096 failed = __ftrace_replace_code(rec, enable); 1098 failed = __ftrace_replace_code(rec, enable);
1097 if (failed) { 1099 if (failed) {
1098 rec->flags |= FTRACE_FL_FAILED;
1099 ftrace_bug(failed, rec->ip); 1100 ftrace_bug(failed, rec->ip);
1100 /* Stop processing */ 1101 /* Stop processing */
1101 return; 1102 return;
@@ -1111,10 +1112,12 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
1111 1112
1112 ip = rec->ip; 1113 ip = rec->ip;
1113 1114
1115 if (unlikely(ftrace_disabled))
1116 return 0;
1117
1114 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR); 1118 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
1115 if (ret) { 1119 if (ret) {
1116 ftrace_bug(ret, ip); 1120 ftrace_bug(ret, ip);
1117 rec->flags |= FTRACE_FL_FAILED;
1118 return 0; 1121 return 0;
1119 } 1122 }
1120 return 1; 1123 return 1;
@@ -1466,6 +1469,9 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
1466 struct ftrace_iterator *iter = m->private; 1469 struct ftrace_iterator *iter = m->private;
1467 struct dyn_ftrace *rec = NULL; 1470 struct dyn_ftrace *rec = NULL;
1468 1471
1472 if (unlikely(ftrace_disabled))
1473 return NULL;
1474
1469 if (iter->flags & FTRACE_ITER_HASH) 1475 if (iter->flags & FTRACE_ITER_HASH)
1470 return t_hash_next(m, pos); 1476 return t_hash_next(m, pos);
1471 1477
@@ -1518,6 +1524,10 @@ static void *t_start(struct seq_file *m, loff_t *pos)
1518 loff_t l; 1524 loff_t l;
1519 1525
1520 mutex_lock(&ftrace_lock); 1526 mutex_lock(&ftrace_lock);
1527
1528 if (unlikely(ftrace_disabled))
1529 return NULL;
1530
1521 /* 1531 /*
1522 * If an lseek was done, then reset and start from beginning. 1532 * If an lseek was done, then reset and start from beginning.
1523 */ 1533 */
@@ -1636,8 +1646,6 @@ static void ftrace_filter_reset(int enable)
1636 if (enable) 1646 if (enable)
1637 ftrace_filtered = 0; 1647 ftrace_filtered = 0;
1638 do_for_each_ftrace_rec(pg, rec) { 1648 do_for_each_ftrace_rec(pg, rec) {
1639 if (rec->flags & FTRACE_FL_FAILED)
1640 continue;
1641 rec->flags &= ~type; 1649 rec->flags &= ~type;
1642 } while_for_each_ftrace_rec(); 1650 } while_for_each_ftrace_rec();
1643 mutex_unlock(&ftrace_lock); 1651 mutex_unlock(&ftrace_lock);
@@ -1767,9 +1775,6 @@ static int ftrace_match_records(char *buff, int len, int enable)
1767 mutex_lock(&ftrace_lock); 1775 mutex_lock(&ftrace_lock);
1768 do_for_each_ftrace_rec(pg, rec) { 1776 do_for_each_ftrace_rec(pg, rec) {
1769 1777
1770 if (rec->flags & FTRACE_FL_FAILED)
1771 continue;
1772
1773 if (ftrace_match_record(rec, search, search_len, type)) { 1778 if (ftrace_match_record(rec, search, search_len, type)) {
1774 if (not) 1779 if (not)
1775 rec->flags &= ~flag; 1780 rec->flags &= ~flag;
@@ -1837,10 +1842,11 @@ static int ftrace_match_module_records(char *buff, char *mod, int enable)
1837 } 1842 }
1838 1843
1839 mutex_lock(&ftrace_lock); 1844 mutex_lock(&ftrace_lock);
1840 do_for_each_ftrace_rec(pg, rec) {
1841 1845
1842 if (rec->flags & FTRACE_FL_FAILED) 1846 if (unlikely(ftrace_disabled))
1843 continue; 1847 goto out_unlock;
1848
1849 do_for_each_ftrace_rec(pg, rec) {
1844 1850
1845 if (ftrace_match_module_record(rec, mod, 1851 if (ftrace_match_module_record(rec, mod,
1846 search, search_len, type)) { 1852 search, search_len, type)) {
@@ -1854,6 +1860,7 @@ static int ftrace_match_module_records(char *buff, char *mod, int enable)
1854 ftrace_filtered = 1; 1860 ftrace_filtered = 1;
1855 1861
1856 } while_for_each_ftrace_rec(); 1862 } while_for_each_ftrace_rec();
1863 out_unlock:
1857 mutex_unlock(&ftrace_lock); 1864 mutex_unlock(&ftrace_lock);
1858 1865
1859 return found; 1866 return found;
@@ -2008,10 +2015,11 @@ register_ftrace_function_probe(char *glob, struct ftrace_probe_ops *ops,
2008 return -EINVAL; 2015 return -EINVAL;
2009 2016
2010 mutex_lock(&ftrace_lock); 2017 mutex_lock(&ftrace_lock);
2011 do_for_each_ftrace_rec(pg, rec) {
2012 2018
2013 if (rec->flags & FTRACE_FL_FAILED) 2019 if (unlikely(ftrace_disabled))
2014 continue; 2020 goto out_unlock;
2021
2022 do_for_each_ftrace_rec(pg, rec) {
2015 2023
2016 if (!ftrace_match_record(rec, search, len, type)) 2024 if (!ftrace_match_record(rec, search, len, type))
2017 continue; 2025 continue;
@@ -2218,6 +2226,10 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
2218 2226
2219 mutex_lock(&ftrace_regex_lock); 2227 mutex_lock(&ftrace_regex_lock);
2220 2228
2229 ret = -ENODEV;
2230 if (unlikely(ftrace_disabled))
2231 goto out_unlock;
2232
2221 if (file->f_mode & FMODE_READ) { 2233 if (file->f_mode & FMODE_READ) {
2222 struct seq_file *m = file->private_data; 2234 struct seq_file *m = file->private_data;
2223 iter = m->private; 2235 iter = m->private;
@@ -2545,9 +2557,6 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer)
2545 bool exists; 2557 bool exists;
2546 int i; 2558 int i;
2547 2559
2548 if (ftrace_disabled)
2549 return -ENODEV;
2550
2551 /* decode regex */ 2560 /* decode regex */
2552 type = filter_parse_regex(buffer, strlen(buffer), &search, &not); 2561 type = filter_parse_regex(buffer, strlen(buffer), &search, &not);
2553 if (!not && *idx >= FTRACE_GRAPH_MAX_FUNCS) 2562 if (!not && *idx >= FTRACE_GRAPH_MAX_FUNCS)
@@ -2556,9 +2565,15 @@ ftrace_set_func(unsigned long *array, int *idx, char *buffer)
2556 search_len = strlen(search); 2565 search_len = strlen(search);
2557 2566
2558 mutex_lock(&ftrace_lock); 2567 mutex_lock(&ftrace_lock);
2568
2569 if (unlikely(ftrace_disabled)) {
2570 mutex_unlock(&ftrace_lock);
2571 return -ENODEV;
2572 }
2573
2559 do_for_each_ftrace_rec(pg, rec) { 2574 do_for_each_ftrace_rec(pg, rec) {
2560 2575
2561 if (rec->flags & (FTRACE_FL_FAILED | FTRACE_FL_FREE)) 2576 if (rec->flags & FTRACE_FL_FREE)
2562 continue; 2577 continue;
2563 2578
2564 if (ftrace_match_record(rec, search, search_len, type)) { 2579 if (ftrace_match_record(rec, search, search_len, type)) {
@@ -2700,10 +2715,11 @@ void ftrace_release_mod(struct module *mod)
2700 struct dyn_ftrace *rec; 2715 struct dyn_ftrace *rec;
2701 struct ftrace_page *pg; 2716 struct ftrace_page *pg;
2702 2717
2718 mutex_lock(&ftrace_lock);
2719
2703 if (ftrace_disabled) 2720 if (ftrace_disabled)
2704 return; 2721 goto out_unlock;
2705 2722
2706 mutex_lock(&ftrace_lock);
2707 do_for_each_ftrace_rec(pg, rec) { 2723 do_for_each_ftrace_rec(pg, rec) {
2708 if (within_module_core(rec->ip, mod)) { 2724 if (within_module_core(rec->ip, mod)) {
2709 /* 2725 /*
@@ -2714,6 +2730,7 @@ void ftrace_release_mod(struct module *mod)
2714 ftrace_free_rec(rec); 2730 ftrace_free_rec(rec);
2715 } 2731 }
2716 } while_for_each_ftrace_rec(); 2732 } while_for_each_ftrace_rec();
2733 out_unlock:
2717 mutex_unlock(&ftrace_lock); 2734 mutex_unlock(&ftrace_lock);
2718} 2735}
2719 2736
@@ -3108,16 +3125,17 @@ void ftrace_kill(void)
3108 */ 3125 */
3109int register_ftrace_function(struct ftrace_ops *ops) 3126int register_ftrace_function(struct ftrace_ops *ops)
3110{ 3127{
3111 int ret; 3128 int ret = -1;
3112
3113 if (unlikely(ftrace_disabled))
3114 return -1;
3115 3129
3116 mutex_lock(&ftrace_lock); 3130 mutex_lock(&ftrace_lock);
3117 3131
3132 if (unlikely(ftrace_disabled))
3133 goto out_unlock;
3134
3118 ret = __register_ftrace_function(ops); 3135 ret = __register_ftrace_function(ops);
3119 ftrace_startup(0); 3136 ftrace_startup(0);
3120 3137
3138 out_unlock:
3121 mutex_unlock(&ftrace_lock); 3139 mutex_unlock(&ftrace_lock);
3122 return ret; 3140 return ret;
3123} 3141}
@@ -3145,14 +3163,14 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
3145 void __user *buffer, size_t *lenp, 3163 void __user *buffer, size_t *lenp,
3146 loff_t *ppos) 3164 loff_t *ppos)
3147{ 3165{
3148 int ret; 3166 int ret = -ENODEV;
3149
3150 if (unlikely(ftrace_disabled))
3151 return -ENODEV;
3152 3167
3153 mutex_lock(&ftrace_lock); 3168 mutex_lock(&ftrace_lock);
3154 3169
3155 ret = proc_dointvec(table, write, buffer, lenp, ppos); 3170 if (unlikely(ftrace_disabled))
3171 goto out;
3172
3173 ret = proc_dointvec(table, write, buffer, lenp, ppos);
3156 3174
3157 if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled)) 3175 if (ret || !write || (last_ftrace_enabled == !!ftrace_enabled))
3158 goto out; 3176 goto out;