All of lore.kernel.org
 help / color / mirror / Atom feed
* Serial console and interrupts latency.
@ 2020-03-24  9:04 Sergey Organov
  2020-03-27 13:13 ` Jiri Slaby
  0 siblings, 1 reply; 10+ messages in thread
From: Sergey Organov @ 2020-03-24  9:04 UTC (permalink / raw)
  To: linux-serial; +Cc: Russell King, Greg Kroah-Hartman, Jiri Slaby

Hello,

[Extended CC list to try to get some attention]

I was investigating random serial overruns on my embedded board and
figured it strongly correlates with serial output (to another serial
port) from kernel printk() calls, that forced me to dig into the kernel
sources, and now I'm very confused.

I'm reading drivers/tty/serial/8250/8250_port.c, and
serial8250_console_write() function in particular (being on tty-next
branch).

What I see is that it locks interrupts

3141:		spin_lock_irqsave(&port->lock, flags);

and then calls wait_for_xmitr() both indirectly here:

3159:	uart_console_write(port, s, count, serial8250_console_putchar);

and then directly as well:

3165:	wait_for_xmitr(up, BOTH_EMPTY);

before re-enabling interrupts at:

3179:		spin_unlock_irqrestore(&port->lock, flags);

Now, wait_for_xmitr(), even according to comments, could busy-wait for
up to 10+1000 milliseconds, and in this case this huge delay will happen
at interrupts disabled?

Does it mean any serial console output out of printk() could cause 10
milliseconds or even 1 second interrupts latency? Somehow I can't
believe it.

What do I miss?

Thanks,
-- Sergey

^ permalink raw reply	[flat|nested] 10+ messages in thread
* Serial console and interrupts latency.
@ 2020-03-20 15:15 Sergey Organov
  0 siblings, 0 replies; 10+ messages in thread
From: Sergey Organov @ 2020-03-20 15:15 UTC (permalink / raw)
  To: linux-serial

Hello,

I was investigating random serial overruns on my embedded board and
figured it strongly correlates with serial output (to another serial
port) from kernel printk() calls, that forced me to dig into the kernel
sources, and now I'm very confused.

I'm reading drivers/tty/serial/8250/8250_port.c, and
serial8250_console_write() function in particular (being on tty-next
branch).

What I see is that it locks interrupts

3141:		spin_lock_irqsave(&port->lock, flags);

and then calls wait_for_xmitr() both indirectly here:

3159:	uart_console_write(port, s, count, serial8250_console_putchar);

and then directly as well:

3165:	wait_for_xmitr(up, BOTH_EMPTY);

before re-enabling interrupts at:

3179:		spin_unlock_irqrestore(&port->lock, flags);

Now, wait_for_xmitr(), even according to comments, could busy-wait for
up to 10+1000 milliseconds, and in this case this huge delay will happen
at interrupts disabled?

Does it mean any serial console output out of printk() could cause 10
milliseconds or even 1 second interrupts latency? Somehow I can't
believe it.

What do I miss?

Thanks,
-- Sergey

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-04-14 12:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-24  9:04 Serial console and interrupts latency Sergey Organov
2020-03-27 13:13 ` Jiri Slaby
2020-03-27 13:38   ` Russell King - ARM Linux admin
2020-03-27 14:03     ` Sergey Organov
2020-03-27 13:58   ` Sergey Organov
2020-03-27 23:24     ` Russell King - ARM Linux admin
2020-04-14  9:50       ` Sergey Organov
2020-04-14  9:56         ` Russell King - ARM Linux admin
2020-04-14 12:14           ` Sergey Organov
  -- strict thread matches above, loose matches on Subject: below --
2020-03-20 15:15 Sergey Organov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.