aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace
diff options
context:
space:
mode:
authorPetr Mladek <pmladek@suse.cz>2015-06-15 09:53:10 -0400
committerSteven Rostedt <rostedt@goodmis.org>2015-06-15 12:03:12 -0400
commitb44754d8262d3aab842998cf747f44fe6090be9f (patch)
tree193f1c3d9efe32692b28b8815b689fd7caf91d65 /kernel/trace
parent33d657d1381025542b84b79d5c7b548598e40a4d (diff)
ring_buffer: Allow to exit the ring buffer benchmark immediately
It takes a while until the ring_buffer_benchmark module is removed when the ring buffer hammer is running. It is because it takes few seconds and kthread_should_stop() is not being checked. This patch adds the check for kthread termination into the producer. It uses the existing @kill_test flag to finish the kthreads as cleanly as possible. It disables printing the "ERROR" message when the kthread is going. It makes sure that producer does not go into the 10sec sleep when it is being killed. Finally, it does not call wait_to_die() when kthread_should_stop() already returns true. Link: http://lkml.kernel.org/r/20150615155428.GD3135@pathway.suse.cz Signed-off-by: Petr Mladek <pmladek@suse.cz> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'kernel/trace')
-rw-r--r--kernel/trace/ring_buffer_benchmark.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
index 2430563cf2bc..5ffbae3d3f86 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -263,6 +263,8 @@ static void ring_buffer_producer(void)
263 if (cnt % wakeup_interval) 263 if (cnt % wakeup_interval)
264 cond_resched(); 264 cond_resched();
265#endif 265#endif
266 if (kthread_should_stop())
267 kill_test = 1;
266 268
267 } while (ktime_before(end_time, timeout) && !kill_test); 269 } while (ktime_before(end_time, timeout) && !kill_test);
268 trace_printk("End ring buffer hammer\n"); 270 trace_printk("End ring buffer hammer\n");
@@ -285,7 +287,7 @@ static void ring_buffer_producer(void)
285 entries = ring_buffer_entries(buffer); 287 entries = ring_buffer_entries(buffer);
286 overruns = ring_buffer_overruns(buffer); 288 overruns = ring_buffer_overruns(buffer);
287 289
288 if (kill_test) 290 if (kill_test && !kthread_should_stop())
289 trace_printk("ERROR!\n"); 291 trace_printk("ERROR!\n");
290 292
291 if (!disable_reader) { 293 if (!disable_reader) {
@@ -379,7 +381,7 @@ static int ring_buffer_consumer_thread(void *arg)
379 } 381 }
380 __set_current_state(TASK_RUNNING); 382 __set_current_state(TASK_RUNNING);
381 383
382 if (kill_test) 384 if (!kthread_should_stop())
383 wait_to_die(); 385 wait_to_die();
384 386
385 return 0; 387 return 0;
@@ -399,13 +401,16 @@ static int ring_buffer_producer_thread(void *arg)
399 } 401 }
400 402
401 ring_buffer_producer(); 403 ring_buffer_producer();
404 if (kill_test)
405 goto out_kill;
402 406
403 trace_printk("Sleeping for 10 secs\n"); 407 trace_printk("Sleeping for 10 secs\n");
404 set_current_state(TASK_INTERRUPTIBLE); 408 set_current_state(TASK_INTERRUPTIBLE);
405 schedule_timeout(HZ * SLEEP_TIME); 409 schedule_timeout(HZ * SLEEP_TIME);
406 } 410 }
407 411
408 if (kill_test) 412out_kill:
413 if (!kthread_should_stop())
409 wait_to_die(); 414 wait_to_die();
410 415
411 return 0; 416 return 0;