[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aLmicQkB5RRJaxCE@pathway>
Date: Thu, 4 Sep 2025 16:30:09 +0200
From: Petr Mladek <pmladek@...e.com>
To: Daniil Tatianin <d-tatianin@...dex-team.ru>
Cc: linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>,
John Ogness <john.ogness@...utronix.de>,
Sergey Senozhatsky <senozhatsky@...omium.org>
Subject: Re: [PATCH v1] printk_ringbuffer: don't needlessly wrap data blocks
around
On Wed 2025-09-03 03:10:08, Daniil Tatianin wrote:
> Previously, data blocks that perfectly fit the data ring buffer would
> get wrapped around to the beginning for no reason since the calculated
> offset of the next data block would belong to the next wrap. Since this
> offset is not actually part of the data block, but rather the offset of
> where the next data block is going to start, there is no reason to
> include it when deciding whether the current block fits the buffer.
I am afraid to touch this code. I am curious how you found this ;-)
> diff --git a/kernel/printk/printk_ringbuffer.c b/kernel/printk/printk_ringbuffer.c
> index d9fb053cff67..f885ba8be5e6 100644
> --- a/kernel/printk/printk_ringbuffer.c
> +++ b/kernel/printk/printk_ringbuffer.c
> @@ -1002,6 +1002,18 @@ static bool desc_reserve(struct printk_ringbuffer *rb, unsigned long *id_out)
> return true;
> }
>
> +static bool same_lpos_wraps(struct prb_data_ring *data_ring,
> + unsigned long begin_lpos, unsigned long next_lpos)
The name might be slightly confusing because it might return true
even when the two given values do not belong into the same wrap.
I would make more clear that it is about the data block starting
on begin_lpos. Either I would call it
same_wrap_data_block()
or I would invert the logic and call it:
is_wrapped_data_block()
The 2nd variant looks more self-explanatory to me.
Otherwise the patch looks good to me. I was not able to find
any scenario when it would blow up just by reading the code.
Well, I would still like to do some tests.
Best Regards,
Petr
Powered by blists - more mailing lists