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

greg.freemyer at gmail.com greg.freemyer at gmail.com
Tue Feb 24 22:41:32 EST 2015



On February 24, 2015 10:07:59 PM EST, manty kuma <mantykuma at gmail.com> wrote:
>Dear All,
>
>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?
>
>Best Regards,
>Manty
>
>
Manty,

I admit to never looking, but I think you will find printk is atomic in someway.  You should review the source code to be sure.

Also remember the kernel is smp (symmetric multi-processing), so if printks were not atomic you would have line corruption far more frequently than just when an interrupt hits at the wrong time.

I've never seen corruption of that type. (Or at least not recently.  I seem to remember that issue in the 1980's, but that was the UNIX kernel.)

Greg
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.



More information about the Kernelnewbies mailing list