From: John Ogness <john.ogness@linutronix.de>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Petr Mladek <pmladek@suse.com>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>,
linux-kernel@vger.kernel.org,
Mukesh Ojha <quic_mojha@quicinc.com>
Subject: Re: [PATCH printk v2 1/9] printk: ringbuffer: Do not skip non-finalized records with prb_next_seq()
Date: Tue, 21 Nov 2023 17:23:35 +0106 [thread overview]
Message-ID: <87lear2i8w.fsf@jogness.linutronix.de> (raw)
In-Reply-To: <20231120134556.DkKNwy7B@linutronix.de>
On 2023-11-20, Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> based on my research this should be the most recent post of this patch.
> If so then
>
> On 2023-11-06 22:13:22 [+0106], John Ogness wrote:
>> --- a/kernel/printk/printk_ringbuffer.c
>> +++ b/kernel/printk/printk_ringbuffer.c
>> + /*
>> + * The provided sequence is only the lower 32 bits of the ringbuffer
>> + * sequence. It needs to be expanded to 64bit. Get the first sequence
>> + * number from the ringbuffer and fold it.
>> + */
>> + seq = rb_first_seq - ((u32)rb_first_seq - ulseq);
>
> This needs to become
> seq = rb_first_seq - ((s32)((u32)rb_first_seq - ulseq));
>
> in order to continue booting on 32bit.
Indeed. The code assumes the passed in value (@ulseq) always represents
a 64-bit number that is less than or equal to the basis value
(@rb_first_seq). For kernel/printk/nbcon.c:__nbcon_seq_to_seq() that
assumption is correct. For this function, it is not.
Your change will round up or down to the nearest 32 bits of the basis
value.
For example, with @rb_first_seq = 0x200000000 and @ulseq = 0x1:
before your change (where @ulseq cannot represent something higher than
@rb_first_seq):
@ulseq translates to 0x100000001
after your change:
@ulseq translates to 0x200000001
Since __ulseq_to_u64seq() must deal with arbitrary values, I think the
32-bit rounding is appropriate.
Despite not strictly being necessary (because of the valid assumption),
I think we should also update __nbcon_seq_to_seq() to avoid any bizarre
cases due to different translations of the 32-bit value.
In fact, there is no reason to have 2 macros for this. I will create a
single macro using the 32-bit rounding.
Thanks for researching this!
John
next prev parent reply other threads:[~2023-11-21 16:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 21:07 [PATCH printk v2 0/9] fix console flushing John Ogness
2023-11-06 21:07 ` [PATCH printk v2 1/9] printk: ringbuffer: Do not skip non-finalized records with prb_next_seq() John Ogness
2023-11-20 13:45 ` Sebastian Andrzej Siewior
2023-11-21 16:17 ` John Ogness [this message]
2023-11-06 21:07 ` [PATCH printk v2 2/9] printk: ringbuffer: Clarify special lpos values John Ogness
2023-11-06 21:07 ` [PATCH printk v2 3/9] printk: For @suppress_panic_printk check for other CPU in panic John Ogness
2023-11-06 21:07 ` [PATCH printk v2 4/9] printk: Add this_cpu_in_panic() John Ogness
2023-11-06 21:07 ` [PATCH printk v2 5/9] printk: ringbuffer: Cleanup reader terminology John Ogness
2023-11-06 21:07 ` [PATCH printk v2 6/9] printk: Wait for all reserved records with pr_flush() John Ogness
2023-11-08 11:08 ` John Ogness
2023-11-06 21:07 ` [PATCH printk v2 7/9] printk: Skip non-finalized records in panic John Ogness
2023-11-06 21:07 ` [PATCH printk v2 8/9] printk: Disable passing console lock owner completely during panic() John Ogness
2023-11-06 21:07 ` [PATCH printk v2 9/9] printk: Avoid non-panic CPUs flooding ringbuffer John Ogness
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=87lear2i8w.fsf@jogness.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=pmladek@suse.com \
--cc=quic_mojha@quicinc.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
--cc=tglx@linutronix.de \
/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