diff options
author | David Howells <dhowells@redhat.com> | 2006-10-05 09:55:46 -0400 |
---|---|---|
committer | David Howells <dhowells@warthog.cambridge.redhat.com> | 2006-10-05 10:10:12 -0400 |
commit | 7d12e780e003f93433d49ce78cfedf4b4c52adc5 (patch) | |
tree | 6748550400445c11a306b132009f3001e3525df8 /arch/ia64/kernel/mca.c | |
parent | da482792a6d1a3fbaaa25fae867b343fb4db3246 (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/ia64/kernel/mca.c')
-rw-r--r-- | arch/ia64/kernel/mca.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c index 663230183254..7cfa63a98cb3 100644 --- a/arch/ia64/kernel/mca.c +++ b/arch/ia64/kernel/mca.c | |||
@@ -499,7 +499,7 @@ int cpe_vector = -1; | |||
499 | int ia64_cpe_irq = -1; | 499 | int ia64_cpe_irq = -1; |
500 | 500 | ||
501 | static irqreturn_t | 501 | static irqreturn_t |
502 | ia64_mca_cpe_int_handler (int cpe_irq, void *arg, struct pt_regs *ptregs) | 502 | ia64_mca_cpe_int_handler (int cpe_irq, void *arg) |
503 | { | 503 | { |
504 | static unsigned long cpe_history[CPE_HISTORY_LENGTH]; | 504 | static unsigned long cpe_history[CPE_HISTORY_LENGTH]; |
505 | static int index; | 505 | static int index; |
@@ -744,7 +744,7 @@ ia64_mca_wakeup_all(void) | |||
744 | * Outputs : None | 744 | * Outputs : None |
745 | */ | 745 | */ |
746 | static irqreturn_t | 746 | static irqreturn_t |
747 | ia64_mca_rendez_int_handler(int rendez_irq, void *arg, struct pt_regs *regs) | 747 | ia64_mca_rendez_int_handler(int rendez_irq, void *arg) |
748 | { | 748 | { |
749 | unsigned long flags; | 749 | unsigned long flags; |
750 | int cpu = smp_processor_id(); | 750 | int cpu = smp_processor_id(); |
@@ -753,8 +753,8 @@ ia64_mca_rendez_int_handler(int rendez_irq, void *arg, struct pt_regs *regs) | |||
753 | 753 | ||
754 | /* Mask all interrupts */ | 754 | /* Mask all interrupts */ |
755 | local_irq_save(flags); | 755 | local_irq_save(flags); |
756 | if (notify_die(DIE_MCA_RENDZVOUS_ENTER, "MCA", regs, (long)&nd, 0, 0) | 756 | if (notify_die(DIE_MCA_RENDZVOUS_ENTER, "MCA", get_irq_regs(), |
757 | == NOTIFY_STOP) | 757 | (long)&nd, 0, 0) == NOTIFY_STOP) |
758 | ia64_mca_spin(__FUNCTION__); | 758 | ia64_mca_spin(__FUNCTION__); |
759 | 759 | ||
760 | ia64_mc_info.imi_rendez_checkin[cpu] = IA64_MCA_RENDEZ_CHECKIN_DONE; | 760 | ia64_mc_info.imi_rendez_checkin[cpu] = IA64_MCA_RENDEZ_CHECKIN_DONE; |
@@ -763,16 +763,16 @@ ia64_mca_rendez_int_handler(int rendez_irq, void *arg, struct pt_regs *regs) | |||
763 | */ | 763 | */ |
764 | ia64_sal_mc_rendez(); | 764 | ia64_sal_mc_rendez(); |
765 | 765 | ||
766 | if (notify_die(DIE_MCA_RENDZVOUS_PROCESS, "MCA", regs, (long)&nd, 0, 0) | 766 | if (notify_die(DIE_MCA_RENDZVOUS_PROCESS, "MCA", get_irq_regs(), |
767 | == NOTIFY_STOP) | 767 | (long)&nd, 0, 0) == NOTIFY_STOP) |
768 | ia64_mca_spin(__FUNCTION__); | 768 | ia64_mca_spin(__FUNCTION__); |
769 | 769 | ||
770 | /* Wait for the monarch cpu to exit. */ | 770 | /* Wait for the monarch cpu to exit. */ |
771 | while (monarch_cpu != -1) | 771 | while (monarch_cpu != -1) |
772 | cpu_relax(); /* spin until monarch leaves */ | 772 | cpu_relax(); /* spin until monarch leaves */ |
773 | 773 | ||
774 | if (notify_die(DIE_MCA_RENDZVOUS_LEAVE, "MCA", regs, (long)&nd, 0, 0) | 774 | if (notify_die(DIE_MCA_RENDZVOUS_LEAVE, "MCA", get_irq_regs(), |
775 | == NOTIFY_STOP) | 775 | (long)&nd, 0, 0) == NOTIFY_STOP) |
776 | ia64_mca_spin(__FUNCTION__); | 776 | ia64_mca_spin(__FUNCTION__); |
777 | 777 | ||
778 | /* Enable all interrupts */ | 778 | /* Enable all interrupts */ |
@@ -791,12 +791,11 @@ ia64_mca_rendez_int_handler(int rendez_irq, void *arg, struct pt_regs *regs) | |||
791 | * | 791 | * |
792 | * Inputs : wakeup_irq (Wakeup-interrupt bit) | 792 | * Inputs : wakeup_irq (Wakeup-interrupt bit) |
793 | * arg (Interrupt handler specific argument) | 793 | * arg (Interrupt handler specific argument) |
794 | * ptregs (Exception frame at the time of the interrupt) | ||
795 | * Outputs : None | 794 | * Outputs : None |
796 | * | 795 | * |
797 | */ | 796 | */ |
798 | static irqreturn_t | 797 | static irqreturn_t |
799 | ia64_mca_wakeup_int_handler(int wakeup_irq, void *arg, struct pt_regs *ptregs) | 798 | ia64_mca_wakeup_int_handler(int wakeup_irq, void *arg) |
800 | { | 799 | { |
801 | return IRQ_HANDLED; | 800 | return IRQ_HANDLED; |
802 | } | 801 | } |
@@ -1261,13 +1260,12 @@ static DECLARE_WORK(cmc_enable_work, ia64_mca_cmc_vector_enable_keventd, NULL); | |||
1261 | * Inputs | 1260 | * Inputs |
1262 | * interrupt number | 1261 | * interrupt number |
1263 | * client data arg ptr | 1262 | * client data arg ptr |
1264 | * saved registers ptr | ||
1265 | * | 1263 | * |
1266 | * Outputs | 1264 | * Outputs |
1267 | * None | 1265 | * None |
1268 | */ | 1266 | */ |
1269 | static irqreturn_t | 1267 | static irqreturn_t |
1270 | ia64_mca_cmc_int_handler(int cmc_irq, void *arg, struct pt_regs *ptregs) | 1268 | ia64_mca_cmc_int_handler(int cmc_irq, void *arg) |
1271 | { | 1269 | { |
1272 | static unsigned long cmc_history[CMC_HISTORY_LENGTH]; | 1270 | static unsigned long cmc_history[CMC_HISTORY_LENGTH]; |
1273 | static int index; | 1271 | static int index; |
@@ -1336,12 +1334,11 @@ out: | |||
1336 | * Inputs | 1334 | * Inputs |
1337 | * interrupt number | 1335 | * interrupt number |
1338 | * client data arg ptr | 1336 | * client data arg ptr |
1339 | * saved registers ptr | ||
1340 | * Outputs | 1337 | * Outputs |
1341 | * handled | 1338 | * handled |
1342 | */ | 1339 | */ |
1343 | static irqreturn_t | 1340 | static irqreturn_t |
1344 | ia64_mca_cmc_int_caller(int cmc_irq, void *arg, struct pt_regs *ptregs) | 1341 | ia64_mca_cmc_int_caller(int cmc_irq, void *arg) |
1345 | { | 1342 | { |
1346 | static int start_count = -1; | 1343 | static int start_count = -1; |
1347 | unsigned int cpuid; | 1344 | unsigned int cpuid; |
@@ -1352,7 +1349,7 @@ ia64_mca_cmc_int_caller(int cmc_irq, void *arg, struct pt_regs *ptregs) | |||
1352 | if (start_count == -1) | 1349 | if (start_count == -1) |
1353 | start_count = IA64_LOG_COUNT(SAL_INFO_TYPE_CMC); | 1350 | start_count = IA64_LOG_COUNT(SAL_INFO_TYPE_CMC); |
1354 | 1351 | ||
1355 | ia64_mca_cmc_int_handler(cmc_irq, arg, ptregs); | 1352 | ia64_mca_cmc_int_handler(cmc_irq, arg); |
1356 | 1353 | ||
1357 | for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++); | 1354 | for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++); |
1358 | 1355 | ||
@@ -1403,14 +1400,13 @@ ia64_mca_cmc_poll (unsigned long dummy) | |||
1403 | * Inputs | 1400 | * Inputs |
1404 | * interrupt number | 1401 | * interrupt number |
1405 | * client data arg ptr | 1402 | * client data arg ptr |
1406 | * saved registers ptr | ||
1407 | * Outputs | 1403 | * Outputs |
1408 | * handled | 1404 | * handled |
1409 | */ | 1405 | */ |
1410 | #ifdef CONFIG_ACPI | 1406 | #ifdef CONFIG_ACPI |
1411 | 1407 | ||
1412 | static irqreturn_t | 1408 | static irqreturn_t |
1413 | ia64_mca_cpe_int_caller(int cpe_irq, void *arg, struct pt_regs *ptregs) | 1409 | ia64_mca_cpe_int_caller(int cpe_irq, void *arg) |
1414 | { | 1410 | { |
1415 | static int start_count = -1; | 1411 | static int start_count = -1; |
1416 | static int poll_time = MIN_CPE_POLL_INTERVAL; | 1412 | static int poll_time = MIN_CPE_POLL_INTERVAL; |
@@ -1422,7 +1418,7 @@ ia64_mca_cpe_int_caller(int cpe_irq, void *arg, struct pt_regs *ptregs) | |||
1422 | if (start_count == -1) | 1418 | if (start_count == -1) |
1423 | start_count = IA64_LOG_COUNT(SAL_INFO_TYPE_CPE); | 1419 | start_count = IA64_LOG_COUNT(SAL_INFO_TYPE_CPE); |
1424 | 1420 | ||
1425 | ia64_mca_cpe_int_handler(cpe_irq, arg, ptregs); | 1421 | ia64_mca_cpe_int_handler(cpe_irq, arg); |
1426 | 1422 | ||
1427 | for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++); | 1423 | for (++cpuid ; cpuid < NR_CPUS && !cpu_online(cpuid) ; cpuid++); |
1428 | 1424 | ||