Linux, BUG: spinlock recursion on CPU

1.

I got a bug report 

BUG: spinlock recursion on CPU#0, hci0/1205 lock: dfae1008, .magic: dead4ead, .owner: hci0/1205, .owner_cpu: 0 [] (unwind_backtrace+0x0/0xe0) from [] (dump_stack+0x20/0x24) [] (dump_stack+0x20/0x24) from [] (spin_bug+0x90/0xa4) [] (spin_bug+0x90/0xa4) from [] (_raw_spin_lock+0x54/0x168) [] (_raw_spin_lock+0x54/0x168) from [] (_spin_lock+0x28/0x2c) [] (_spin_lock+0x28/0x2c) from [] (hci_rx_task+0x268/0x498) [] (hci_rx_task+0x268/0x498) from [] (tasklet_action+0x78/0xcc) [] (tasklet_action+0x78/0xcc) from [] (__do_softirq+0xfc/0x204) [] (__do_softirq+0xfc/0x204) from [] (irq_exit+0x58/0xac) [] (irq_exit+0x58/0xac) from [] (asm_do_IRQ+0x80/0x98) [] (asm_do_IRQ+0x80/0x98) from [

 

2.

It is reported here in the linux kernel source code

lib/spinlock_debug.c

 

 

void _raw_spin_lock(spinlock_t *lock) { debug_spin_lock_before(lock); if (unlikely(!__raw_spin_trylock(&lock->raw_lock))) __spin_lock_debug(lock); debug_spin_lock_after(lock); } static inline void debug_spin_lock_before(spinlock_t *lock) { SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic"); SPIN_BUG_ON(lock->owner == current, lock, "recursion"); SPIN_BUG_ON(lock->owner_cpu == raw_smp_processor_id(), lock, "cpu recursion"); } 

 

3. 

The reason is that, I did things like

spinlock(); printfk(...) spinunlock(); 

It is not allowed , because in printk() function, it will also call spinlock(), and that cause the recursion.

 

 

你可能感兴趣的:(Linux, BUG: spinlock recursion on CPU)