diff options
Diffstat (limited to 'kernel/trace/trace_selftest.c')
-rw-r--r-- | kernel/trace/trace_selftest.c | 47 |
1 files changed, 30 insertions, 17 deletions
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 | |||
1033 | struct wakeup_test_data { | ||
1034 | struct completion is_ready; | ||
1035 | int go; | ||
1036 | }; | ||
1037 | |||
1032 | static int trace_wakeup_test_thread(void *data) | 1038 | static 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 | |||
1066 | int | 1075 | int |
1067 | trace_selftest_startup_wakeup(struct tracer *trace, struct trace_array *tr) | 1076 | trace_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 | ||