0

Recently I study the Linux-Kernel-Development by Robert Love.

There is a paragraph describes mechanism of softirq.

The softirq handlers run with interrupts enabled and cannot sleep. While a handler runs, softirqs on the current processor are disabled. Another processor, however, can execute other softirqs.

I don't understand the meaning of "softirqs on the current processor are disabled."

Does this mean that when running __do_softirq, even if some of the bit in the softirq_pending is raising again, the __do_softirq function cannot be interrupted? If yes then what statements in the __do_softirq do this kind of protection?

When tracing the code in __do_softirq, I found that there are a pair of __local_bh_disable and __local_bh_enable functions.

Do they disable the local softirq?

Thanks.

Anakin Tung
  • 419
  • 5
  • 17

1 Answers1

1

Yes, __local_bh_disable and __local_bh_enable disable and enable processing of softirqs on the current CPU. Softirqs are also known as "bottom halves", which is what the "bh" in those names represents.

caf
  • 233,326
  • 40
  • 323
  • 462
  • so if there is another interrupt making the bit in softirq_pending again, the scheduler will only schedule to another cpu[if there exist multiple cpu] right? – Anakin Tung Oct 10 '15 at 11:36
  • I'm also confuse about if the __do_softirq calls the __local_bf_disable, why does it calls local_irq_enable again? it seems contradict between these two functions? whats the difference between these two functions? many thanks. – Anakin Tung Oct 10 '15 at 11:40
  • 1
    If another softirq becomes pending on this CPU, it won't execute until the curently-executing softirq finishes. The `local_irq_enable` is to allow hardware interrupts to interrupt the softirq handler. They're only disabled to allow the set of pending softirqs to be read and zeroed without racing with a hard irq changing it. – caf Oct 10 '15 at 12:27