aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/trace.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-12-31 14:46:59 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-31 14:46:59 -0500
commit495d714ad140e1732e66c45d0409054b24c1a0d6 (patch)
tree373ec6619adea47d848d36f140b32def27164bbd /kernel/trace/trace.c
parentf12e840c819bab42621685558a01d3f46ab9a226 (diff)
parent3d739c1f6156c70eb0548aa288dcfbac9e0bd162 (diff)
Merge tag 'trace-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: - Rework of the kprobe/uprobe and synthetic events to consolidate all the dynamic event code. This will make changes in the future easier. - Partial rewrite of the function graph tracing infrastructure. This will allow for multiple users of hooking onto functions to get the callback (return) of the function. This is the ground work for having kprobes and function graph tracer using one code base. - Clean up of the histogram code that will facilitate adding more features to the histograms in the future. - Addition of str_has_prefix() and a few use cases. There currently is a similar function strstart() that is used in a few places, but only returns a bool and not a length. These instances will be removed in the future to use str_has_prefix() instead. - A few other various clean ups as well. * tag 'trace-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (57 commits) tracing: Use the return of str_has_prefix() to remove open coded numbers tracing: Have the historgram use the result of str_has_prefix() for len of prefix tracing: Use str_has_prefix() instead of using fixed sizes tracing: Use str_has_prefix() helper for histogram code string.h: Add str_has_prefix() helper function tracing: Make function ‘ftrace_exports’ static tracing: Simplify printf'ing in seq_print_sym tracing: Avoid -Wformat-nonliteral warning tracing: Merge seq_print_sym_short() and seq_print_sym_offset() tracing: Add hist trigger comments for variable-related fields tracing: Remove hist trigger synth_var_refs tracing: Use hist trigger's var_ref array to destroy var_refs tracing: Remove open-coding of hist trigger var_ref management tracing: Use var_refs[] for hist trigger reference checking tracing: Change strlen to sizeof for hist trigger static strings tracing: Remove unnecessary hist trigger struct field tracing: Fix ftrace_graph_get_ret_stack() to use task and not current seq_buf: Use size_t for len in seq_buf_puts() seq_buf: Make seq_buf_puts() null-terminate the buffer arm64: Use ftrace_graph_get_ret_stack() instead of curr_ret_stack ...
Diffstat (limited to 'kernel/trace/trace.c')
-rw-r--r--kernel/trace/trace.c82
1 files changed, 74 insertions, 8 deletions
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 51612b4a603f..c521b7347482 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1431,7 +1431,7 @@ update_max_tr_single(struct trace_array *tr, struct task_struct *tsk, int cpu)
1431} 1431}
1432#endif /* CONFIG_TRACER_MAX_TRACE */ 1432#endif /* CONFIG_TRACER_MAX_TRACE */
1433 1433
1434static int wait_on_pipe(struct trace_iterator *iter, bool full) 1434static int wait_on_pipe(struct trace_iterator *iter, int full)
1435{ 1435{
1436 /* Iterators are static, they should be filled or empty */ 1436 /* Iterators are static, they should be filled or empty */
1437 if (trace_buffer_iter(iter, iter->cpu_file)) 1437 if (trace_buffer_iter(iter, iter->cpu_file))
@@ -2452,7 +2452,7 @@ static inline void ftrace_exports_disable(void)
2452 static_branch_disable(&ftrace_exports_enabled); 2452 static_branch_disable(&ftrace_exports_enabled);
2453} 2453}
2454 2454
2455void ftrace_exports(struct ring_buffer_event *event) 2455static void ftrace_exports(struct ring_buffer_event *event)
2456{ 2456{
2457 struct trace_export *export; 2457 struct trace_export *export;
2458 2458
@@ -4408,13 +4408,15 @@ static int trace_set_options(struct trace_array *tr, char *option)
4408 int neg = 0; 4408 int neg = 0;
4409 int ret; 4409 int ret;
4410 size_t orig_len = strlen(option); 4410 size_t orig_len = strlen(option);
4411 int len;
4411 4412
4412 cmp = strstrip(option); 4413 cmp = strstrip(option);
4413 4414
4414 if (strncmp(cmp, "no", 2) == 0) { 4415 len = str_has_prefix(cmp, "no");
4416 if (len)
4415 neg = 1; 4417 neg = 1;
4416 cmp += 2; 4418
4417 } 4419 cmp += len;
4418 4420
4419 mutex_lock(&trace_types_lock); 4421 mutex_lock(&trace_types_lock);
4420 4422
@@ -4604,6 +4606,10 @@ static const char readme_msg[] =
4604 "\t\t\t traces\n" 4606 "\t\t\t traces\n"
4605#endif 4607#endif
4606#endif /* CONFIG_STACK_TRACER */ 4608#endif /* CONFIG_STACK_TRACER */
4609#ifdef CONFIG_DYNAMIC_EVENTS
4610 " dynamic_events\t\t- Add/remove/show the generic dynamic events\n"
4611 "\t\t\t Write into this file to define/undefine new trace events.\n"
4612#endif
4607#ifdef CONFIG_KPROBE_EVENTS 4613#ifdef CONFIG_KPROBE_EVENTS
4608 " kprobe_events\t\t- Add/remove/show the kernel dynamic events\n" 4614 " kprobe_events\t\t- Add/remove/show the kernel dynamic events\n"
4609 "\t\t\t Write into this file to define/undefine new trace events.\n" 4615 "\t\t\t Write into this file to define/undefine new trace events.\n"
@@ -4616,6 +4622,9 @@ static const char readme_msg[] =
4616 "\t accepts: event-definitions (one definition per line)\n" 4622 "\t accepts: event-definitions (one definition per line)\n"
4617 "\t Format: p[:[<group>/]<event>] <place> [<args>]\n" 4623 "\t Format: p[:[<group>/]<event>] <place> [<args>]\n"
4618 "\t r[maxactive][:[<group>/]<event>] <place> [<args>]\n" 4624 "\t r[maxactive][:[<group>/]<event>] <place> [<args>]\n"
4625#ifdef CONFIG_HIST_TRIGGERS
4626 "\t s:[synthetic/]<event> <field> [<field>]\n"
4627#endif
4619 "\t -:[<group>/]<event>\n" 4628 "\t -:[<group>/]<event>\n"
4620#ifdef CONFIG_KPROBE_EVENTS 4629#ifdef CONFIG_KPROBE_EVENTS
4621 "\t place: [<module>:]<symbol>[+<offset>]|<memaddr>\n" 4630 "\t place: [<module>:]<symbol>[+<offset>]|<memaddr>\n"
@@ -4634,6 +4643,11 @@ static const char readme_msg[] =
4634 "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string, symbol,\n" 4643 "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string, symbol,\n"
4635 "\t b<bit-width>@<bit-offset>/<container-size>,\n" 4644 "\t b<bit-width>@<bit-offset>/<container-size>,\n"
4636 "\t <type>\\[<array-size>\\]\n" 4645 "\t <type>\\[<array-size>\\]\n"
4646#ifdef CONFIG_HIST_TRIGGERS
4647 "\t field: <stype> <name>;\n"
4648 "\t stype: u8/u16/u32/u64, s8/s16/s32/s64, pid_t,\n"
4649 "\t [unsigned] char/int/long\n"
4650#endif
4637#endif 4651#endif
4638 " events/\t\t- Directory containing all trace event subsystems:\n" 4652 " events/\t\t- Directory containing all trace event subsystems:\n"
4639 " enable\t\t- Write 0/1 to enable/disable tracing of all events\n" 4653 " enable\t\t- Write 0/1 to enable/disable tracing of all events\n"
@@ -5693,7 +5707,7 @@ static int tracing_wait_pipe(struct file *filp)
5693 5707
5694 mutex_unlock(&iter->mutex); 5708 mutex_unlock(&iter->mutex);
5695 5709
5696 ret = wait_on_pipe(iter, false); 5710 ret = wait_on_pipe(iter, 0);
5697 5711
5698 mutex_lock(&iter->mutex); 5712 mutex_lock(&iter->mutex);
5699 5713
@@ -6751,7 +6765,7 @@ tracing_buffers_read(struct file *filp, char __user *ubuf,
6751 if ((filp->f_flags & O_NONBLOCK)) 6765 if ((filp->f_flags & O_NONBLOCK))
6752 return -EAGAIN; 6766 return -EAGAIN;
6753 6767
6754 ret = wait_on_pipe(iter, false); 6768 ret = wait_on_pipe(iter, 0);
6755 if (ret) 6769 if (ret)
6756 return ret; 6770 return ret;
6757 6771
@@ -6948,7 +6962,7 @@ tracing_buffers_splice_read(struct file *file, loff_t *ppos,
6948 if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK)) 6962 if ((file->f_flags & O_NONBLOCK) || (flags & SPLICE_F_NONBLOCK))
6949 goto out; 6963 goto out;
6950 6964
6951 ret = wait_on_pipe(iter, true); 6965 ret = wait_on_pipe(iter, iter->tr->buffer_percent);
6952 if (ret) 6966 if (ret)
6953 goto out; 6967 goto out;
6954 6968
@@ -7662,6 +7676,53 @@ static const struct file_operations rb_simple_fops = {
7662 .llseek = default_llseek, 7676 .llseek = default_llseek,
7663}; 7677};
7664 7678
7679static ssize_t
7680buffer_percent_read(struct file *filp, char __user *ubuf,
7681 size_t cnt, loff_t *ppos)
7682{
7683 struct trace_array *tr = filp->private_data;
7684 char buf[64];
7685 int r;
7686
7687 r = tr->buffer_percent;
7688 r = sprintf(buf, "%d\n", r);
7689
7690 return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
7691}
7692
7693static ssize_t
7694buffer_percent_write(struct file *filp, const char __user *ubuf,
7695 size_t cnt, loff_t *ppos)
7696{
7697 struct trace_array *tr = filp->private_data;
7698 unsigned long val;
7699 int ret;
7700
7701 ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
7702 if (ret)
7703 return ret;
7704
7705 if (val > 100)
7706 return -EINVAL;
7707
7708 if (!val)
7709 val = 1;
7710
7711 tr->buffer_percent = val;
7712
7713 (*ppos)++;
7714
7715 return cnt;
7716}
7717
7718static const struct file_operations buffer_percent_fops = {
7719 .open = tracing_open_generic_tr,
7720 .read = buffer_percent_read,
7721 .write = buffer_percent_write,
7722 .release = tracing_release_generic_tr,
7723 .llseek = default_llseek,
7724};
7725
7665struct dentry *trace_instance_dir; 7726struct dentry *trace_instance_dir;
7666 7727
7667static void 7728static void
@@ -7970,6 +8031,11 @@ init_tracer_tracefs(struct trace_array *tr, struct dentry *d_tracer)
7970 trace_create_file("timestamp_mode", 0444, d_tracer, tr, 8031 trace_create_file("timestamp_mode", 0444, d_tracer, tr,
7971 &trace_time_stamp_mode_fops); 8032 &trace_time_stamp_mode_fops);
7972 8033
8034 tr->buffer_percent = 50;
8035
8036 trace_create_file("buffer_percent", 0444, d_tracer,
8037 tr, &buffer_percent_fops);
8038
7973 create_trace_options_dir(tr); 8039 create_trace_options_dir(tr);
7974 8040
7975#if defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER) 8041#if defined(CONFIG_TRACER_MAX_TRACE) || defined(CONFIG_HWLAT_TRACER)