From: wangwensheng <wsw9603@163.com>
To: John Ogness <john.ogness@linutronix.de>,
pmladek@suse.com, rostedt@goodmis.org, senozhatsky@chromium.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] printk_ringbuffer: Avoid needless read of prb_desc
Date: Sat, 26 Sep 2026 17:45:40 +0800 [thread overview]
Message-ID: <88eb1124-8dc1-4f1f-8654-07e1535f346c@163.com> (raw)
In-Reply-To: <87mrt6u5cs.fsf@jogness.linutronix.de>
On 9/24/26 21:49, John Ogness wrote:
> On 2026-09-22, Wang Wensheng <wsw9603@163.com> wrote:
>> diff --git a/kernel/printk/printk_ringbuffer.c b/kernel/printk/printk_ringbuffer.c
>> index 85c0c854b3ce..607666d37455 100644
>> --- a/kernel/printk/printk_ringbuffer.c
>> +++ b/kernel/printk/printk_ringbuffer.c
>> @@ -443,8 +443,8 @@ static enum desc_state get_desc_state(unsigned long id,
>> * descriptor is in an inconsistent state (miss or reserved), the caller can
>> * only expect the descriptor's @state_var field to be valid.
>> *
>> - * The sequence number and caller_id can be optionally retrieved. Like all
>> - * non-state_var data, they are only valid if the descriptor is in a
>> + * The sequence number, caller_id, and desc can be optionally retrieved. Like
>> + * all non-state_var data, they are only valid if the descriptor is in a
>> * consistent state.
>> */
> I realize you are trying to minimally update the documentation. But
> really the whole description needs to be appropriately updated. I
> suggest:
>
> /*
> * Get the state of a specified descriptor.
> *
> * Optionally, a copy of the descriptor, sequence number and/or caller ID can
> * be retrieved. However, (with the exception of @desc_out->state_var) all
> * retrieved values are invalid if the descriptor is in an inconsistent state
> * (miss or reserved).
> */
>
>> static enum desc_state desc_read(struct prb_desc_ring *desc_ring,
>> @@ -1335,7 +1335,6 @@ static struct prb_desc *desc_reopen_last(struct prb_desc_ring *desc_ring,
>> {
>> unsigned long prev_state_val;
>> enum desc_state d_state;
>> - struct prb_desc desc;
>> struct prb_desc *d;
>> unsigned long id;
>> u32 cid;
>> @@ -1346,7 +1345,7 @@ static struct prb_desc *desc_reopen_last(struct prb_desc_ring *desc_ring,
>> * To reduce unnecessarily reopening, first check if the descriptor
>> * state and caller ID are correct.
>> */
>> - d_state = desc_read(desc_ring, id, &desc, NULL, &cid);
>> + d_state = desc_read(desc_ring, id, NULL, NULL, &cid);
>> if (d_state != desc_committed || cid != caller_id)
>> return NULL;
>>
>> @@ -2007,14 +2006,13 @@ u64 prb_first_seq(struct printk_ringbuffer *rb)
>> {
>> struct prb_desc_ring *desc_ring = &rb->desc_ring;
>> enum desc_state d_state;
>> - struct prb_desc desc;
>> unsigned long id;
>> u64 seq;
>>
>> for (;;) {
>> id = atomic_long_read(&rb->desc_ring.tail_id); /* LMM(prb_first_seq:A) */
>>
>> - d_state = desc_read(desc_ring, id, &desc, &seq, NULL); /* LMM(prb_first_seq:B) */
>> + d_state = desc_read(desc_ring, id, NULL, &seq, NULL); /* LMM(prb_first_seq:B) */
>>
>> /*
>> * This loop will not be infinite because the tail is
> Using my suggestion for the documentation:
>
> Reviewed-by: John Ogness <john.ogness@linutronix.de>
Thanks for your comment. I have sent a new patch with your suggestion.
prev parent reply other threads:[~2026-09-26 9:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 6:25 Wang Wensheng
2026-09-23 11:36 ` Petr Mladek
2026-09-24 13:49 ` John Ogness
2026-09-26 9:45 ` wangwensheng [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=88eb1124-8dc1-4f1f-8654-07e1535f346c@163.com \
--to=wsw9603@163.com \
--cc=john.ogness@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®