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

From: Petr Mladek
Date: Wed Oct 18 2023 - 09:15:57 EST


On Wed 2023-10-18 10:30:46, John Ogness wrote:
> On 2023-10-17, John Ogness <john.ogness@xxxxxxxxxxxxx> 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.

Yeah, this look like a better solution. Anyway, we need to try reading
the messages behind prb_next_seq() up to the head of the ring buffer.
And @head_id is not available outside prb API.

> 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().

Sounds reasonable.

Best Regards,
Petr