What happens when an interrupt comes while in middle of printk?

anupam kapoor anupam.kapoor at gmail.com
Wed Feb 25 00:38:39 EST 2015


>>>>> [2015-02-25T08:37:59+0530]: "manty kuma" (manty-kuma):
,----[ manty-kuma ]
| What happens if an interrupt comes while in middle of printk execution and
| the interrupt handler has a printk in it?
| 
| There is a chance that the log_buf could be corrupted. isn't it?
`----
no this doesn't happen. look at vprintk_emit(...) which invokes
local_irq_save(...).

essentially, printk tries to acquire console_lock. if it succeeds all is
well. otherwise, output is dumped to a log buffer. when the current
holder of console_lock, unlocks it, log buffer is emptied...

---
thanks
anupam



More information about the Kernelnewbies mailing list