All of lore.kernel.org
 help / color / mirror / Atom feed
From: linke li <lilinke99@qq.com>
Cc: lilinke99@qq.com, Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: [PATCH] ring-buffer: mark racy accesses on work->wait_index
Date: Wed,  6 Mar 2024 10:55:34 +0800	[thread overview]
Message-ID: <tencent_BA1473492BC618B473864561EA3AB1418908@qq.com> (raw)

Mark data races to work->wait_index as benign using READ_ONCE and WRITE_ONCE. These accesses are expected to be racy.

Signed-off-by: linke li <lilinke99@qq.com>
---
 kernel/trace/ring_buffer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 0699027b4f4c..a47e9e9750cc 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -798,7 +798,7 @@ void ring_buffer_wake_waiters(struct trace_buffer *buffer, int cpu)
 		rbwork = &cpu_buffer->irq_work;
 	}
 
-	rbwork->wait_index++;
+	WRITE_ONCE(rbwork->wait_index, READ_ONCE(rbwork->wait_index) + 1);
 	/* make sure the waiters see the new index */
 	smp_wmb();
 
@@ -906,7 +906,7 @@ int ring_buffer_wait(struct trace_buffer *buffer, int cpu, int full)
 
 		/* Make sure to see the new wait index */
 		smp_rmb();
-		if (wait_index != work->wait_index)
+		if (wait_index != READ_ONCE(work->wait_index))
 			break;
 	}
 
-- 
2.39.3 (Apple Git-145)


             reply	other threads:[~2024-03-06  3:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-06  2:55 linke li [this message]
2024-03-06 14:05 ` [PATCH] ring-buffer: mark racy accesses on work->wait_index Steven Rostedt

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=tencent_BA1473492BC618B473864561EA3AB1418908@qq.com \
    --to=lilinke99@qq.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.