From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Vincent Donnefort <vdonnefort@google.com>,
Zhu Jun <zhujun2@cmss.chinamobile.com>
Subject: [for-next][PATCH 3/3] ring-buffer: Annotate the speculative iterator event copy
Date: Wed, 02 Dec 2026 03:10:41 -0500 [thread overview]
Message-ID: <20261202081110.804172902@kernel.org> (raw)
In-Reply-To: 20261202081038.604861818@kernel.org
From: Zhu Jun <zhujun2@cmss.chinamobile.com>
A non-consuming iterator speculatively copies an event while a writer
may overwrite its page. The reader lock excludes other readers, but not
writers, so KCSAN reports the concurrent memcpy() and event reservation
accesses.
The iterator already validates the page stamp and committed size after
the copy and retries if the page changed. This makes the race intentional
and the KCSAN report a false positive. Mark the speculative copy with
data_race() to document the allowed access and suppress the report.
Link: https://patch.msgid.link/20261113083446.177306-1-zhujun2@cmss.chinamobile.com
Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/ring_buffer.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
index 5c08a755d29d..f4090e25b910 100644
--- a/kernel/trace/ring_buffer.c
+++ b/kernel/trace/ring_buffer.c
@@ -3575,7 +3575,8 @@ rb_iter_head_event(struct ring_buffer_iter *iter)
/* Writer corrupted the read? */
goto reset;
- memcpy(iter->event, event, length);
+ /* The page stamp below detects a concurrent overwrite of this copy. */
+ data_race(memcpy(iter->event, event, length));
/*
* If the page stamp is still the same after this rmb() then the
* event was safely copied without the writer entering the page.
--
2.53.0
prev parent reply other threads:[~2026-12-02 8:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 8:10 [for-next][PATCH 0/3] ring-buffer: Updates for v7.5 Steven Rostedt
2026-12-02 8:10 ` [for-next][PATCH 1/3] ring-buffer: Use is_user_task() in __rb_allocate_pages() Steven Rostedt
2026-12-02 8:10 ` [for-next][PATCH 2/3] ring-buffer: Mark concurrent accesses to waiter flags Steven Rostedt
2026-12-02 8:10 ` Steven Rostedt [this message]
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=20261202081110.804172902@kernel.org \
--to=rostedt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=vdonnefort@google.com \
--cc=zhujun2@cmss.chinamobile.com \
/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.