linuxkernelspinlocksoftirq

Can the SoftIRQ prempt currently running the same SoftIRQ with Linux kernel?


I am working on a performance improvement of a driver and should consider the possibility of deadlock. In a SoftIRQ context, spin_lock will be held and protect some variable. In this case, should I use spin_lock or spin_lock_bh? spin_lock_bh sounds like safer, but I have a general question about SoftIRQ implementation.

What is true from the above statement?


Solution

  • From Linux Kernel Development (2nd edition):

    A softirq never preempts another softirq.

    The reason is simple: during softIRQ software interrupts are disabled.

    So it is sufficient to use plain spin_lock() in a softIRQ function.