aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-10-05 09:55:46 -0400
committerDavid Howells <dhowells@warthog.cambridge.redhat.com>2006-10-05 10:10:12 -0400
commit7d12e780e003f93433d49ce78cfedf4b4c52adc5 (patch)
tree6748550400445c11a306b132009f3001e3525df8 /arch/i386/kernel
parentda482792a6d1a3fbaaa25fae867b343fb4db3246 (diff)
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead of passing regs around manually through all ~1800 interrupt handlers in the Linux kernel. The regs pointer is used in few places, but it potentially costs both stack space and code to pass it around. On the FRV arch, removing the regs parameter from all the genirq function results in a 20% speed up of the IRQ exit path (ie: from leaving timer_interrupt() to leaving do_IRQ()). Where appropriate, an arch may override the generic storage facility and do something different with the variable. On FRV, for instance, the address is maintained in GR28 at all times inside the kernel as part of general exception handling. Having looked over the code, it appears that the parameter may be handed down through up to twenty or so layers of functions. Consider a USB character device attached to a USB hub, attached to a USB controller that posts its interrupts through a cascaded auxiliary interrupt controller. A character device driver may want to pass regs to the sysrq handler through the input layer which adds another few layers of parameter passing. I've build this code with allyesconfig for x86_64 and i386. I've runtested the main part of the code on FRV and i386, though I can't test most of the drivers. I've also done partial conversion for powerpc and MIPS - these at least compile with minimal configurations. This will affect all archs. Mostly the changes should be relatively easy. Take do_IRQ(), store the regs pointer at the beginning, saving the old one: struct pt_regs *old_regs = set_irq_regs(regs); And put the old one back at the end: set_irq_regs(old_regs); Don't pass regs through to generic_handle_irq() or __do_IRQ(). In timer_interrupt(), this sort of change will be necessary: - update_process_times(user_mode(regs)); - profile_tick(CPU_PROFILING, regs); + update_process_times(user_mode(get_irq_regs())); + profile_tick(CPU_PROFILING); I'd like to move update_process_times()'s use of get_irq_regs() into itself, except that i386, alone of the archs, uses something other than user_mode(). Some notes on the interrupt handling in the drivers: (*) input_dev() is now gone entirely. The regs pointer is no longer stored in the input_dev struct. (*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does something different depending on whether it's been supplied with a regs pointer or not. (*) Various IRQ handler function pointers have been moved to type irq_handler_t. Signed-Off-By: David Howells <dhowells@redhat.com> (cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
Diffstat (limited to 'arch/i386/kernel')
-rw-r--r--arch/i386/kernel/apic.c18
-rw-r--r--arch/i386/kernel/i8259.c4
-rw-r--r--arch/i386/kernel/irq.c12
-rw-r--r--arch/i386/kernel/smp.c6
-rw-r--r--arch/i386/kernel/time.c6
-rw-r--r--arch/i386/kernel/time_hpet.c4
-rw-r--r--arch/i386/kernel/vm86.c2
7 files changed, 31 insertions, 21 deletions
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 90faae5c5d30..7d500da0e63b 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -1193,11 +1193,11 @@ EXPORT_SYMBOL(switch_ipi_to_APIC_timer);
1193 * value into /proc/profile. 1193 * value into /proc/profile.
1194 */ 1194 */
1195 1195
1196inline void smp_local_timer_interrupt(struct pt_regs * regs) 1196inline void smp_local_timer_interrupt(void)
1197{ 1197{
1198 profile_tick(CPU_PROFILING, regs); 1198 profile_tick(CPU_PROFILING);
1199#ifdef CONFIG_SMP 1199#ifdef CONFIG_SMP
1200 update_process_times(user_mode_vm(regs)); 1200 update_process_times(user_mode_vm(irq_regs));
1201#endif 1201#endif
1202 1202
1203 /* 1203 /*
@@ -1223,6 +1223,7 @@ inline void smp_local_timer_interrupt(struct pt_regs * regs)
1223 1223
1224fastcall void smp_apic_timer_interrupt(struct pt_regs *regs) 1224fastcall void smp_apic_timer_interrupt(struct pt_regs *regs)
1225{ 1225{
1226 struct pt_regs *old_regs = set_irq_regs(regs);
1226 int cpu = smp_processor_id(); 1227 int cpu = smp_processor_id();
1227 1228
1228 /* 1229 /*
@@ -1241,12 +1242,13 @@ fastcall void smp_apic_timer_interrupt(struct pt_regs *regs)
1241 * interrupt lock, which is the WrongThing (tm) to do. 1242 * interrupt lock, which is the WrongThing (tm) to do.
1242 */ 1243 */
1243 irq_enter(); 1244 irq_enter();
1244 smp_local_timer_interrupt(regs); 1245 smp_local_timer_interrupt();
1245 irq_exit(); 1246 irq_exit();
1247 set_irq_regs(old_regs);
1246} 1248}
1247 1249
1248#ifndef CONFIG_SMP 1250#ifndef CONFIG_SMP
1249static void up_apic_timer_interrupt_call(struct pt_regs *regs) 1251static void up_apic_timer_interrupt_call(void)
1250{ 1252{
1251 int cpu = smp_processor_id(); 1253 int cpu = smp_processor_id();
1252 1254
@@ -1255,11 +1257,11 @@ static void up_apic_timer_interrupt_call(struct pt_regs *regs)
1255 */ 1257 */
1256 per_cpu(irq_stat, cpu).apic_timer_irqs++; 1258 per_cpu(irq_stat, cpu).apic_timer_irqs++;
1257 1259
1258 smp_local_timer_interrupt(regs); 1260 smp_local_timer_interrupt();
1259} 1261}
1260#endif 1262#endif
1261 1263
1262void smp_send_timer_broadcast_ipi(struct pt_regs *regs) 1264void smp_send_timer_broadcast_ipi(void)
1263{ 1265{
1264 cpumask_t mask; 1266 cpumask_t mask;
1265 1267
@@ -1272,7 +1274,7 @@ void smp_send_timer_broadcast_ipi(struct pt_regs *regs)
1272 * We can directly call the apic timer interrupt handler 1274 * We can directly call the apic timer interrupt handler
1273 * in UP case. Minus all irq related functions 1275 * in UP case. Minus all irq related functions
1274 */ 1276 */
1275 up_apic_timer_interrupt_call(regs); 1277 up_apic_timer_interrupt_call();
1276#endif 1278#endif
1277 } 1279 }
1278} 1280}
diff --git a/arch/i386/kernel/i8259.c b/arch/i386/kernel/i8259.c
index d07ed31f11e3..d53eafb6daa7 100644
--- a/arch/i386/kernel/i8259.c
+++ b/arch/i386/kernel/i8259.c
@@ -335,13 +335,13 @@ void init_8259A(int auto_eoi)
335 */ 335 */
336 336
337 337
338static irqreturn_t math_error_irq(int cpl, void *dev_id, struct pt_regs *regs) 338static irqreturn_t math_error_irq(int cpl, void *dev_id)
339{ 339{
340 extern void math_error(void __user *); 340 extern void math_error(void __user *);
341 outb(0,0xF0); 341 outb(0,0xF0);
342 if (ignore_fpu_irq || !boot_cpu_data.hard_math) 342 if (ignore_fpu_irq || !boot_cpu_data.hard_math)
343 return IRQ_NONE; 343 return IRQ_NONE;
344 math_error((void __user *)regs->eip); 344 math_error((void __user *)get_irq_regs()->eip);
345 return IRQ_HANDLED; 345 return IRQ_HANDLED;
346} 346}
347 347
diff --git a/arch/i386/kernel/irq.c b/arch/i386/kernel/irq.c
index 3dd2e180151b..8cfc7dbec7b9 100644
--- a/arch/i386/kernel/irq.c
+++ b/arch/i386/kernel/irq.c
@@ -53,6 +53,7 @@ static union irq_ctx *softirq_ctx[NR_CPUS] __read_mostly;
53 */ 53 */
54fastcall unsigned int do_IRQ(struct pt_regs *regs) 54fastcall unsigned int do_IRQ(struct pt_regs *regs)
55{ 55{
56 struct pt_regs *old_regs;
56 /* high bit used in ret_from_ code */ 57 /* high bit used in ret_from_ code */
57 int irq = ~regs->orig_eax; 58 int irq = ~regs->orig_eax;
58 struct irq_desc *desc = irq_desc + irq; 59 struct irq_desc *desc = irq_desc + irq;
@@ -67,6 +68,7 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs)
67 BUG(); 68 BUG();
68 } 69 }
69 70
71 old_regs = set_irq_regs(regs);
70 irq_enter(); 72 irq_enter();
71#ifdef CONFIG_DEBUG_STACKOVERFLOW 73#ifdef CONFIG_DEBUG_STACKOVERFLOW
72 /* Debugging check for stack overflow: is there less than 1KB free? */ 74 /* Debugging check for stack overflow: is there less than 1KB free? */
@@ -95,7 +97,7 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs)
95 * current stack (which is the irq stack already after all) 97 * current stack (which is the irq stack already after all)
96 */ 98 */
97 if (curctx != irqctx) { 99 if (curctx != irqctx) {
98 int arg1, arg2, arg3, ebx; 100 int arg1, arg2, ebx;
99 101
100 /* build the stack frame on the IRQ stack */ 102 /* build the stack frame on the IRQ stack */
101 isp = (u32*) ((char*)irqctx + sizeof(*irqctx)); 103 isp = (u32*) ((char*)irqctx + sizeof(*irqctx));
@@ -114,17 +116,17 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs)
114 " xchgl %%ebx,%%esp \n" 116 " xchgl %%ebx,%%esp \n"
115 " call *%%edi \n" 117 " call *%%edi \n"
116 " movl %%ebx,%%esp \n" 118 " movl %%ebx,%%esp \n"
117 : "=a" (arg1), "=d" (arg2), "=c" (arg3), "=b" (ebx) 119 : "=a" (arg1), "=d" (arg2), "=b" (ebx)
118 : "0" (irq), "1" (desc), "2" (regs), "3" (isp), 120 : "0" (irq), "1" (desc), "2" (isp),
119 "D" (desc->handle_irq) 121 "D" (desc->handle_irq)
120 : "memory", "cc" 122 : "memory", "cc"
121 ); 123 );
122 } else 124 } else
123#endif 125#endif
124 desc->handle_irq(irq, desc, regs); 126 desc->handle_irq(irq, desc);
125 127
126 irq_exit(); 128 irq_exit();
127 129 set_irq_regs(old_regs);
128 return 1; 130 return 1;
129} 131}
130 132
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
index 1b080ab8a49f..31e5c6573aae 100644
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -321,6 +321,7 @@ static inline void leave_mm (unsigned long cpu)
321 321
322fastcall void smp_invalidate_interrupt(struct pt_regs *regs) 322fastcall void smp_invalidate_interrupt(struct pt_regs *regs)
323{ 323{
324 struct pt_regs *old_regs = set_irq_regs(regs);
324 unsigned long cpu; 325 unsigned long cpu;
325 326
326 cpu = get_cpu(); 327 cpu = get_cpu();
@@ -351,6 +352,7 @@ fastcall void smp_invalidate_interrupt(struct pt_regs *regs)
351 smp_mb__after_clear_bit(); 352 smp_mb__after_clear_bit();
352out: 353out:
353 put_cpu_no_resched(); 354 put_cpu_no_resched();
355 set_irq_regs(old_regs);
354} 356}
355 357
356static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm, 358static void flush_tlb_others(cpumask_t cpumask, struct mm_struct *mm,
@@ -605,11 +607,14 @@ void smp_send_stop(void)
605 */ 607 */
606fastcall void smp_reschedule_interrupt(struct pt_regs *regs) 608fastcall void smp_reschedule_interrupt(struct pt_regs *regs)
607{ 609{
610 struct pt_regs *old_regs = set_irq_regs(regs);
608 ack_APIC_irq(); 611 ack_APIC_irq();
612 set_irq_regs(old_regs);
609} 613}
610 614
611fastcall void smp_call_function_interrupt(struct pt_regs *regs) 615fastcall void smp_call_function_interrupt(struct pt_regs *regs)
612{ 616{
617 struct pt_regs *old_regs = set_irq_regs(regs);
613 void (*func) (void *info) = call_data->func; 618 void (*func) (void *info) = call_data->func;
614 void *info = call_data->info; 619 void *info = call_data->info;
615 int wait = call_data->wait; 620 int wait = call_data->wait;
@@ -632,6 +637,7 @@ fastcall void smp_call_function_interrupt(struct pt_regs *regs)
632 mb(); 637 mb();
633 atomic_inc(&call_data->finished); 638 atomic_inc(&call_data->finished);
634 } 639 }
640 set_irq_regs(old_regs);
635} 641}
636 642
637/* 643/*
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index 58a2d5582419..3f221f5eb47e 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -161,7 +161,7 @@ EXPORT_SYMBOL(profile_pc);
161 * Time Stamp Counter value at the time of the timer interrupt, so that 161 * Time Stamp Counter value at the time of the timer interrupt, so that
162 * we later on can estimate the time of day more exactly. 162 * we later on can estimate the time of day more exactly.
163 */ 163 */
164irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs) 164irqreturn_t timer_interrupt(int irq, void *dev_id)
165{ 165{
166 /* 166 /*
167 * Here we are in the timer irq handler. We just have irqs locally 167 * Here we are in the timer irq handler. We just have irqs locally
@@ -188,7 +188,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
188 } 188 }
189#endif 189#endif
190 190
191 do_timer_interrupt_hook(regs); 191 do_timer_interrupt_hook();
192 192
193 193
194 if (MCA_bus) { 194 if (MCA_bus) {
@@ -209,7 +209,7 @@ irqreturn_t timer_interrupt(int irq, void *dev_id, struct pt_regs *regs)
209 209
210#ifdef CONFIG_X86_LOCAL_APIC 210#ifdef CONFIG_X86_LOCAL_APIC
211 if (using_apic_timer) 211 if (using_apic_timer)
212 smp_send_timer_broadcast_ipi(regs); 212 smp_send_timer_broadcast_ipi();
213#endif 213#endif
214 214
215 return IRQ_HANDLED; 215 return IRQ_HANDLED;
diff --git a/arch/i386/kernel/time_hpet.c b/arch/i386/kernel/time_hpet.c
index 6bf14a4e995e..1a2a979cf6a3 100644
--- a/arch/i386/kernel/time_hpet.c
+++ b/arch/i386/kernel/time_hpet.c
@@ -441,7 +441,7 @@ int hpet_rtc_dropped_irq(void)
441 return 1; 441 return 1;
442} 442}
443 443
444irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs) 444irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id)
445{ 445{
446 struct rtc_time curr_time; 446 struct rtc_time curr_time;
447 unsigned long rtc_int_flag = 0; 447 unsigned long rtc_int_flag = 0;
@@ -480,7 +480,7 @@ irqreturn_t hpet_rtc_interrupt(int irq, void *dev_id, struct pt_regs *regs)
480 } 480 }
481 if (call_rtc_interrupt) { 481 if (call_rtc_interrupt) {
482 rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8)); 482 rtc_int_flag |= (RTC_IRQF | (RTC_NUM_INTS << 8));
483 rtc_interrupt(rtc_int_flag, dev_id, regs); 483 rtc_interrupt(rtc_int_flag, dev_id);
484 } 484 }
485 return IRQ_HANDLED; 485 return IRQ_HANDLED;
486} 486}
diff --git a/arch/i386/kernel/vm86.c b/arch/i386/kernel/vm86.c
index 8355d8d87d18..cbcd61d6120b 100644
--- a/arch/i386/kernel/vm86.c
+++ b/arch/i386/kernel/vm86.c
@@ -714,7 +714,7 @@ static int irqbits;
714 | (1 << SIGUSR1) | (1 << SIGUSR2) | (1 << SIGIO) | (1 << SIGURG) \ 714 | (1 << SIGUSR1) | (1 << SIGUSR2) | (1 << SIGIO) | (1 << SIGURG) \
715 | (1 << SIGUNUSED) ) 715 | (1 << SIGUNUSED) )
716 716
717static irqreturn_t irq_handler(int intno, void *dev_id, struct pt_regs * regs) 717static irqreturn_t irq_handler(int intno, void *dev_id)
718{ 718{
719 int irq_bit; 719 int irq_bit;
720 unsigned long flags; 720 unsigned long flags;