aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-04 14:50:00 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-04 14:50:00 -0400
commitb8c0aa46b3e86083721b57ed2eec6bd2c29ebfba (patch)
tree45e349bf8a14aa99279d323fdc515e849fd349f3 /kernel/trace/trace.c
parentc7ed326fa7cafb83ced5a8b02517a61672fe9e90 (diff)
parentdc6f03f26f570104a2bb03f9d1deb588026d7c75 (diff)
Merge tag 'trace-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: "This pull request has a lot of work done. The main thing is the changes to the ftrace function callback infrastructure. It's introducing a way to allow different functions to call directly different trampolines instead of all calling the same "mcount" one. The only user of this for now is the function graph tracer, which always had a different trampoline, but the function tracer trampoline was called and did basically nothing, and then the function graph tracer trampoline was called. The difference now, is that the function graph tracer trampoline can be called directly if a function is only being traced by the function graph trampoline. If function tracing is also happening on the same function, the old way is still done. The accounting for this takes up more memory when function graph tracing is activated, as it needs to keep track of which functions it uses. I have a new way that wont take as much memory, but it's not ready yet for this merge window, and will have to wait for the next one. Another big change was the removal of the ftrace_start/stop() calls that were used by the suspend/resume code that stopped function tracing when entering into suspend and resume paths. The stop of ftrace was done because there was some function that would crash the system if one called smp_processor_id()! The stop/start was a big hammer to solve the issue at the time, which was when ftrace was first introduced into Linux. Now ftrace has better infrastructure to debug such issues, and I found the problem function and labeled it with "notrace" and function tracing can now safely be activated all the way down into the guts of suspend and resume Other changes include clean ups of uprobe code, clean up of the trace_seq() code, and other various small fixes and clean ups to ftrace and tracing" * tag 'trace-3.17' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (57 commits) ftrace: Add warning if tramp hash does not match nr_trampolines ftrace: Fix trampoline hash update check on rec->flags ring-buffer: Use rb_page_size() instead of open coded head_page size ftrace: Rename ftrace_ops field from trampolines to nr_trampolines tracing: Convert local function_graph functions to static ftrace: Do not copy old hash when resetting tracing: let user specify tracing_thresh after selecting function_graph ring-buffer: Always run per-cpu ring buffer resize with schedule_work_on() tracing: Remove function_trace_stop and HAVE_FUNCTION_TRACE_MCOUNT_TEST s390/ftrace: remove check of obsolete variable function_trace_stop arm64, ftrace: Remove check of obsolete variable function_trace_stop Blackfin: ftrace: Remove check of obsolete variable function_trace_stop metag: ftrace: Remove check of obsolete variable function_trace_stop microblaze: ftrace: Remove check of obsolete variable function_trace_stop MIPS: ftrace: Remove check of obsolete variable function_trace_stop parisc: ftrace: Remove check of obsolete variable function_trace_stop sh: ftrace: Remove check of obsolete variable function_trace_stop sparc64,ftrace: Remove check of obsolete variable function_trace_stop tile: ftrace: Remove check of obsolete variable function_trace_stop ftrace: x86: Remove check of obsolete variable function_trace_stop ...
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c96
1 files changed, 61 insertions, 35 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 291397e66669..8bb80fe08767 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -937,30 +937,6 @@ out:
937 return ret; 937 return ret;
938} 938}
939 939
940ssize_t trace_seq_to_user(struct trace_seq *s, char __user *ubuf, size_t cnt)
941{
942 int len;
943 int ret;
944
945 if (!cnt)
946 return 0;
947
948 if (s->len <= s->readpos)
949 return -EBUSY;
950
951 len = s->len - s->readpos;
952 if (cnt > len)
953 cnt = len;
954 ret = copy_to_user(ubuf, s->buffer + s->readpos, cnt);
955 if (ret == cnt)
956 return -EFAULT;
957
958 cnt -= ret;
959
960 s->readpos += cnt;
961 return cnt;
962}
963
964static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt) 940static ssize_t trace_seq_to_buffer(struct trace_seq *s, void *buf, size_t cnt)
965{ 941{
966 int len; 942 int len;
@@ -3699,6 +3675,7 @@ static const char readme_msg[] =
3699#endif 3675#endif
3700#ifdef CONFIG_FUNCTION_GRAPH_TRACER 3676#ifdef CONFIG_FUNCTION_GRAPH_TRACER
3701 " set_graph_function\t- Trace the nested calls of a function (function_graph)\n" 3677 " set_graph_function\t- Trace the nested calls of a function (function_graph)\n"
3678 " set_graph_notrace\t- Do not trace the nested calls of a function (function_graph)\n"
3702 " max_graph_depth\t- Trace a limited depth of nested calls (0 is unlimited)\n" 3679 " max_graph_depth\t- Trace a limited depth of nested calls (0 is unlimited)\n"
3703#endif 3680#endif
3704#ifdef CONFIG_TRACER_SNAPSHOT 3681#ifdef CONFIG_TRACER_SNAPSHOT
@@ -4238,10 +4215,9 @@ tracing_set_trace_write(struct file *filp, const char __user *ubuf,
4238} 4215}
4239 4216
4240static ssize_t 4217static ssize_t
4241tracing_max_lat_read(struct file *filp, char __user *ubuf, 4218tracing_nsecs_read(unsigned long *ptr, char __user *ubuf,
4242 size_t cnt, loff_t *ppos) 4219 size_t cnt, loff_t *ppos)
4243{ 4220{
4244 unsigned long *ptr = filp->private_data;
4245 char buf[64]; 4221 char buf[64];
4246 int r; 4222 int r;
4247 4223
@@ -4253,10 +4229,9 @@ tracing_max_lat_read(struct file *filp, char __user *ubuf,
4253} 4229}
4254 4230
4255static ssize_t 4231static ssize_t
4256tracing_max_lat_write(struct file *filp, const char __user *ubuf, 4232tracing_nsecs_write(unsigned long *ptr, const char __user *ubuf,
4257 size_t cnt, loff_t *ppos) 4233 size_t cnt, loff_t *ppos)
4258{ 4234{
4259 unsigned long *ptr = filp->private_data;
4260 unsigned long val; 4235 unsigned long val;
4261 int ret; 4236 int ret;
4262 4237
@@ -4269,6 +4244,52 @@ tracing_max_lat_write(struct file *filp, const char __user *ubuf,
4269 return cnt; 4244 return cnt;
4270} 4245}
4271 4246
4247static ssize_t
4248tracing_thresh_read(struct file *filp, char __user *ubuf,
4249 size_t cnt, loff_t *ppos)
4250{
4251 return tracing_nsecs_read(&tracing_thresh, ubuf, cnt, ppos);
4252}
4253
4254static ssize_t
4255tracing_thresh_write(struct file *filp, const char __user *ubuf,
4256 size_t cnt, loff_t *ppos)
4257{
4258 struct trace_array *tr = filp->private_data;
4259 int ret;
4260
4261 mutex_lock(&trace_types_lock);
4262 ret = tracing_nsecs_write(&tracing_thresh, ubuf, cnt, ppos);
4263 if (ret < 0)
4264 goto out;
4265
4266 if (tr->current_trace->update_thresh) {
4267 ret = tr->current_trace->update_thresh(tr);
4268 if (ret < 0)
4269 goto out;
4270 }
4271
4272 ret = cnt;
4273out:
4274 mutex_unlock(&trace_types_lock);
4275
4276 return ret;
4277}
4278
4279static ssize_t
4280tracing_max_lat_read(struct file *filp, char __user *ubuf,
4281 size_t cnt, loff_t *ppos)
4282{
4283 return tracing_nsecs_read(filp->private_data, ubuf, cnt, ppos);
4284}
4285
4286static ssize_t
4287tracing_max_lat_write(struct file *filp, const char __user *ubuf,
4288 size_t cnt, loff_t *ppos)
4289{
4290 return tracing_nsecs_write(filp->private_data, ubuf, cnt, ppos);
4291}
4292
4272static int tracing_open_pipe(struct inode *inode, struct file *filp) 4293static int tracing_open_pipe(struct inode *inode, struct file *filp)
4273{ 4294{
4274 struct trace_array *tr = inode->i_private; 4295 struct trace_array *tr = inode->i_private;
@@ -5170,6 +5191,13 @@ static int snapshot_raw_open(struct inode *inode, struct file *filp)
5170#endif /* CONFIG_TRACER_SNAPSHOT */ 5191#endif /* CONFIG_TRACER_SNAPSHOT */
5171 5192
5172 5193
5194static const struct file_operations tracing_thresh_fops = {
5195 .open = tracing_open_generic,
5196 .read = tracing_thresh_read,
5197 .write = tracing_thresh_write,
5198 .llseek = generic_file_llseek,
5199};
5200
5173static const struct file_operations tracing_max_lat_fops = { 5201static const struct file_operations tracing_max_lat_fops = {
5174 .open = tracing_open_generic, 5202 .open = tracing_open_generic,
5175 .read = tracing_max_lat_read, 5203 .read = tracing_max_lat_read,
@@ -6107,10 +6135,8 @@ destroy_trace_option_files(struct trace_option_dentry *topts)
6107 if (!topts) 6135 if (!topts)
6108 return; 6136 return;
6109 6137
6110 for (cnt = 0; topts[cnt].opt; cnt++) { 6138 for (cnt = 0; topts[cnt].opt; cnt++)
6111 if (topts[cnt].entry) 6139 debugfs_remove(topts[cnt].entry);
6112 debugfs_remove(topts[cnt].entry);
6113 }
6114 6140
6115 kfree(topts); 6141 kfree(topts);
6116} 6142}
@@ -6533,7 +6559,7 @@ static __init int tracer_init_debugfs(void)
6533 init_tracer_debugfs(&global_trace, d_tracer); 6559 init_tracer_debugfs(&global_trace, d_tracer);
6534 6560
6535 trace_create_file("tracing_thresh", 0644, d_tracer, 6561 trace_create_file("tracing_thresh", 0644, d_tracer,
6536 &tracing_thresh, &tracing_max_lat_fops); 6562 &global_trace, &tracing_thresh_fops);
6537 6563
6538 trace_create_file("README", 0444, d_tracer, 6564 trace_create_file("README", 0444, d_tracer,
6539 NULL, &tracing_readme_fops); 6565 NULL, &tracing_readme_fops);