Re: question on printk() & spin_lock()/spin_unlock(): its proper usage

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 30 Mar 2008 23:24:50 +0800
"Peter Teoh" <htmldeveloper@xxxxxxxxx> wrote:

> Is there any guidelines on when and where can we insert printk() to do
> debugging?

You can use it pretty much anywhere.
 
> asmlinkage int vprintk(const char *fmt, va_list args)
> {

...

>         preempt_disable();
>         /* This stops the holder of console_sem just where we want him */
>         raw_local_irq_save(flags);
> 
> So we can see that printk() MUST NOT BE USED when the kernel is
> preempt-disabled, as at the end of printk() it will be enabled again.
> 
> MISUSE scenario:   using printk() INSIDE a spin_lock()-spin_unlock() pair.

Multiple preempt_disable+preempt_enable sequences can nest, because
they simply keep a counter and preemption will not be enabled until
the counter reaches zero (the outer-most preempt_disable call).

-- 
All rights reversed.

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux