aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-03-09 21:44:06 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-03-09 21:44:06 -0400
commite7901af14398bf0272e523936d0774b4469741a8 (patch)
tree1259f6f2632ea31673ddf7bcee0315aca2810cbb /kernel
parent36bef88380037288d5b575ed2029de694533b1ec (diff)
parent524a38682573b2e15ab6317ccfe50280441514be (diff)
Merge tag 'trace-fixes-v4.0-rc2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull seq-buf/ftrace fixes from Steven Rostedt: "This includes fixes for seq_buf_bprintf() truncation issue. It also contains fixes to ftrace when /proc/sys/kernel/ftrace_enabled and function tracing are started. Doing the following causes some issues: # echo 0 > /proc/sys/kernel/ftrace_enabled # echo function_graph > /sys/kernel/debug/tracing/current_tracer # echo 1 > /proc/sys/kernel/ftrace_enabled # echo nop > /sys/kernel/debug/tracing/current_tracer # echo function_graph > /sys/kernel/debug/tracing/current_tracer As well as with function tracing too. Pratyush Anand first reported this issue to me and supplied a patch. When I tested this on my x86 test box, it caused thousands of backtraces and warnings to appear in dmesg, which also caused a denial of service (a warning for every function that was listed). I applied Pratyush's patch but it did not fix the issue for me. I looked into it and found a slight problem with trampoline accounting. I fixed it and sent Pratyush a patch, but he said that it did not fix the issue for him. I later learned tha Pratyush was using an ARM64 server, and when I tested on my ARM board, I was able to reproduce the same issue as Pratyush. After applying his patch, it fixed the problem. The above test uncovered two different bugs, one in x86 and one in ARM and ARM64. As this looked like it would affect PowerPC, I tested it on my PPC64 box. It too broke, but neither the patch that fixed ARM or x86 fixed this box (the changes were all in generic code!). The above test, uncovered two more bugs that affected PowerPC. Again, the changes were only done to generic code. It's the way the arch code expected things to be done that was different between the archs. Some where more sensitive than others. The rest of this series fixes the PPC bugs as well" * tag 'trace-fixes-v4.0-rc2-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: ftrace: Fix ftrace enable ordering of sysctl ftrace_enabled ftrace: Fix en(dis)able graph caller when en(dis)abling record via sysctl ftrace: Clear REGS_EN and TRAMP_EN flags on disabling record via sysctl seq_buf: Fix seq_buf_bprintf() truncation seq_buf: Fix seq_buf_vprintf() truncation
Diffstat (limited to 'kernel')
-rw-r--r--kernel/trace/ftrace.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 45e5cb143d17..4f228024055b 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1059,6 +1059,12 @@ static __init void ftrace_profile_debugfs(struct dentry *d_tracer)
1059 1059
1060static struct pid * const ftrace_swapper_pid = &init_struct_pid; 1060static struct pid * const ftrace_swapper_pid = &init_struct_pid;
1061 1061
1062#ifdef CONFIG_FUNCTION_GRAPH_TRACER
1063static int ftrace_graph_active;
1064#else
1065# define ftrace_graph_active 0
1066#endif
1067
1062#ifdef CONFIG_DYNAMIC_FTRACE 1068#ifdef CONFIG_DYNAMIC_FTRACE
1063 1069
1064static struct ftrace_ops *removed_ops; 1070static struct ftrace_ops *removed_ops;
@@ -2041,8 +2047,12 @@ static int ftrace_check_record(struct dyn_ftrace *rec, int enable, int update)
2041 if (!ftrace_rec_count(rec)) 2047 if (!ftrace_rec_count(rec))
2042 rec->flags = 0; 2048 rec->flags = 0;
2043 else 2049 else
2044 /* Just disable the record (keep REGS state) */ 2050 /*
2045 rec->flags &= ~FTRACE_FL_ENABLED; 2051 * Just disable the record, but keep the ops TRAMP
2052 * and REGS states. The _EN flags must be disabled though.
2053 */
2054 rec->flags &= ~(FTRACE_FL_ENABLED | FTRACE_FL_TRAMP_EN |
2055 FTRACE_FL_REGS_EN);
2046 } 2056 }
2047 2057
2048 return FTRACE_UPDATE_MAKE_NOP; 2058 return FTRACE_UPDATE_MAKE_NOP;
@@ -2688,24 +2698,36 @@ static int ftrace_shutdown(struct ftrace_ops *ops, int command)
2688 2698
2689static void ftrace_startup_sysctl(void) 2699static void ftrace_startup_sysctl(void)
2690{ 2700{
2701 int command;
2702
2691 if (unlikely(ftrace_disabled)) 2703 if (unlikely(ftrace_disabled))
2692 return; 2704 return;
2693 2705
2694 /* Force update next time */ 2706 /* Force update next time */
2695 saved_ftrace_func = NULL; 2707 saved_ftrace_func = NULL;
2696 /* ftrace_start_up is true if we want ftrace running */ 2708 /* ftrace_start_up is true if we want ftrace running */
2697 if (ftrace_start_up) 2709 if (ftrace_start_up) {
2698 ftrace_run_update_code(FTRACE_UPDATE_CALLS); 2710 command = FTRACE_UPDATE_CALLS;
2711 if (ftrace_graph_active)
2712 command |= FTRACE_START_FUNC_RET;
2713 ftrace_startup_enable(command);
2714 }
2699} 2715}
2700 2716
2701static void ftrace_shutdown_sysctl(void) 2717static void ftrace_shutdown_sysctl(void)
2702{ 2718{
2719 int command;
2720
2703 if (unlikely(ftrace_disabled)) 2721 if (unlikely(ftrace_disabled))
2704 return; 2722 return;
2705 2723
2706 /* ftrace_start_up is true if ftrace is running */ 2724 /* ftrace_start_up is true if ftrace is running */
2707 if (ftrace_start_up) 2725 if (ftrace_start_up) {
2708 ftrace_run_update_code(FTRACE_DISABLE_CALLS); 2726 command = FTRACE_DISABLE_CALLS;
2727 if (ftrace_graph_active)
2728 command |= FTRACE_STOP_FUNC_RET;
2729 ftrace_run_update_code(command);
2730 }
2709} 2731}
2710 2732
2711static cycle_t ftrace_update_time; 2733static cycle_t ftrace_update_time;
@@ -5558,12 +5580,12 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
5558 5580
5559 if (ftrace_enabled) { 5581 if (ftrace_enabled) {
5560 5582
5561 ftrace_startup_sysctl();
5562
5563 /* we are starting ftrace again */ 5583 /* we are starting ftrace again */
5564 if (ftrace_ops_list != &ftrace_list_end) 5584 if (ftrace_ops_list != &ftrace_list_end)
5565 update_ftrace_function(); 5585 update_ftrace_function();
5566 5586
5587 ftrace_startup_sysctl();
5588
5567 } else { 5589 } else {
5568 /* stopping ftrace calls (just send to ftrace_stub) */ 5590 /* stopping ftrace calls (just send to ftrace_stub) */
5569 ftrace_trace_function = ftrace_stub; 5591 ftrace_trace_function = ftrace_stub;
@@ -5590,8 +5612,6 @@ static struct ftrace_ops graph_ops = {
5590 ASSIGN_OPS_HASH(graph_ops, &global_ops.local_hash) 5612 ASSIGN_OPS_HASH(graph_ops, &global_ops.local_hash)
5591}; 5613};
5592 5614
5593static int ftrace_graph_active;
5594
5595int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace) 5615int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
5596{ 5616{
5597 return 0; 5617 return 0;