Re: [PATCH printk v2 3/4] printk: Skip unfinalized records in panic

John Ogness
2023-10-18T08:25:02Z

On 2023-10-17, John Ogness <john.ogness@linutronix.de> wrote:
>>> - if (!prb_read_valid(prb, seq, &r))
>>> - return false;
>>> + while (!prb_read_valid(prb, seq, &r)) {
>>> + if (this_cpu_in_panic() && seq < prb_next_seq(prb)) {
>>> + /*
>>> + * The record @seq is not finalized and there may be

I am wondering if we should put the this_cpu_in_panic() check into
_prb_read_valid() instead. This has the advantage that it could more
intelligently skip non-finalized records and not need to rely on
prb_next_seq(). Also, it would allow any other readers (kmsg_dump) to
skip non-finalized records during panic.

Looking over the code, it would be easy to extend
desc_read_finalized_seq() to return a separate error code for exists but
is non-finalized. This would make it trivial for _prb_read_valid() to
skip over it when this_cpu_in_panic().

John