History

x86-32/irq: Don't switch to irq stack for a user-mode irq

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.

Linus Torvalds committed 14 years ago

Commit 986cb481 parent b01543d1 file · +3 −8Browse files

Unified · Split

arch/x86/kernel/irq_32.c+3−8
@@ -100,13 +100,8 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) · 99 unmodified lines
100100 irqctx->tinfo.task = curctx->tinfo.task;
101101 irqctx->tinfo.previous_esp = current_stack_pointer;
102102
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;
110105
111106 if (unlikely(overflow))
112107 call_on_stack(print_stack_overflow, isp);
@@ -196,7 +191,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs) · 83 unmodified lines
196191 if (unlikely(!desc))
197192 return false;
198193
199− if (!execute_on_irq_stack(overflow, desc, irq)) {
194+ if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
200195 if (unlikely(overflow))
201196 print_stack_overflow();
202197 desc->handle_irq(irq, desc);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t