aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-10-12 07:28:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-10-12 07:28:55 -0400
commit8df6be116c87314e35c2ac9de35561b57f87739f (patch)
treea65863c462468cf1d26e379b73d50ec7301b6df8 /kernel/trace
parent9837acff77f51e40ab21521e914aa19f85beb312 (diff)
parentaddff1feb02b03cb766b9a611c6b2cebf29bc285 (diff)
Merge tag 'trace-3.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing fixes from Steven Rostedt: "Seems that Peter Zijlstra added a new check that is making old code scream nasty warnings: WARNING: CPU: 0 PID: 91 at kernel/sched/core.c:7253 __might_sleep+0x9a/0x378() do not call blocking ops when !TASK_RUNNING; state=1 set at [<ffffffff8d79b511>] event_test_thread+0x48/0x93 Call Trace: __might_sleep+0x9a/0x378 down_read+0x26/0x98 exit_signals+0x27/0x1c2 do_exit+0x193/0x10bd kthread+0x156/0x156 ret_from_fork+0x7a/0xb0 These are triggered by some self tests that run at start up when configure in. Although the code is technically correct, they are a little sloppy and not very robust. They work now because it runs at boot up and the tests do not call anything that might trigger a spurious wake up. But that doesn't mean those tests wont change in the future. It's best to clean them now to make sure the tests used to test the internal workings of the system don't cause breakage themselves. This also quiets the warnings made by the new checks" * tag 'trace-3.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Clean up scheduling in trace_wakeup_test_thread() tracing: Robustify wait loop
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/trace_events.c5
-rw-r--r--kernel/trace/trace_selftest.c47
2 files changed, 34 insertions, 18 deletions
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index ef06ce7e9cf8..0cc51edde3a8 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -2513,8 +2513,11 @@ static __init int event_test_thread(void *unused)
2513 kfree(test_malloc); 2513 kfree(test_malloc);
2514 2514
2515 set_current_state(TASK_INTERRUPTIBLE); 2515 set_current_state(TASK_INTERRUPTIBLE);
2516 while (!kthread_should_stop()) 2516 while (!kthread_should_stop()) {
2517 schedule(); 2517 schedule();
2518 set_current_state(TASK_INTERRUPTIBLE);
2519 }
2520 __set_current_state(TASK_RUNNING);
2518 2521
2519 return 0; 2522 return 0;
2520} 2523}
diff --git a/kernel/trace/trace_selftest.c b/kernel/trace/trace_selftest.c
index 61a6acd6025d..b0f86ea77881 100644
--- a/kernel/trace/trace_selftest.c
+++ b/kernel/trace/trace_selftest.c
@@ -1029,6 +1029,12 @@ trace_selftest_startup_nop(struct tracer *trace, struct trace_array *tr)
1029#endif 1029#endif
1030 1030
1031#ifdef CONFIG_SCHED_TRACER 1031#ifdef CONFIG_SCHED_TRACER
1032
1033struct wakeup_test_data {
1034 struct completion is_ready;
1035 int go;
1036};
1037
1032static int trace_wakeup_test_thread(void *data) 1038static int trace_wakeup_test_thread(void *data)
1033{ 1039{
1034 /* Make this a -deadline thread */ 1040 /* Make this a -deadline thread */
@@ -1038,51 +1044,56 @@ static int trace_wakeup_test_thread(void *data)
1038 .sched_deadline = 10000000ULL, 1044 .sched_deadline = 10000000ULL,
1039 .sched_period = 10000000ULL 1045 .sched_period = 10000000ULL
1040 }; 1046 };
1041 struct completion *x = data; 1047 struct wakeup_test_data *x = data;
1042 1048
1043 sched_setattr(current, &attr); 1049 sched_setattr(current, &attr);
1044 1050
1045 /* Make it know we have a new prio */ 1051 /* Make it know we have a new prio */
1046 complete(x); 1052 complete(&x->is_ready);
1047 1053
1048 /* now go to sleep and let the test wake us up */ 1054 /* now go to sleep and let the test wake us up */
1049 set_current_state(TASK_INTERRUPTIBLE); 1055 set_current_state(TASK_INTERRUPTIBLE);
1050 schedule(); 1056 while (!x->go) {
1057 schedule();
1058 set_current_state(TASK_INTERRUPTIBLE);
1059 }
1051 1060
1052 complete(x); 1061 complete(&x->is_ready);
1062
1063 set_current_state(TASK_INTERRUPTIBLE);
1053 1064
1054 /* we are awake, now wait to disappear */ 1065 /* we are awake, now wait to disappear */
1055 while (!kthread_should_stop()) { 1066 while (!kthread_should_stop()) {
1056 /* 1067 schedule();
1057 * This will likely be the system top priority 1068 set_current_state(TASK_INTERRUPTIBLE);
1058 * task, do short sleeps to let others run.
1059 */
1060 msleep(100);
1061 } 1069 }
1062 1070
1071 __set_current_state(TASK_RUNNING);
1072
1063 return 0; 1073 return 0;
1064} 1074}
1065
1066int 1075int
1067trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr) 1076trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
1068{ 1077{
1069 unsigned long save_max = tr->max_latency; 1078 unsigned long save_max = tr->max_latency;
1070 struct task_struct *p; 1079 struct task_struct *p;
1071 struct completion is_ready; 1080 struct wakeup_test_data data;
1072 unsigned long count; 1081 unsigned long count;
1073 int ret; 1082 int ret;
1074 1083
1075 init_completion(&is_ready); 1084 memset(&data, 0, sizeof(data));
1085
1086 init_completion(&data.is_ready);
1076 1087
1077 /* create a -deadline thread */ 1088 /* create a -deadline thread */
1078 p = kthread_run(trace_wakeup_test_thread, &is_ready, "ftrace-test"); 1089 p = kthread_run(trace_wakeup_test_thread, &data, "ftrace-test");
1079 if (IS_ERR(p)) { 1090 if (IS_ERR(p)) {
1080 printk(KERN_CONT "Failed to create ftrace wakeup test thread "); 1091 printk(KERN_CONT "Failed to create ftrace wakeup test thread ");
1081 return -1; 1092 return -1;
1082 } 1093 }
1083 1094
1084 /* make sure the thread is running at -deadline policy */ 1095 /* make sure the thread is running at -deadline policy */
1085 wait_for_completion(&is_ready); 1096 wait_for_completion(&data.is_ready);
1086 1097
1087 /* start the tracing */ 1098 /* start the tracing */
1088 ret = tracer_init(trace, tr); 1099 ret = tracer_init(trace, tr);
@@ -1103,18 +1114,20 @@ trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr)
1103 msleep(100); 1114 msleep(100);
1104 } 1115 }
1105 1116
1106 init_completion(&is_ready); 1117 init_completion(&data.is_ready);
1118
1119 data.go = 1;
1120 /* memory barrier is in the wake_up_process() */
1107 1121
1108 wake_up_process(p); 1122 wake_up_process(p);
1109 1123
1110 /* Wait for the task to wake up */ 1124 /* Wait for the task to wake up */
1111 wait_for_completion(&is_ready); 1125 wait_for_completion(&data.is_ready);
1112 1126
1113 /* stop the tracing. */ 1127 /* stop the tracing. */
1114 tracing_stop(); 1128 tracing_stop();
1115 /* check both trace buffers */ 1129 /* check both trace buffers */
1116 ret = trace_test_buffer(&tr->trace_buffer, NULL); 1130 ret = trace_test_buffer(&tr->trace_buffer, NULL);
1117 printk("ret = %d\n", ret);
1118 if (!ret) 1131 if (!ret)
1119 ret = trace_test_buffer(&tr->max_buffer, &count); 1132 ret = trace_test_buffer(&tr->max_buffer, &count);
1120 1133