Skip to contentSkip to conversation

Delegating printk work to UART interrupt

DISCUSSION Alexander 2 participants 4 messages Jul 18, 2015 – Jul 22, 2015

lore
Share & tools
lore

Alexander

author
#0 lore raw

Hi!
When i checked how kernel printing works, i mentioned that it takes messages from log_buffer in console_unlock and gives it to call_console_drivers -> ... -> some uart bsp function. Basically, as i see this BSP realization tries to flush all message chars in busyloop ... so it waits until FIFO_NOT_FULL bit will be dropped by UART and it will be able to push the next byte. Basically, as i see userspace printing do something different. It puts N_FIFO_BYTES and exits, next, when FIFO will be freed - interrupt will be generated, and other characters will be put into UART FIFO.
Can we do something similar for kernel printing? i.e. do not busyloop sending char after char, but put N_FIFO chars and flush other in interrupt. When panic will occur we can do busyloop printing again. Is it reliable? Suppose we have several cores. Thank you.

Signature · 1 line
Alexander <[email protected]>
#1 lore raw

Hello Alexander,

Quoted 13 lines · Alexander

Hi!
When i checked how kernel printing works, i mentioned that it takes messages
from log_buffer in console_unlock and gives it to call_console_drivers ->
...
-> some uart bsp function. Basically, as i see this BSP realization tries to flush all message chars in busyloop ... so it waits until FIFO_NOT_FULL bit will
be dropped by UART and it will be able to push the next byte. Basically, as i see userspace printing do something different. It puts N_FIFO_BYTES
and exits, next, when FIFO will be freed - interrupt will be generated, and

Quoted 9 lines

other characters will be put into UART FIFO.
Can we do something similar for kernel printing? i.e. do not busyloop sending char
after char, but put N_FIFO chars and flush other in interrupt. When panic will occur
we can do busyloop printing again. Is it reliable? Suppose we have several cores.
Thank you.

What about trying this patch,
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/kernel/printk/printk.c?id=5874af2003b1aaaa053128d655710140e3187226

Its not changing console printing through UART to interrupt mode. But minimizes the time interrupts being disabled on printk().

Thanks,
Arun

Quoted 9 lines

--
Alexander <[email protected]>

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150720/198b65bf/attachment.html

author
#2 lore raw

Hi Arun KS,
Actually, i already saw this one and something similar were tested. I just trying to figure out the reasons why generic kernel layer (console_unlock) implemented in such way: i.e. why it accounts on immediate busyloop printing? Is it reliable to defer such printing to UART interrupts?

Thank you.

Quoted 46 lines · On Mon, 20 Jul 2015 09:34:16 +0530 Arun KS <[email protected]> wrote:

Hello Alexander,

Quoted 13 lines · Alexander

Hi!
When i checked how kernel printing works, i mentioned that it takes messages
from log_buffer in console_unlock and gives it to call_console_drivers ->
...
-> some uart bsp function. Basically, as i see this BSP realization tries to flush all message chars in busyloop ... so it waits until FIFO_NOT_FULL bit will
be dropped by UART and it will be able to push the next byte. Basically, as i see userspace printing do something different. It puts N_FIFO_BYTES
and exits, next, when FIFO will be freed - interrupt will be generated, and

Quoted 9 lines

other characters will be put into UART FIFO.
Can we do something similar for kernel printing? i.e. do not busyloop sending char
after char, but put N_FIFO chars and flush other in interrupt. When panic will occur
we can do busyloop printing again. Is it reliable? Suppose we have several cores.
Thank you.

What about trying this patch,
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/kernel/printk/printk.c?id=5874af2003b1aaaa053128d655710140e3187226

Its not changing console printing through UART to interrupt mode. But minimizes the time interrupts being disabled on printk().

Thanks,
Arun

Quoted 9 lines

--
Alexander <[email protected]>

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Signature · 1 line
Alexander <[email protected]>
#3 lore raw

Hello Alexander,

Quoted 9 lines · Alexander

Hi Arun KS,
Actually, i already saw this one and something similar were tested. I just trying
to figure out the reasons why generic kernel layer (console_unlock) implemented
in such way: i.e. why it accounts on immediate busyloop printing? Is it reliable to
defer such printing to UART interrupts?

Lets try to find out why it is done the way it is. My guess is "it makes printk simple and robust". Because if interrupts are blocked, console should not fail giving the critical information.

To change this behavior, we have to change the complete logic in the prink code to adjust with that. Because as of now printk code expects serial drivers returns only after finishing the job.

Thanks,
Arun

Quoted 62 lines

Thank you.

Quoted 3 lines · On Mon, 20 Jul 2015 09:34:16 +0530 Arun KS <[email protected]> wrote:

Hello Alexander,

On Sat, Jul 18, 2015 at 11:23 AM, Alexander <[email protected]>

Quoted 6 lines · wrote:
Quoted 6 lines

Hi!
When i checked how kernel printing works, i mentioned that it takes messages
from log_buffer in console_unlock and gives it to call_console_drivers

->

Quoted 2 lines
Quoted 2 lines

...
-> some uart bsp function. Basically, as i see this BSP realization

tries

Quoted 1 line
Quoted 1 line

to flush all message chars in busyloop ... so it waits until

FIFO_NOT_FULL

Quoted 5 lines
Quoted 5 lines

bit will
be dropped by UART and it will be able to push the next byte. Basically, as i see userspace printing do something different. It puts N_FIFO_BYTES
and exits, next, when FIFO will be freed - interrupt will be

generated, and

Quoted 4 lines
Quoted 4 lines

other characters will be put into UART FIFO.
Can we do something similar for kernel printing? i.e. do not busyloop sending char
after char, but put N_FIFO chars and flush other in interrupt. When

panic

Quoted 2 lines
Quoted 2 lines

will occur
we can do busyloop printing again. Is it reliable? Suppose we have

several

Quoted 5 lines
Quoted 3 lines

cores.
Thank you.

What about trying this patch,

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/kernel/printk/printk.c?id=5874af2003b1aaaa053128d655710140e3187226

Quoted 18 lines

Its not changing console printing through UART to interrupt mode. But minimizes the time interrupts being disabled on printk().

Thanks,
Arun

Quoted 9 lines

--
Alexander <[email protected]>

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

Quoted 3 lines

--
Alexander <[email protected]>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150722/f051e8ce/attachment-0001.html