If the irq happens in user mode, our kernel stack is empty (apart from the pt_regs themselves, of course), so there's no need or advantage to switch. And it really doesn't save any stack space, quite the reverse: it means that a nested interrupt cannot switch irq stacks. So instead of saving kernel stack space, it actually causes the potential for *more* stack usage. Also simplify the preemption count copy when we do switch stacks: just copy the whole preemption count, rather than just the softirq parts of it. There is no advantage to the partial copy: it is more effort to get a less correct result.
Unified · Split
| @@ -100,13 +100,8 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) · 99 unmodified lines | ||
| 100 | 100 | irqctx->tinfo.task = curctx->tinfo.task; |
| 101 | 101 | irqctx->tinfo.previous_esp = current_stack_pointer; |
| 102 | 102 | |
| 103 | − /* | |
| 104 | − * Copy the softirq bits in preempt_count so that the | |
| 105 | − * softirq checks work in the hardirq context. | |
| 106 | − */ | |
| 107 | − irqctx->tinfo.preempt_count = | |
| 108 | − (irqctx->tinfo.preempt_count & ~SOFTIRQ_MASK) | | |
| 109 | − (curctx->tinfo.preempt_count & SOFTIRQ_MASK); | |
| 103 | + /* Copy the preempt_count so that the [soft]irq checks work. */ | |
| 104 | + irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count; | |
| 110 | 105 | |
| 111 | 106 | if (unlikely(overflow)) |
| 112 | 107 | call_on_stack(print_stack_overflow, isp); |
| @@ -196,7 +191,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs) · 83 unmodified lines | ||
| 196 | 191 | if (unlikely(!desc)) |
| 197 | 192 | return false; |
| 198 | 193 | |
| 199 | − if (!execute_on_irq_stack(overflow, desc, irq)) { | |
| 194 | + if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) { | |
| 200 | 195 | if (unlikely(overflow)) |
| 201 | 196 | print_stack_overflow(); |
| 202 | 197 | desc->handle_irq(irq, desc); |