ftrace: Narrow down the protected area of graph_lock
The parser set up is just a generic utility that uses local variables allocated by the function. There's no need to hold the graph_lock for this set up. This also makes the code simpler. Link: http://lkml.kernel.org/r/1381739066-7531-4-git-send-email-namhyung@kernel.org Signed-off-by: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt
parent
faf982a60f
commit
6a10108bdb
@@ -3973,37 +3973,33 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
|
|||||||
size_t cnt, loff_t *ppos)
|
size_t cnt, loff_t *ppos)
|
||||||
{
|
{
|
||||||
struct trace_parser parser;
|
struct trace_parser parser;
|
||||||
ssize_t read, ret;
|
ssize_t read, ret = 0;
|
||||||
struct ftrace_graph_data *fgd = file->private_data;
|
struct ftrace_graph_data *fgd = file->private_data;
|
||||||
|
|
||||||
if (!cnt)
|
if (!cnt)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
mutex_lock(&graph_lock);
|
if (trace_parser_get_init(&parser, FTRACE_BUFF_MAX))
|
||||||
|
return -ENOMEM;
|
||||||
if (trace_parser_get_init(&parser, FTRACE_BUFF_MAX)) {
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto out_unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
read = trace_get_user(&parser, ubuf, cnt, ppos);
|
read = trace_get_user(&parser, ubuf, cnt, ppos);
|
||||||
|
|
||||||
if (read >= 0 && trace_parser_loaded((&parser))) {
|
if (read >= 0 && trace_parser_loaded((&parser))) {
|
||||||
parser.buffer[parser.idx] = 0;
|
parser.buffer[parser.idx] = 0;
|
||||||
|
|
||||||
|
mutex_lock(&graph_lock);
|
||||||
|
|
||||||
/* we allow only one expression at a time */
|
/* we allow only one expression at a time */
|
||||||
ret = ftrace_set_func(fgd->table, fgd->count, fgd->size,
|
ret = ftrace_set_func(fgd->table, fgd->count, fgd->size,
|
||||||
parser.buffer);
|
parser.buffer);
|
||||||
if (ret)
|
|
||||||
goto out_free;
|
mutex_unlock(&graph_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
ret = read;
|
ret = read;
|
||||||
|
|
||||||
out_free:
|
|
||||||
trace_parser_put(&parser);
|
trace_parser_put(&parser);
|
||||||
out_unlock:
|
|
||||||
mutex_unlock(&graph_lock);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user