inconsistent lock state on call to kmem_cache_zalloc()

Arvid Brodin arvid.brodin at enea.com
Thu Mar 17 18:49:55 EDT 2011


Daniel Baluta wrote:
> On Thu, Mar 17, 2011 at 10:59 PM, Arvid Brodin <arvid.brodin at enea.com> wrote:
>> Hi,
>>
>> Daniel Baluta wrote:
>>> Hello,
>>>
>>>> The call to kmem_cache_zalloc() never returns; the printk() text on the line
>>>> after is never displayed and the system locks up. The printk() om the line
>>>> before displays.
>>> What flags are you passing to kmem_cache_zalloc?
>> I'm using the flags passed to the urb_enqueue() function; a printk reveals
>> the value is 16, which would be GFP_NOIO if I read include/linux/gfp.h correctly.
> 
> Hmm, I guess this is not quite OK. You hold a spinlock, and you can sleep
> while allocating memory.

I can see why this is not a good idea, and indeed using GFP_ATOMIC gets rid of the

=================================
[ INFO: inconsistent lock state ]
2.6.37 #116
---------------------------------
inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage.
...

message. Many thanks!

To the list in general:

Still, I would have expected some kind of "You're sleeping while holding a
spinlock / with interrupts disabled!" message (I have DEBUG_SPINLOCK_SLEEP
enabled), not a message from the lock debug code. Well... perhaps one of the
'W's in the message stands for "wait"? Also, the call stack in my original
mail shows the interrupt routine being called despite having disabled
interrupts - are they automatically enabled by functions that sleep?

> 
> Daniel.

-- 
Arvid Brodin
Enea Services Stockholm AB



More information about the Kernelnewbies mailing list