diff options
-rw-r--r-- | kernel/trace/ring_buffer_benchmark.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c index a1503a027ee2..9ea7949366b3 100644 --- a/kernel/trace/ring_buffer_benchmark.c +++ b/kernel/trace/ring_buffer_benchmark.c | |||
@@ -24,8 +24,8 @@ struct rb_page { | |||
24 | static int wakeup_interval = 100; | 24 | static int wakeup_interval = 100; |
25 | 25 | ||
26 | static int reader_finish; | 26 | static int reader_finish; |
27 | static struct completion read_start; | 27 | static DECLARE_COMPLETION(read_start); |
28 | static struct completion read_done; | 28 | static DECLARE_COMPLETION(read_done); |
29 | 29 | ||
30 | static struct ring_buffer *buffer; | 30 | static struct ring_buffer *buffer; |
31 | static struct task_struct *producer; | 31 | static struct task_struct *producer; |
@@ -178,10 +178,14 @@ static void ring_buffer_consumer(void) | |||
178 | read_events ^= 1; | 178 | read_events ^= 1; |
179 | 179 | ||
180 | read = 0; | 180 | read = 0; |
181 | while (!reader_finish && !kill_test) { | 181 | /* |
182 | int found; | 182 | * Continue running until the producer specifically asks to stop |
183 | * and is ready for the completion. | ||
184 | */ | ||
185 | while (!READ_ONCE(reader_finish)) { | ||
186 | int found = 1; | ||
183 | 187 | ||
184 | do { | 188 | while (found && !kill_test) { |
185 | int cpu; | 189 | int cpu; |
186 | 190 | ||
187 | found = 0; | 191 | found = 0; |
@@ -195,17 +199,23 @@ static void ring_buffer_consumer(void) | |||
195 | 199 | ||
196 | if (kill_test) | 200 | if (kill_test) |
197 | break; | 201 | break; |
202 | |||
198 | if (stat == EVENT_FOUND) | 203 | if (stat == EVENT_FOUND) |
199 | found = 1; | 204 | found = 1; |
205 | |||
200 | } | 206 | } |
201 | } while (found && !kill_test); | 207 | } |
202 | 208 | ||
209 | /* Wait till the producer wakes us up when there is more data | ||
210 | * available or when the producer wants us to finish reading. | ||
211 | */ | ||
203 | set_current_state(TASK_INTERRUPTIBLE); | 212 | set_current_state(TASK_INTERRUPTIBLE); |
204 | if (reader_finish) | 213 | if (reader_finish) |
205 | break; | 214 | break; |
206 | 215 | ||
207 | schedule(); | 216 | schedule(); |
208 | } | 217 | } |
218 | __set_current_state(TASK_RUNNING); | ||
209 | reader_finish = 0; | 219 | reader_finish = 0; |
210 | complete(&read_done); | 220 | complete(&read_done); |
211 | } | 221 | } |
@@ -389,13 +399,10 @@ static int ring_buffer_consumer_thread(void *arg) | |||
389 | 399 | ||
390 | static int ring_buffer_producer_thread(void *arg) | 400 | static int ring_buffer_producer_thread(void *arg) |
391 | { | 401 | { |
392 | init_completion(&read_start); | ||
393 | |||
394 | while (!kthread_should_stop() && !kill_test) { | 402 | while (!kthread_should_stop() && !kill_test) { |
395 | ring_buffer_reset(buffer); | 403 | ring_buffer_reset(buffer); |
396 | 404 | ||
397 | if (consumer) { | 405 | if (consumer) { |
398 | smp_wmb(); | ||
399 | wake_up_process(consumer); | 406 | wake_up_process(consumer); |
400 | wait_for_completion(&read_start); | 407 | wait_for_completion(&read_start); |
401 | } | 408 | } |