From: Steven Rostedt <rostedt@goodmis.org>
To: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v7 2/2] ring-buffer: Skip invalid sub-buffers when validating persistent ring buffer
Date: Sat, 7 Mar 2026 10:27:11 -0500 [thread overview]
Message-ID: <20260307102711.50932648@robin> (raw)
In-Reply-To: <177289359843.248514.164858607457269337.stgit@devnote2>
On Sat, 7 Mar 2026 23:26:38 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> kernel/trace/ring_buffer.c | 63 +++++++++++++++++++++++---------------------
> 1 file changed, 33 insertions(+), 30 deletions(-)
>
> diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
> index b6f3ac99834f..8599de5cf59b 100644
> --- a/kernel/trace/ring_buffer.c
> +++ b/kernel/trace/ring_buffer.c
> @@ -396,6 +396,12 @@ static __always_inline unsigned int rb_page_commit(struct buffer_page *bpage)
> return local_read(&bpage->page->commit);
> }
>
> +/* Size is determined by what has been committed */
> +static __always_inline unsigned int rb_page_size(struct buffer_page *bpage)
> +{
> + return rb_page_commit(bpage) & ~RB_MISSED_MASK;
> +}
> +
> static void free_buffer_page(struct buffer_page *bpage)
> {
> /* Range pages are not to be freed */
> @@ -1819,7 +1825,7 @@ static bool rb_cpu_meta_valid(struct ring_buffer_cpu_meta *meta, int cpu,
>
> bitmap_clear(subbuf_mask, 0, meta->nr_subbufs);
>
> - /* Is the meta buffers and the subbufs themselves have correct data? */
> + /* Is the meta buffers themselves have correct data? */
I just realized that the origin didn't have correct grammar. But we
still check the subbufs, why remove that comment?
The original should have said:
/* Do the meta buffers and subbufs have correct data? */
> for (i = 0; i < meta->nr_subbufs; i++) {
> if (meta->buffers[i] < 0 ||
> meta->buffers[i] >= meta->nr_subbufs) {
> @@ -1827,11 +1833,6 @@ static bool rb_cpu_meta_valid(struct ring_buffer_cpu_meta *meta, int cpu,
> return false;
> }
>
> - if ((unsigned)local_read(&subbuf->commit) > subbuf_size) {
> - pr_info("Ring buffer boot meta [%d] buffer invalid commit\n", cpu);
> - return false;
> - }
This should still be checked, although it doesn't need to fail the loop
but instead continue to the next buffer.
Also, I mentioned that if the commit == RB_MISSED_EVENTS, then we know
the sub buffer was corrupted and should be skipped.
And honestly, the commit should never be greater than the subbuf_size,
even if corrupted. As we are only worried about corruption due to cache
not writing out. That should not corrupt the commit size (now we can
ignore the flags and use page size instead).
So, perhaps we should invalidate the entire buffer if the commit part
is corrupted, as that is a major corruption.
-- Steve
next prev parent reply other threads:[~2026-03-07 15:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-07 14:26 [PATCH v7 0/2] ring-buffer: Making persistent ring buffers robust Masami Hiramatsu (Google)
2026-03-07 14:26 ` [PATCH v7 1/2] ring-buffer: Flush and stop persistent ring buffer on panic Masami Hiramatsu (Google)
2026-03-07 14:26 ` [PATCH v7 2/2] ring-buffer: Skip invalid sub-buffers when validating persistent ring buffer Masami Hiramatsu (Google)
2026-03-07 15:27 ` Steven Rostedt [this message]
2026-03-08 23:53 ` Masami Hiramatsu
2026-03-09 0:53 ` Masami Hiramatsu
2026-03-09 2:19 ` Steven Rostedt
2026-03-09 2:19 ` Steven Rostedt
2026-03-09 13:32 ` Masami Hiramatsu
2026-03-09 13:53 ` 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=20260307102711.50932648@robin \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.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