[PATCH v18 3/8] ring-buffer: Skip invalid sub-buffers when validating persistent ring buffer

Steven Rostedt rostedt at goodmis.org
Tue Apr 28 12:55:08 PDT 2026


On Fri, 24 Apr 2026 15:52:27 +0900
"Masami Hiramatsu (Google)" <mhiramat at kernel.org> wrote:

> @@ -5648,11 +5668,12 @@ __rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
>   again:
>  	/*
>  	 * This should normally only loop twice. But because the
> -	 * start of the reader inserts an empty page, it causes
> -	 * a case where we will loop three times. There should be no
> -	 * reason to loop four times (that I know of).
> +	 * start of the reader inserts an empty page, it causes a
> +	 * case where we will loop three times. There should be no
> +	 * reason to loop four times unless the ring buffer is a
> +	 * recovered persistent ring buffer.

Can you explain more to why this is allowed for persistent ring buffer?

Note, I do not like any loops that can go into an infinite loop and lock up
the machine. If something goes wrong with a persistent ring buffer, then
this could possibly go into an infinite loop.

I want to understand why this is allowed, and possibly add a check that
prevents this from never ending.

-- Steve


>  	 */
> -	if (RB_WARN_ON(cpu_buffer, ++nr_loops > 3)) {
> +	if (RB_WARN_ON(cpu_buffer, ++nr_loops > 3 && !cpu_buffer->ring_meta)) {
>  		reader = NULL;
>  		goto out;
>  	}



More information about the linux-arm-kernel mailing list