From: Petr Mladek <pmladek@suse.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Jiri Kosina <jkosina@suse.cz>, Ingo Molnar <mingo@kernel.org>,
linux-kernel@vger.kernel.org, Petr Mladek <pmladek@suse.com>
Subject: [PATCH 1/2] ring_buffer: Initialize completions statically in the benchmark
Date: Thu, 9 Jul 2015 17:09:20 +0200 [thread overview]
Message-ID: <1436454561-29925-2-git-send-email-pmladek@suse.com> (raw)
In-Reply-To: <1436454561-29925-1-git-send-email-pmladek@suse.com>
It looks strange to initialize the completions repeatedly.
This patch uses static initialization. It simplifies the code
and even helps to get rid of two memory barriers.
Signed-off-by: Petr Mladek <pmladek@suse.com>
---
kernel/trace/ring_buffer_benchmark.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
index a1503a027ee2..ccb1a0b95f64 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -24,8 +24,8 @@ struct rb_page {
static int wakeup_interval = 100;
static int reader_finish;
-static struct completion read_start;
-static struct completion read_done;
+static DECLARE_COMPLETION(read_start);
+static DECLARE_COMPLETION(read_done);
static struct ring_buffer *buffer;
static struct task_struct *producer;
@@ -270,11 +270,6 @@ static void ring_buffer_producer(void)
trace_printk("End ring buffer hammer\n");
if (consumer) {
- /* Init both completions here to avoid races */
- init_completion(&read_start);
- init_completion(&read_done);
- /* the completions must be visible before the finish var */
- smp_wmb();
reader_finish = 1;
/* finish var visible before waking up the consumer */
smp_wmb();
@@ -389,13 +384,10 @@ static int ring_buffer_consumer_thread(void *arg)
static int ring_buffer_producer_thread(void *arg)
{
- init_completion(&read_start);
-
while (!kthread_should_stop() && !kill_test) {
ring_buffer_reset(buffer);
if (consumer) {
- smp_wmb();
wake_up_process(consumer);
wait_for_completion(&read_start);
}
--
1.8.5.6
next prev parent reply other threads:[~2015-07-09 15:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-09 15:09 [PATCH 0/2] Some cleanup of ring buffer benchmark Petr Mladek
2015-07-09 15:09 ` Petr Mladek [this message]
2015-07-09 15:09 ` [PATCH 2/2] ring_buffer: Fix more races when terminating the producer in the benchmark Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1436454561-29925-2-git-send-email-pmladek@suse.com \
--to=pmladek@suse.com \
--cc=jkosina@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®