ring_buffer: Fix more races when terminating the producer in the benchmark
authorPetr Mladek <pmladek@suse.com>
Mon, 7 Sep 2015 12:38:38 +0000 (14:38 +0200)
committerSteven Rostedt <rostedt@goodmis.org>
Tue, 3 Nov 2015 21:03:45 +0000 (16:03 -0500)
commitf47cb66df2f89dd1f796742c64f9ead77e548a6a
treef9ea36d78fcff17ba3bbd80c20cf0faa9339432e
parent8b46ff6938d2c78a16520a37086944ecbaa8ab8b
ring_buffer: Fix more races when terminating the producer in the benchmark

The commit b44754d8262d3aab8 ("ring_buffer: Allow to exit the ring
buffer benchmark immediately") added a hack into ring_buffer_producer()
that set @kill_test when kthread_should_stop() returned true. It improved
the situation a lot. It stopped the kthread in most cases because
the producer spent most of the time in the patched while cycle.

But there are still few possible races when kthread_should_stop()
is set outside of the cycle. Then we do not set @kill_test and
some other checks pass.

This patch adds a better fix. It renames @test_kill/TEST_KILL() into
a better descriptive @test_error/TEST_ERROR(). Also it introduces
break_test() function that checks for both @test_error and
kthread_should_stop().

The new function is used in the producer when the check for @test_error
is not enough. It is not used in the consumer because its state
is manipulated by the producer via the "reader_finish" variable.

Also we add a missing check into ring_buffer_producer_thread()
between setting TASK_INTERRUPTIBLE and calling schedule_timeout().
Otherwise, we might miss a wakeup from kthread_stop().

Link: http://lkml.kernel.org/r/1441629518-32712-3-git-send-email-pmladek@suse.com
Signed-off-by: Petr Mladek <pmladek@suse.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
kernel/trace/ring_buffer_benchmark.c
This page took 0.026168 seconds and 5 git commands to generate.