On Sun, 30 Mar 2008 23:24:50 +0800
"Peter Teoh" <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to