All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Mladek <pmladek@suse.com>
To: Daniil Tatianin <d-tatianin@yandex-team.ru>
Cc: linux-kernel@vger.kernel.org,
	Steven Rostedt <rostedt@goodmis.org>,
	John Ogness <john.ogness@linutronix.de>,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: Re: [PATCH v1] printk_ringbuffer: don't needlessly wrap data blocks around
Date: Thu, 4 Sep 2025 16:30:09 +0200	[thread overview]
Message-ID: <aLmicQkB5RRJaxCE@pathway> (raw)
In-Reply-To: <20250903001008.6720-1-d-tatianin@yandex-team.ru>

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

      parent reply	other threads:[~2025-09-04 14:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03  0:10 [PATCH v1] printk_ringbuffer: don't needlessly wrap data blocks around Daniil Tatianin
2025-09-04  7:33 ` John Ogness
2025-09-04 13:58 ` John Ogness
2025-09-04 16:33   ` Petr Mladek
2025-09-04 16:50     ` Daniil Tatianin
2025-09-05  9:13     ` John Ogness
2025-09-05 10:47       ` Petr Mladek
2025-09-04 14:30 ` Petr Mladek [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=aLmicQkB5RRJaxCE@pathway \
    --to=pmladek@suse.com \
    --cc=d-tatianin@yandex-team.ru \
    --cc=john.ogness@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=senozhatsky@chromium.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.