Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'trace-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull tracing fixes from Steven Rostedt:

- Fix a bug caused by not cleaning up the new instance unique triggers
when deleting an instance. It also creates a selftest that triggers
that bug.

- Fix the delayed optimization happening after kprobes boot up self
tests being removed by freeing of init memory.

- Comment kprobes on why the delay optimization is not a problem for
removal of modules, to keep other developers from searching that
riddle.

- Fix another case of rcu not watching in stack trace tracing.

* tag 'trace-v4.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace:
tracing: Make sure RCU is watching before calling a stack trace
kprobes: Document how optimized kprobes are removed from module unload
selftests/ftrace: Add test to remove instance with active event triggers
selftests/ftrace: Fix bashisms
ftrace: Remove #ifdef from code and add clear_ftrace_function_probes() stub
ftrace/instances: Clear function triggers when removing instances
ftrace: Simplify glob handling in unregister_ftrace_function_probe_func()
tracing/kprobes: Enforce kprobes teardown after testing
tracing: Move postpone selftests to core from early_initcall

+72 -11
+3
include/linux/kprobes.h
··· 349 349 int write, void __user *buffer, 350 350 size_t *length, loff_t *ppos); 351 351 #endif 352 + extern void wait_for_kprobe_optimizer(void); 353 + #else 354 + static inline void wait_for_kprobe_optimizer(void) { } 352 355 #endif /* CONFIG_OPTPROBES */ 353 356 #ifdef CONFIG_KPROBES_ON_FTRACE 354 357 extern void kprobe_ftrace_handler(unsigned long ip, unsigned long parent_ip,
+7 -1
kernel/kprobes.c
··· 595 595 } 596 596 597 597 /* Wait for completing optimization and unoptimization */ 598 - static void wait_for_kprobe_optimizer(void) 598 + void wait_for_kprobe_optimizer(void) 599 599 { 600 600 mutex_lock(&kprobe_mutex); 601 601 ··· 2183 2183 * The vaddr this probe is installed will soon 2184 2184 * be vfreed buy not synced to disk. Hence, 2185 2185 * disarming the breakpoint isn't needed. 2186 + * 2187 + * Note, this will also move any optimized probes 2188 + * that are pending to be removed from their 2189 + * corresponding lists to the freeing_list and 2190 + * will not be touched by the delayed 2191 + * kprobe_optimizer work handler. 2186 2192 */ 2187 2193 kill_kprobe(p); 2188 2194 }
+10 -2
kernel/trace/ftrace.c
··· 4144 4144 int i, ret = -ENODEV; 4145 4145 int size; 4146 4146 4147 - if (glob && (strcmp(glob, "*") == 0 || !strlen(glob))) 4147 + if (!glob || !strlen(glob) || !strcmp(glob, "*")) 4148 4148 func_g.search = NULL; 4149 - else if (glob) { 4149 + else { 4150 4150 int not; 4151 4151 4152 4152 func_g.type = filter_parse_regex(glob, strlen(glob), ··· 4254 4254 err_unlock_ftrace: 4255 4255 mutex_unlock(&ftrace_lock); 4256 4256 return ret; 4257 + } 4258 + 4259 + void clear_ftrace_function_probes(struct trace_array *tr) 4260 + { 4261 + struct ftrace_func_probe *probe, *n; 4262 + 4263 + list_for_each_entry_safe(probe, n, &tr->func_probes, list) 4264 + unregister_ftrace_function_probe_func(NULL, tr, probe->probe_ops); 4257 4265 } 4258 4266 4259 4267 static LIST_HEAD(ftrace_commands);
+32 -2
kernel/trace/trace.c
··· 1558 1558 1559 1559 return 0; 1560 1560 } 1561 - early_initcall(init_trace_selftests); 1561 + core_initcall(init_trace_selftests); 1562 1562 #else 1563 1563 static inline int run_tracer_selftest(struct tracer *type) 1564 1564 { ··· 2568 2568 void __trace_stack(struct trace_array *tr, unsigned long flags, int skip, 2569 2569 int pc) 2570 2570 { 2571 - __ftrace_trace_stack(tr->trace_buffer.buffer, flags, skip, pc, NULL); 2571 + struct ring_buffer *buffer = tr->trace_buffer.buffer; 2572 + 2573 + if (rcu_is_watching()) { 2574 + __ftrace_trace_stack(buffer, flags, skip, pc, NULL); 2575 + return; 2576 + } 2577 + 2578 + /* 2579 + * When an NMI triggers, RCU is enabled via rcu_nmi_enter(), 2580 + * but if the above rcu_is_watching() failed, then the NMI 2581 + * triggered someplace critical, and rcu_irq_enter() should 2582 + * not be called from NMI. 2583 + */ 2584 + if (unlikely(in_nmi())) 2585 + return; 2586 + 2587 + /* 2588 + * It is possible that a function is being traced in a 2589 + * location that RCU is not watching. A call to 2590 + * rcu_irq_enter() will make sure that it is, but there's 2591 + * a few internal rcu functions that could be traced 2592 + * where that wont work either. In those cases, we just 2593 + * do nothing. 2594 + */ 2595 + if (unlikely(rcu_irq_enter_disabled())) 2596 + return; 2597 + 2598 + rcu_irq_enter_irqson(); 2599 + __ftrace_trace_stack(buffer, flags, skip, pc, NULL); 2600 + rcu_irq_exit_irqson(); 2572 2601 } 2573 2602 2574 2603 /** ··· 7579 7550 } 7580 7551 7581 7552 tracing_set_nop(tr); 7553 + clear_ftrace_function_probes(tr); 7582 7554 event_trace_del_tracer(tr); 7583 7555 ftrace_clear_pids(tr); 7584 7556 ftrace_destroy_function_files(tr);
+5
kernel/trace/trace.h
··· 980 980 extern int 981 981 unregister_ftrace_function_probe_func(char *glob, struct trace_array *tr, 982 982 struct ftrace_probe_ops *ops); 983 + extern void clear_ftrace_function_probes(struct trace_array *tr); 983 984 984 985 int register_ftrace_command(struct ftrace_func_command *cmd); 985 986 int unregister_ftrace_command(struct ftrace_func_command *cmd); ··· 999 998 { 1000 999 return -EINVAL; 1001 1000 } 1001 + static inline void clear_ftrace_function_probes(struct trace_array *tr) 1002 + { 1003 + } 1004 + 1002 1005 /* 1003 1006 * The ops parameter passed in is usually undefined. 1004 1007 * This must be a macro.
+5
kernel/trace/trace_kprobe.c
··· 1535 1535 1536 1536 end: 1537 1537 release_all_trace_kprobes(); 1538 + /* 1539 + * Wait for the optimizer work to finish. Otherwise it might fiddle 1540 + * with probes in already freed __init text. 1541 + */ 1542 + wait_for_kprobe_optimizer(); 1538 1543 if (warn) 1539 1544 pr_cont("NG: Some tests are failed. Please check them.\n"); 1540 1545 else
+1 -1
tools/testing/selftests/ftrace/ftracetest
··· 58 58 ;; 59 59 --verbose|-v|-vv) 60 60 VERBOSE=$((VERBOSE + 1)) 61 - [ $1 == '-vv' ] && VERBOSE=$((VERBOSE + 1)) 61 + [ $1 = '-vv' ] && VERBOSE=$((VERBOSE + 1)) 62 62 shift 1 63 63 ;; 64 64 --debug|-d)
+1 -1
tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
··· 48 48 e=`cat $EVENT_ENABLE` 49 49 if [ "$e" != $val ]; then 50 50 echo "Expected $val but found $e" 51 - exit -1 51 + exit 1 52 52 fi 53 53 } 54 54
+2 -2
tools/testing/selftests/ftrace/test.d/functions
··· 34 34 echo > set_ftrace_filter 35 35 grep -v '^#' set_ftrace_filter | while read t; do 36 36 tr=`echo $t | cut -d: -f2` 37 - if [ "$tr" == "" ]; then 37 + if [ "$tr" = "" ]; then 38 38 continue 39 39 fi 40 - if [ $tr == "enable_event" -o $tr == "disable_event" ]; then 40 + if [ $tr = "enable_event" -o $tr = "disable_event" ]; then 41 41 tr=`echo $t | cut -d: -f1-4` 42 42 limit=`echo $t | cut -d: -f5` 43 43 else
+6 -2
tools/testing/selftests/ftrace/test.d/instances/instance-event.tc
··· 75 75 if [ -d foo ]; then 76 76 fail "foo still exists" 77 77 fi 78 - exit 0 79 78 80 - 79 + mkdir foo 80 + echo "schedule:enable_event:sched:sched_switch" > foo/set_ftrace_filter 81 + rmdir foo 82 + if [ -d foo ]; then 83 + fail "foo still exists" 84 + fi 81 85 82 86 83 87 instance_slam() {