4

I wanted to know this part. We know that tasklets can't sleep, then if the HW interrupt comes in what happens to the tasklets?

I am facing a crash, in which the tasklet is interrupted by a hW interrupt. I have used spinlock in my tasklet.

Should I use spinlock_irq_save?

Please, let me know.

Invictus
  • 2,653
  • 8
  • 31
  • 50
  • Accept the answer if its clears your doubt – Milind Dumbare Feb 20 '15 at 09:15
  • What are you trying to protect with the 'spinlock'? Often you can construct things so it doesn't matter. While `spinlock_irq_save` may be a solution, it will increase the entire system IRQ latency. Ie, it can be a bad idea depending on context. – artless noise Feb 20 '15 at 16:20

1 Answers1

2

Yes, you are right. Tasklets can be interrupted by HW interrupts, And you should prevent that. By using spin_lock_irqsave() and family.

Refer https://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/c188.html

If you don't do it and if tasklets are interrupted then you have seen what happens (crash)

Milind Dumbare
  • 3,104
  • 2
  • 19
  • 32
  • 1
    If you do spin_lock_irqsave , you may unknowingly increase interrupt latency. According to tasklet definition, it runs in "interrupt enable" context. Two tasklet of same type can't run concurrently so what is usage of lock ? I see lock only in case of shared resource but i am not able to recall a scenario. Could you please share an example? – Manish Feb 28 '15 at 20:11