Re: [RFC PATCH v1 15/25] printk: print history for new consoles

From: Sergey Senozhatsky
Date: Mon Mar 04 2019 - 04:24:52 EST


On (02/26/19 16:22), John Ogness wrote:
> > This looks like an alien. The code is supposed to write one message
> > from the given buffer. And some huge job is well hidden there.
>
> This is a very simple implementation of a printk kthread. It probably
> makes more sense to have a printk kthread per console. That would allow
> fast consoles to not be penalized by slow consoles. Due to the
> per-console seq tracking, the code would already support it.

I believe we discussed "polling consoles" several times.

printk-kthread is one way to implement polling. Another one might
already be implemented in, probably, all serial drivers and we just
need to extend it a bit - polling from console's IRQ handler.

Serial drivers poll UART xmit buffer and print (usually) up to
`count' bytes:

static irqreturn_t foo_irq_handler(int irq, void *id)
{
int count = 512;

[...]
while (count > 0 && !uart_circ_empty(xmit)) {
wr_regb(port, TX, xmit->buf[xmit->tail]);
xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
count--;
}
[...]

return IRQ_HANDLED;
}

So we can also grub NUM (e.g. max 64 entries) pending logbuf messages
and print them from device's isr.

-ss