Commit 52baf119 authored by Steven Rostedt's avatar Steven Rostedt

ftrace: convert ftrace_lock from a spinlock to mutex

Impact: clean up

The older versions of ftrace required doing the ftrace list
search under atomic context. Now all the calls are in non-atomic
context. There is no reason to keep the ftrace_lock as a spinlock.

This patch converts it to a mutex.
Signed-off-by: default avatarSteven Rostedt <srostedt@redhat.com>
parent f6180773
...@@ -61,7 +61,7 @@ int function_trace_stop; ...@@ -61,7 +61,7 @@ int function_trace_stop;
*/ */
static int ftrace_disabled __read_mostly; static int ftrace_disabled __read_mostly;
static DEFINE_SPINLOCK(ftrace_lock); static DEFINE_MUTEX(ftrace_lock);
static DEFINE_MUTEX(ftrace_sysctl_lock); static DEFINE_MUTEX(ftrace_sysctl_lock);
static DEFINE_MUTEX(ftrace_start_lock); static DEFINE_MUTEX(ftrace_start_lock);
...@@ -134,8 +134,7 @@ static void ftrace_test_stop_func(unsigned long ip, unsigned long parent_ip) ...@@ -134,8 +134,7 @@ static void ftrace_test_stop_func(unsigned long ip, unsigned long parent_ip)
static int __register_ftrace_function(struct ftrace_ops *ops) static int __register_ftrace_function(struct ftrace_ops *ops)
{ {
/* should not be called from interrupt context */ mutex_lock(&ftrace_lock);
spin_lock(&ftrace_lock);
ops->next = ftrace_list; ops->next = ftrace_list;
/* /*
...@@ -172,7 +171,7 @@ static int __register_ftrace_function(struct ftrace_ops *ops) ...@@ -172,7 +171,7 @@ static int __register_ftrace_function(struct ftrace_ops *ops)
#endif #endif
} }
spin_unlock(&ftrace_lock); mutex_unlock(&ftrace_lock);
return 0; return 0;
} }
...@@ -182,8 +181,7 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops) ...@@ -182,8 +181,7 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops)
struct ftrace_ops **p; struct ftrace_ops **p;
int ret = 0; int ret = 0;
/* should not be called from interrupt context */ mutex_lock(&ftrace_lock);
spin_lock(&ftrace_lock);
/* /*
* If we are removing the last function, then simply point * If we are removing the last function, then simply point
...@@ -224,7 +222,7 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops) ...@@ -224,7 +222,7 @@ static int __unregister_ftrace_function(struct ftrace_ops *ops)
} }
out: out:
spin_unlock(&ftrace_lock); mutex_unlock(&ftrace_lock);
return ret; return ret;
} }
...@@ -233,8 +231,7 @@ static void ftrace_update_pid_func(void) ...@@ -233,8 +231,7 @@ static void ftrace_update_pid_func(void)
{ {
ftrace_func_t func; ftrace_func_t func;
/* should not be called from interrupt context */ mutex_lock(&ftrace_lock);
spin_lock(&ftrace_lock);
if (ftrace_trace_function == ftrace_stub) if (ftrace_trace_function == ftrace_stub)
goto out; goto out;
...@@ -256,7 +253,7 @@ static void ftrace_update_pid_func(void) ...@@ -256,7 +253,7 @@ static void ftrace_update_pid_func(void)
#endif #endif
out: out:
spin_unlock(&ftrace_lock); mutex_unlock(&ftrace_lock);
} }
#ifdef CONFIG_DYNAMIC_FTRACE #ifdef CONFIG_DYNAMIC_FTRACE
...@@ -358,15 +355,12 @@ void ftrace_release(void *start, unsigned long size) ...@@ -358,15 +355,12 @@ void ftrace_release(void *start, unsigned long size)
if (ftrace_disabled || !start) if (ftrace_disabled || !start)
return; return;
/* should not be called from interrupt context */ mutex_lock(&ftrace_lock);
spin_lock(&ftrace_lock);
do_for_each_ftrace_rec(pg, rec) { do_for_each_ftrace_rec(pg, rec) {
if ((rec->ip >= s) && (rec->ip < e)) if ((rec->ip >= s) && (rec->ip < e))
ftrace_free_rec(rec); ftrace_free_rec(rec);
} while_for_each_ftrace_rec(); } while_for_each_ftrace_rec();
mutex_unlock(&ftrace_lock);
spin_unlock(&ftrace_lock);
} }
static struct dyn_ftrace *ftrace_alloc_dyn_node(unsigned long ip) static struct dyn_ftrace *ftrace_alloc_dyn_node(unsigned long ip)
...@@ -803,8 +797,7 @@ t_next(struct seq_file *m, void *v, loff_t *pos) ...@@ -803,8 +797,7 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
if (iter->flags & FTRACE_ITER_PRINTALL) if (iter->flags & FTRACE_ITER_PRINTALL)
return NULL; return NULL;
/* should not be called from interrupt context */ mutex_lock(&ftrace_lock);
spin_lock(&ftrace_lock);
retry: retry:
if (iter->idx >= iter->pg->index) { if (iter->idx >= iter->pg->index) {
if (iter->pg->next) { if (iter->pg->next) {
...@@ -833,7 +826,7 @@ t_next(struct seq_file *m, void *v, loff_t *pos) ...@@ -833,7 +826,7 @@ t_next(struct seq_file *m, void *v, loff_t *pos)
goto retry; goto retry;
} }
} }
spin_unlock(&ftrace_lock); mutex_unlock(&ftrace_lock);
return rec; return rec;
} }
...@@ -962,8 +955,7 @@ static void ftrace_filter_reset(int enable) ...@@ -962,8 +955,7 @@ static void ftrace_filter_reset(int enable)
struct dyn_ftrace *rec; struct dyn_ftrace *rec;
unsigned long type = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE; unsigned long type = enable ? FTRACE_FL_FILTER : FTRACE_FL_NOTRACE;
/* should not be called from interrupt context */ mutex_lock(&ftrace_lock);
spin_lock(&ftrace_lock);
if (enable) if (enable)
ftrace_filtered = 0; ftrace_filtered = 0;
do_for_each_ftrace_rec(pg, rec) { do_for_each_ftrace_rec(pg, rec) {
...@@ -971,8 +963,7 @@ static void ftrace_filter_reset(int enable) ...@@ -971,8 +963,7 @@ static void ftrace_filter_reset(int enable)
continue; continue;
rec->flags &= ~type; rec->flags &= ~type;
} while_for_each_ftrace_rec(); } while_for_each_ftrace_rec();
mutex_unlock(&ftrace_lock);
spin_unlock(&ftrace_lock);
} }
static int static int
...@@ -1151,8 +1142,7 @@ static void ftrace_match_records(char *buff, int len, int enable) ...@@ -1151,8 +1142,7 @@ static void ftrace_match_records(char *buff, int len, int enable)
search_len = strlen(search); search_len = strlen(search);
/* should not be called from interrupt context */ mutex_lock(&ftrace_lock);
spin_lock(&ftrace_lock);
do_for_each_ftrace_rec(pg, rec) { do_for_each_ftrace_rec(pg, rec) {
if (rec->flags & FTRACE_FL_FAILED) if (rec->flags & FTRACE_FL_FAILED)
...@@ -1171,7 +1161,7 @@ static void ftrace_match_records(char *buff, int len, int enable) ...@@ -1171,7 +1161,7 @@ static void ftrace_match_records(char *buff, int len, int enable)
if (enable && (rec->flags & FTRACE_FL_FILTER)) if (enable && (rec->flags & FTRACE_FL_FILTER))
ftrace_filtered = 1; ftrace_filtered = 1;
} while_for_each_ftrace_rec(); } while_for_each_ftrace_rec();
spin_unlock(&ftrace_lock); mutex_unlock(&ftrace_lock);
} }
static int static int
...@@ -1218,8 +1208,7 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable) ...@@ -1218,8 +1208,7 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable)
search_len = strlen(search); search_len = strlen(search);
} }
/* should not be called from interrupt context */ mutex_lock(&ftrace_lock);
spin_lock(&ftrace_lock);
do_for_each_ftrace_rec(pg, rec) { do_for_each_ftrace_rec(pg, rec) {
if (rec->flags & FTRACE_FL_FAILED) if (rec->flags & FTRACE_FL_FAILED)
...@@ -1236,7 +1225,7 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable) ...@@ -1236,7 +1225,7 @@ static void ftrace_match_module_records(char *buff, char *mod, int enable)
ftrace_filtered = 1; ftrace_filtered = 1;
} while_for_each_ftrace_rec(); } while_for_each_ftrace_rec();
spin_unlock(&ftrace_lock); mutex_unlock(&ftrace_lock);
} }
/* /*
...@@ -1676,9 +1665,7 @@ ftrace_set_func(unsigned long *array, int idx, char *buffer) ...@@ -1676,9 +1665,7 @@ ftrace_set_func(unsigned long *array, int idx, char *buffer)
if (ftrace_disabled) if (ftrace_disabled)
return -ENODEV; return -ENODEV;
/* should not be called from interrupt context */ mutex_lock(&ftrace_lock);
spin_lock(&ftrace_lock);
do_for_each_ftrace_rec(pg, rec) { do_for_each_ftrace_rec(pg, rec) {
if (rec->flags & (FTRACE_FL_FAILED | FTRACE_FL_FREE)) if (rec->flags & (FTRACE_FL_FAILED | FTRACE_FL_FREE))
...@@ -1699,7 +1686,7 @@ ftrace_set_func(unsigned long *array, int idx, char *buffer) ...@@ -1699,7 +1686,7 @@ ftrace_set_func(unsigned long *array, int idx, char *buffer)
} }
} while_for_each_ftrace_rec(); } while_for_each_ftrace_rec();
out: out:
spin_unlock(&ftrace_lock); mutex_unlock(&ftrace_lock);
return found ? 0 : -EINVAL; return found ? 0 : -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment