aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/mach-voyager/voyager_smp.c
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/mach-voyager/voyager_smp.c
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/mach-voyager/voyager_smp.c')
-rw-r--r--arch/i386/mach-voyager/voyager_smp.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/arch/i386/mach-voyager/voyager_smp.c b/arch/i386/mach-voyager/voyager_smp.c
index 856c73fcb7e7..d42422fc4af3 100644
--- a/arch/i386/mach-voyager/voyager_smp.c
+++ b/arch/i386/mach-voyager/voyager_smp.c
@@ -126,10 +126,10 @@ send_QIC_CPI(__u32 cpuset, __u8 cpi)
126} 126}
127 127
128static inline void 128static inline void
129wrapper_smp_local_timer_interrupt(struct pt_regs *regs) 129wrapper_smp_local_timer_interrupt(void)
130{ 130{
131 irq_enter(); 131 irq_enter();
132 smp_local_timer_interrupt(regs); 132 smp_local_timer_interrupt();
133 irq_exit(); 133 irq_exit();
134} 134}
135 135
@@ -786,7 +786,7 @@ fastcall void
786smp_vic_sys_interrupt(struct pt_regs *regs) 786smp_vic_sys_interrupt(struct pt_regs *regs)
787{ 787{
788 ack_CPI(VIC_SYS_INT); 788 ack_CPI(VIC_SYS_INT);
789 printk("Voyager SYSTEM INTERRUPT\n"); 789 printk("Voyager SYSTEM INTERRUPT\n");
790} 790}
791 791
792/* Handle a voyager CMN_INT; These interrupts occur either because of 792/* Handle a voyager CMN_INT; These interrupts occur either because of
@@ -1135,7 +1135,9 @@ EXPORT_SYMBOL(smp_call_function);
1135fastcall void 1135fastcall void
1136smp_apic_timer_interrupt(struct pt_regs *regs) 1136smp_apic_timer_interrupt(struct pt_regs *regs)
1137{ 1137{
1138 wrapper_smp_local_timer_interrupt(regs); 1138 struct pt_regs *old_regs = set_irq_regs(regs);
1139 wrapper_smp_local_timer_interrupt();
1140 set_irq_regs(old_regs);
1139} 1141}
1140 1142
1141/* All of the QUAD interrupt GATES */ 1143/* All of the QUAD interrupt GATES */
@@ -1143,7 +1145,9 @@ fastcall void
1143smp_qic_timer_interrupt(struct pt_regs *regs) 1145smp_qic_timer_interrupt(struct pt_regs *regs)
1144{ 1146{
1145 ack_QIC_CPI(QIC_TIMER_CPI); 1147 ack_QIC_CPI(QIC_TIMER_CPI);
1146 wrapper_smp_local_timer_interrupt(regs); 1148 struct pt_regs *old_regs = set_irq_regs(regs);
1149 wrapper_smp_local_timer_interrupt(void);
1150 set_irq_regs(old_regs);
1147} 1151}
1148 1152
1149fastcall void 1153fastcall void
@@ -1177,6 +1181,7 @@ smp_qic_call_function_interrupt(struct pt_regs *regs)
1177fastcall void 1181fastcall void
1178smp_vic_cpi_interrupt(struct pt_regs *regs) 1182smp_vic_cpi_interrupt(struct pt_regs *regs)
1179{ 1183{
1184 struct pt_regs *old_regs = set_irq_regs(regs);
1180 __u8 cpu = smp_processor_id(); 1185 __u8 cpu = smp_processor_id();
1181 1186
1182 if(is_cpu_quad()) 1187 if(is_cpu_quad())
@@ -1185,7 +1190,7 @@ smp_vic_cpi_interrupt(struct pt_regs *regs)
1185 ack_VIC_CPI(VIC_CPI_LEVEL0); 1190 ack_VIC_CPI(VIC_CPI_LEVEL0);
1186 1191
1187 if(test_and_clear_bit(VIC_TIMER_CPI, &vic_cpi_mailbox[cpu])) 1192 if(test_and_clear_bit(VIC_TIMER_CPI, &vic_cpi_mailbox[cpu]))
1188 wrapper_smp_local_timer_interrupt(regs); 1193 wrapper_smp_local_timer_interrupt();
1189 if(test_and_clear_bit(VIC_INVALIDATE_CPI, &vic_cpi_mailbox[cpu])) 1194 if(test_and_clear_bit(VIC_INVALIDATE_CPI, &vic_cpi_mailbox[cpu]))
1190 smp_invalidate_interrupt(); 1195 smp_invalidate_interrupt();
1191 if(test_and_clear_bit(VIC_RESCHEDULE_CPI, &vic_cpi_mailbox[cpu])) 1196 if(test_and_clear_bit(VIC_RESCHEDULE_CPI, &vic_cpi_mailbox[cpu]))
@@ -1194,6 +1199,7 @@ smp_vic_cpi_interrupt(struct pt_regs *regs)
1194 smp_enable_irq_interrupt(); 1199 smp_enable_irq_interrupt();
1195 if(test_and_clear_bit(VIC_CALL_FUNCTION_CPI, &vic_cpi_mailbox[cpu])) 1200 if(test_and_clear_bit(VIC_CALL_FUNCTION_CPI, &vic_cpi_mailbox[cpu]))
1196 smp_call_function_interrupt(); 1201 smp_call_function_interrupt();
1202 set_irq_regs(old_regs);
1197} 1203}
1198 1204
1199static void 1205static void
@@ -1266,8 +1272,10 @@ smp_send_stop(void)
1266void 1272void
1267smp_vic_timer_interrupt(struct pt_regs *regs) 1273smp_vic_timer_interrupt(struct pt_regs *regs)
1268{ 1274{
1275 struct pt_regs *old_regs = set_irq_regs(regs);
1269 send_CPI_allbutself(VIC_TIMER_CPI); 1276 send_CPI_allbutself(VIC_TIMER_CPI);
1270 smp_local_timer_interrupt(regs); 1277 smp_local_timer_interrupt();
1278 set_irq_regs(old_regs);
1271} 1279}
1272 1280
1273/* local (per CPU) timer interrupt. It does both profiling and 1281/* local (per CPU) timer interrupt. It does both profiling and
@@ -1279,12 +1287,12 @@ smp_vic_timer_interrupt(struct pt_regs *regs)
1279 * value into /proc/profile. 1287 * value into /proc/profile.
1280 */ 1288 */
1281void 1289void
1282smp_local_timer_interrupt(struct pt_regs * regs) 1290smp_local_timer_interrupt(void)
1283{ 1291{
1284 int cpu = smp_processor_id(); 1292 int cpu = smp_processor_id();
1285 long weight; 1293 long weight;
1286 1294
1287 profile_tick(CPU_PROFILING, regs); 1295 profile_tick(CPU_PROFILING);
1288 if (--per_cpu(prof_counter, cpu) <= 0) { 1296 if (--per_cpu(prof_counter, cpu) <= 0) {
1289 /* 1297 /*
1290 * The multiplier may have changed since the last time we got 1298 * The multiplier may have changed since the last time we got
@@ -1302,7 +1310,7 @@ smp_local_timer_interrupt(struct pt_regs * regs)
1302 per_cpu(prof_counter, cpu); 1310 per_cpu(prof_counter, cpu);
1303 } 1311 }
1304 1312
1305 update_process_times(user_mode_vm(regs)); 1313 update_process_times(user_mode_vm(irq_regs));
1306 } 1314 }
1307 1315
1308 if( ((1<<cpu) & voyager_extended_vic_processors) == 0) 1316 if( ((1<<cpu) & voyager_extended_vic_processors) == 0)