2009-12-16 01:06:53     Bug, Scheduling while atomic

Document created by Aaronwu Employee on Aug 20, 2013
Version 1Show Document
  • View in full screen mode

2009-12-16 01:06:53     Bug, Scheduling while atomic

Srinivas Nagathihalli (INDIA)

Message: 83550   




  Is it OK for a driver to sleep holding a semaphore? The Linux Device Driver books says it is OK to do so but the sleep duration must be small (but it not OK to sleep holding spinlock)


I get a kernel crash saying Bug, Scheduling while atomic when certain sequence of events happen in our driver.


We have a work queue in our driver which aquires a semapahore and does some processing and then releases it. But if for some reason this work queue blocks  holding the semahore and the write method of our driver gets called which tries to aquire the same semaphore the kernel crashes saying Scheduling while atomic.






2009-12-16 04:26:39     Re: Bug, Scheduling while atomic

Wolfgang Muees (GERMANY)

Message: 83594   


Is there a spinlock inside the write method?


Can you post the source code of the write method, and the error message / location?


It IS ok to sleep with semaphores held.




2009-12-16 05:39:14     Re: Bug, Scheduling while atomic

Srinivas Nagathihalli (INDIA)

Message: 83597   




  The write method does not have any spinlock. However after some investigation I found out that the work queue calls the function tty_wakeup  which does hold and release spinlocks(in the routines called by it). May be the work queue is pre-empted when it is holding the spin lock and then the driver write method gets called and this results in the crash.


Sorry I should have looked more before posting.