kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* What happens when an interrupt comes while in middle of printk?
@ 2015-02-25  3:07 manty kuma
  2015-02-25  3:41 ` greg.freemyer at gmail.com
  2015-02-25  5:38 ` anupam kapoor
  0 siblings, 2 replies; 4+ messages in thread
From: manty kuma @ 2015-02-25  3:07 UTC (permalink / raw)
  To: kernelnewbies

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20150225/d0327c54/attachment.html 

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

* What happens when an interrupt comes while in middle of printk?
  2015-02-25  3:07 What happens when an interrupt comes while in middle of printk? manty kuma
@ 2015-02-25  3:41 ` greg.freemyer at gmail.com
  2015-02-25  3:47   ` nick
  2015-02-25  5:38 ` anupam kapoor
  1 sibling, 1 reply; 4+ messages in thread
From: greg.freemyer at gmail.com @ 2015-02-25  3:41 UTC (permalink / raw)
  To: kernelnewbies



On February 24, 2015 10:07:59 PM EST, manty kuma <mantykuma@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.

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

* What happens when an interrupt comes while in middle of printk?
  2015-02-25  3:41 ` greg.freemyer at gmail.com
@ 2015-02-25  3:47   ` nick
  0 siblings, 0 replies; 4+ messages in thread
From: nick @ 2015-02-25  3:47 UTC (permalink / raw)
  To: kernelnewbies



On 2015-02-24 10:41 PM, greg.freemyer at gmail.com wrote:
> 
> 
> On February 24, 2015 10:07:59 PM EST, manty kuma <mantykuma@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
> 
Greg,
You are right here as printk works anywhere needed after console is enabled in the boot of the kernel.
The only issue is if you are too early in the kernel's boot cycle you need to use early_printk, to my
knowledge through most architectures support this function including x86.
Nick
 

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

* What happens when an interrupt comes while in middle of printk?
  2015-02-25  3:07 What happens when an interrupt comes while in middle of printk? manty kuma
  2015-02-25  3:41 ` greg.freemyer at gmail.com
@ 2015-02-25  5:38 ` anupam kapoor
  1 sibling, 0 replies; 4+ messages in thread
From: anupam kapoor @ 2015-02-25  5:38 UTC (permalink / raw)
  To: kernelnewbies


>>>>> [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

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

end of thread, other threads:[~2015-02-25  5:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25  3:07 What happens when an interrupt comes while in middle of printk? manty kuma
2015-02-25  3:41 ` greg.freemyer at gmail.com
2015-02-25  3:47   ` nick
2015-02-25  5:38 ` anupam kapoor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).