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
100 irqctx->tinfo.task = curctx->tinfo.task;100 irqctx->tinfo.task = curctx->tinfo.task;
101 irqctx->tinfo.previous_esp = current_stack_pointer;101 irqctx->tinfo.previous_esp = current_stack_pointer;
102 102
103 /*103 /* Copy the preempt_count so that the [soft]irq checks work. */
104 * Copy the softirq bits in preempt_count so that the104 irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
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);
110 105
111 if (unlikely(overflow))106 if (unlikely(overflow))
112 call_on_stack(print_stack_overflow, isp);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 if (unlikely(!desc))191 if (unlikely(!desc))
197 return false;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 if (unlikely(overflow))195 if (unlikely(overflow))
201 print_stack_overflow();196 print_stack_overflow();
202 desc->handle_irq(irq, desc);197 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