title: BUG: Scheduling while atomic RAID_LAZY_WRITE/102/0x00000205
body: <p>I am developing a raid system and I am getting following BUG when I issue lots of parallel IO. <strong>I am not able to figure out how to go about debugging this dump.</strong> It's evident here that RAID_LAZY_WRITE thread is trying to schedule while it has locked the CPU but I am not able to trace it exactly how and why it's happening. As I don't acquire any lock to issue IO to block layer.</p>
  
  <p>I enabled spin lock debugging and lock dependency checking so that I could get detailed debug info. <strong>Here is the whole dump which I got, please provide me tips, ideas on
  how to analyze and debug using this dump.</strong></p>
  
  <pre><code>BUG: scheduling while atomic: RAID_LAZY_WRITE/102/0x00000205
  no locks held by RAID_LAZY_WRITE/102.
  
  Showing all locks held in the system:
  
  =============================================
  
  Pid: 102, comm:      RAID_LAZY_WRITE
  CPU: 0    Not tainted  (2.6.24 #274)
  PC is at add_preempt_count+0xa0/0xbc
  LR is at raid_write_stripe+0x388/0x544
  pc : [&lt;c004b014&gt;]    lr : [&lt;c015a83c&gt;]    psr: 80000013
  sp : cfc63ec4  ip : cfc63ed4  fp : cfc63ed0
  r10: cf5ce118  r9 : 00000001  r8 : 000000b4
  r7 : 00000001  r6 : cf403cd8  r5 : cfc62000  r4 : 00000002
  r3 : 00000001  r2 : 00000001  r1 : cfc62000  r0 : 00000001
  Flags: Nzcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
  Control: 0000397f  Table: 0f558000  DAC: 00000017
  [&lt;c0039fa0&gt;] (show_regs+0x0/0x4c) from [&lt;c004ae14&gt;] (__schedule_bug+0x54/0x68)
   r4:cfc9b0a0
  [&lt;c004adc0&gt;] (__schedule_bug+0x0/0x68) from [&lt;c029747c&gt;] (schedule+0x74/0x2f4)
   r5:cfc9b0a0 r4:c034d13c
  [&lt;c0297408&gt;] (schedule+0x0/0x2f4) from [&lt;c029772c&gt;] (io_schedule+0x30/0x54)
  [&lt;c02976fc&gt;] (io_schedule+0x0/0x54) from [&lt;c012e214&gt;]
  (get_request_wait+0xac/0x140)
   r4:00000000
  [&lt;c012e168&gt;] (get_request_wait+0x0/0x140) from [&lt;c012e864&gt;]
  (__make_request+0x478/0x544)
  [&lt;c012e3ec&gt;] (__make_request+0x0/0x544) from [&lt;c012c3d0&gt;]
  (generic_make_request+0x2a8/0x2f0)
  [&lt;c012c128&gt;] (generic_make_request+0x0/0x2f0) from [&lt;c0168858&gt;]
  (raid_submit_disk_io+0x348/0x37c)
  [&lt;c0168510&gt;] (raid_submit_disk_io+0x0/0x37c) from [&lt;c016be24&gt;]
  (perform_raid5_ops+0xdc8/0x1100)
  [&lt;c016b05c&gt;] (perform_raid5_ops+0x0/0x1100) from [&lt;c016c594&gt;]
  (raid5_RCW_postXOR+0x438/0x4c4)
  [&lt;c016c15c&gt;] (raid5_RCW_postXOR+0x0/0x4c4) from [&lt;c016cb8c&gt;]
  (raid5_xor_completed+0x2a4/0x3b0)
  [&lt;c016c8e8&gt;] (raid5_xor_completed+0x0/0x3b0) from [&lt;c01fb3a4&gt;]
  (iop_adma_run_tx_complete_actions+0x64/0xe8)
  [&lt;c01fb340&gt;] (iop_adma_run_tx_complete_actions+0x0/0xe8) from
  [&lt;c01fb720&gt;] (__iop_adma_slot_cleanup+0x2f8/0x3c0)
   r8:c0352f24 r7:00000000 r6:00000000 r5:00000000 r4:cf4faa7c
  [&lt;c01fb428&gt;] (__iop_adma_slot_cleanup+0x0/0x3c0) from [&lt;c01fb7f8&gt;]
  (iop_adma_tasklet+0x10/0x14)
  [&lt;c01fb7e8&gt;] (iop_adma_tasklet+0x0/0x14) from [&lt;c0057204&gt;]
  (run_timer_softirq+0x17c/0x208)
  [&lt;c0057088&gt;] (run_timer_softirq+0x0/0x208) from [&lt;c0053268&gt;]
  (__do_softirq+0x64/0xd0)
  [&lt;c0053204&gt;] (__do_softirq+0x0/0xd0) from [&lt;c005331c&gt;] (irq_exit+0x48/0x5c)
  [&lt;c00532d4&gt;] (irq_exit+0x0/0x5c) from [&lt;c0038048&gt;]
  (__exception_text_start+0x48/0x60)
  [&lt;c0038000&gt;] (__exception_text_start+0x0/0x60) from [&lt;c0038ab0&gt;]
  (__irq_svc+0x50/0x7c)
  Exception stack(0xcfc63e7c to 0xcfc63ec4)
  3e60:                                                                00000001
  3e80: cfc62000 00000001 00000001 00000002 cfc62000 cf403cd8 00000001 000000b4
  3ea0: 00000001 cf5ce118 cfc63ed0 cfc63ed4 cfc63ec4 c015a83c c004b014 80000013
  3ec0: ffffffff
   r6:00000020 r5:cfc63eb0 r4:ffffffff
  [&lt;c004af74&gt;] (add_preempt_count+0x0/0xbc) from [&lt;c015a83c&gt;]
  (raid_write_stripe+0x388/0x544)
  [&lt;c015a4b4&gt;] (raid_write_stripe+0x0/0x544) from [&lt;c015fc44&gt;]
  (raid_lazy_writer+0x4c4/0x6b8)
  [&lt;c015f780&gt;] (raid_lazy_writer+0x0/0x6b8) from [&lt;c0159528&gt;]
  (raid_thread_daemon+0x140/0x15c)
  [&lt;c01593e8&gt;] (raid_thread_daemon+0x0/0x15c) from [&lt;c0062c78&gt;]
  (kthread+0x58/0x90)
  [&lt;c0062c20&gt;] (kthread+0x0/0x90) from [&lt;c0051284&gt;] (do_exit+0x0/0x764)
   r6:00000000 r5:00000000 r4:00000000
  
  
  BUG: spinlock cpu recursion on CPU#0, RAID_DAEMON/101
   lock: cf4faae0, .magic: dead4ead, .owner: RAID_LAZY_WRITE/102, .owner_cpu: 0
  [&lt;c032a9d0&gt;] (dump_stack+0x0/0x14) from [&lt;c0141c90&gt;] (spin_bug+0x90/0xa4)
  [&lt;c0141c00&gt;] (spin_bug+0x0/0xa4) from [&lt;c0141e08&gt;] (_raw_spin_lock+0x68/0x15c)
   r5:c01fb378 r4:cf4faae0
  [&lt;c0141da0&gt;] (_raw_spin_lock+0x0/0x15c) from [&lt;c0298ec8&gt;]
  (_spin_lock_bh+0x4c/0x54)
  [&lt;c0298e7c&gt;] (_spin_lock_bh+0x0/0x54) from [&lt;c01fb378&gt;]
  (iop_adma_run_tx_complete_actions+0x38/0xe8)
   r5:00000000 r4:cf4faa7c
  [&lt;c01fb340&gt;] (iop_adma_run_tx_complete_actions+0x0/0xe8) from
  [&lt;c01fb720&gt;] (__iop_adma_slot_cleanup+0x2f8/0x3c0)
   r8:00000001 r7:00000000 r6:00000000 r5:00000000 r4:cf4faa7c
  [&lt;c01fb428&gt;] (__iop_adma_slot_cleanup+0x0/0x3c0) from [&lt;c01fb7f8&gt;]
  (iop_adma_tasklet+0x10/0x14)
  [&lt;c01fb7e8&gt;] (iop_adma_tasklet+0x0/0x14) from [&lt;c0052e30&gt;]
  (tasklet_action+0x8c/0xe4)
  [&lt;c0052da4&gt;] (tasklet_action+0x0/0xe4) from [&lt;c0053268&gt;]
  (__do_softirq+0x64/0xd0)
   r6:0000000a r5:00000001 r4:c0351f44
  [&lt;c0053204&gt;] (__do_softirq+0x0/0xd0) from [&lt;c005331c&gt;] (irq_exit+0x48/0x5c)
  [&lt;c00532d4&gt;] (irq_exit+0x0/0x5c) from [&lt;c0038048&gt;]
  (__exception_text_start+0x48/0x60)
  [&lt;c0038000&gt;] (__exception_text_start+0x0/0x60) from [&lt;c0038ab0&gt;]
  (__irq_svc+0x50/0x7c)
  Exception stack(0xcfcb1e64 to 0xcfcb1eac)
  1e60:          cf652404 00000001 ffffffff 00000001 cf652404 40000013 c0417bec
  1e80: 7fffffff cea81d88 00000000 cf6523e0 cfcb1ec0 cfcb1eac cfcb1eac c0298d00
  1ea0: c0298d04 60000013 ffffffff
   r6:00000064 r5:cfcb1e98 r4:ffffffff
  [&lt;c0298cd4&gt;] (_spin_unlock_irqrestore+0x0/0x54) from [&lt;c015c344&gt;]
  (raid_read_stripe+0x204/0x560)
   r5:00000008 r4:cf652404
  [&lt;c015c140&gt;] (raid_read_stripe+0x0/0x560) from [&lt;c01602bc&gt;]
  (raid_daemon+0x1d4/0x1110)
  [&lt;c01600e8&gt;] (raid_daemon+0x0/0x1110) from [&lt;c0159528&gt;]
  (raid_thread_daemon+0x140/0x15c)
  [&lt;c01593e8&gt;] (raid_thread_daemon+0x0/0x15c) from [&lt;c0062c78&gt;]
  (kthread+0x58/0x90)
  [&lt;c0062c20&gt;] (kthread+0x0/0x90) from [&lt;c0051284&gt;] (do_exit+0x0/0x764)
   r6:00000000 r5:00000000 r4:00000000
  </code></pre>
  
  <p>Thank you.</p>
  
  <p>Regards,
  Vikash Kumar
  <a href="http://VikashKumar.com/" rel="nofollow noreferrer">http://VikashKumar.com/</a></p>