Stack overflow if softirq preempt by hardware interrupt many times

234 Views Asked by At

Recently I've been looking into one NIC driver implemented by NAPI which uses softirq to handle tx&rx packets, and lots of docs say softirq can be triggered when hardware interrupt return, then I have two questions about it:

  1. when running softirq, is registers stored by hardware interrupt still on kernel stack?
  2. if yes on 1, will the below sequence cause kernel stack overflow?
  • hardware interrupt and store registers on kernel stack.
  • hardware interrupt handler raises softirq.
  • softirq is running and a new hardware interrupt is coming.
  • go back to the first step.
1

There are 1 best solutions below

0
Xuan Li On

I think I got the point:

  1. is registers stored by hardware interrupt still on kernel stack yes, we are still in hardware interrupt context, but it is after calling the interrupt handler which is usually registered by the driver.

  2. no, that will not happen, when we all do_softirq, it will check preempt count by function "in_interrupt" which check both hardirq and softirq, so on the second round, do_softirq check in_interrupt is true and return directly.