Run interrupt handlers always with interrupts disabled
Subsystems (4)
cover Run interrupt handlers always with interrupts disabled
The following patch series removes the IRQF_DISABLED functionality from the core interrupt code and runs all interrupt handlers with interrupts disabled.
IRQF_DISABLED is kept as a define and scheduled for feature removal.
I booted and stressed that patches w/o any obvious fallout on more than 20 different systems in my arsenal of test machines which includes various embedded non x86 systems.
To debug eventual latency issues we (admittedly I talked acme into looking at that) want to extend perf with a top like tool to monitor the maximum runtime of interrupt handlers with the already existing tracepoints.
Thanks,
tglx
PATCH 1/2 genirq: Run irq handlers with interrupts disabled
Running interrupt handlers with interrupts enabled can cause stack overflows. That has been observed with multiqueue NICs delivering all their interrupts to a single core. We might band aid that somehow by checking the interrupt stacks, but the real safe fix is to run the irq handlers with interrupts disabled.
Drivers for whacky hardware still can reenable them in the handler itself, if the need arises. (They do already due to lockdep)
The risk of doing this is rather low:
- lockdep already enforces this
- CONFIG_NOHZ has shaken out the drivers which relied on jiffies updates
- time keeping is not longer sensitive to the timer interrupt being delayed
--- kernel/irq/handle.c | 3 --- 1 file changed, 3 deletions(-)
kernel/irq/handle.c +0 -3
@@ -370,9 +370,6 @@ irqreturn_t handle_IRQ_event(unsigned inirqreturn_t ret, retval =IRQ_NONE ;unsigned int status =0 ; -if (!(action->flags &IRQF_DISABLED )) -local_irq_enable_in_hardirq (); - do { trace_irq_handler_entry(irq, action); ret = action->handler(irq, action->dev_id);
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
Quoted 2 lines
Drivers for whacky hardware still can reenable them in the handler itself, if the need arises. (They do already due to lockdep)
Can you please explain that lockdep reference?
I don't think lockdep really forces on interrupts, does it?
BTW the one problem I have with this patchkit is that it's clearly no stable candidate and I was hoping for a stable fix too. Any chance to at least approve my original patch for .32/.33 only?
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
Quoted 5 lines · Andi Kleen
Quoted 2 lines
Drivers for whacky hardware still can reenable them in the handler itself, if the need arises. (They do already due to lockdep)
Can you please explain that lockdep reference?
I don't think lockdep really forces on interrupts, does it?
Lockdep forces interrupts off. It yells at anyone enabling irqs in the handler. The ones which do that have been annotated with local_irq_enable_in_hardirq(), which is a nop for lockdep.
Quoted 3 lines
BTW the one problem I have with this patchkit is that it's clearly no stable candidate and I was hoping for a stable fix too. Any chance to at least approve my original patch for .32/.33 only?
Why not simply force IRQF_DISABLED for all MSI interrupts. That still allows nesting for non MSI ones, but it limits the chance of throwing up reasonably well. That's a two liner.
Can you please test whether it resolves the issue at hand ?
Thanks,
tglx
---
kernel/irq/manage.c +3 -0
@@ -735,6 +735,9 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)if (new->flags &IRQF_ONESHOT ) desc->status |=IRQ_ONESHOT ; +if (desc->msi_desc) + new->flags |=IRQF_DISABLED ; +if (!(desc->status &IRQ_NOAUTOEN )) { desc->depth =0 ; desc->status &= ~IRQ_DISABLED ;
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
Quoted 5 lines
Why not simply force
IRQF_DISABLEDfor all MSI interrupts. That still allows nesting for non MSI ones, but it limits the chance of throwing up reasonably well. That's a two liner.Can you please test whether it resolves the issue at hand ?
Sorry for the late answer. Got confirmation that this patch fixes the test case. Thanks.
-Andi
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
Quoted 8 lines · Andi Kleen
Quoted 5 lines
Why not simply force
IRQF_DISABLEDfor all MSI interrupts. That still allows nesting for non MSI ones, but it limits the chance of throwing up reasonably well. That's a two liner.Can you please test whether it resolves the issue at hand ?
Sorry for the late answer. Got confirmation that this patch fixes the test case. Thanks.
Ok, I'll push it linus wards and cc stable. I think thats the least intrusive safe bet we can have right now.
Thanks,
tglx
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
Quoted 6 lines · Thomas Gleixner
Quoted 4 lines · Andi Kleen
Quoted 4 lines
Why not simply force
IRQF_DISABLEDfor all MSI interrupts. That still allows nesting for non MSI ones, but it limits the chance of throwing up reasonably well. That's a two liner.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Can you please test whether it resolves the issue at hand ?
Sorry for the late answer. Got confirmation that this patch fixes the test case. Thanks.
Ok, I'll push it linus wards and cc stable. I think thats the least intrusive safe bet we can have right now.
stable? I'd say thats way too intrusive for -stable...
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
Quoted 9 lines · Pavel Machek
Quoted 8 lines · Thomas Gleixner
Quoted 6 lines · Andi Kleen
Quoted 5 lines
Why not simply force
IRQF_DISABLEDfor all MSI interrupts. That still allows nesting for non MSI ones, but it limits the chance of throwing up reasonably well. That's a two liner.Can you please test whether it resolves the issue at hand ?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Sorry for the late answer. Got confirmation that this patch fixes the test case. Thanks.
Ok, I'll push it linus wards and cc stable. I think thats the least intrusive safe bet we can have right now.
stable? I'd say thats way too intrusive for -stable...
So we better let the possible stack overruns unaddressed ?
Thanks,
tglx
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
Quoted 14 lines · Thomas Gleixner
Quoted 12 lines · Pavel Machek
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Andi Kleen
Quoted 5 lines
Why not simply force
IRQF_DISABLEDfor all MSI interrupts. That still allows nesting for non MSI ones, but it limits the chance of throwing up reasonably well. That's a two liner.Can you please test whether it resolves the issue at hand ?
Sorry for the late answer. Got confirmation that this patch fixes the test case. Thanks.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Ok, I'll push it linus wards and cc stable. I think thats the least intrusive safe bet we can have right now.
stable? I'd say thats way too intrusive for -stable...
So we better let the possible stack overruns unaddressed ?
-stable should have no regressions, first and foremost. And this is pretty certain to introduce some, at least on low-powered system with serial ports.
So yes, it is probably better to let the possible stack overruns unaddressed. We have lived with them for 15 years or so...
(Alternatively, just make the irq stacks bigger? Or just take Andi's patch, which solves the overruns, and only introduces latency regressions when it would otherwise crash?)
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
Quoted 26 lines · Pavel Machek
Quoted 14 lines · Thomas Gleixner
Quoted 12 lines · Pavel Machek
Quoted 11 lines · Thomas Gleixner
Quoted 8 lines · Andi Kleen
Quoted 5 lines
Why not simply force
IRQF_DISABLEDfor all MSI interrupts. That still allows nesting for non MSI ones, but it limits the chance of throwing up reasonably well. That's a two liner.Can you please test whether it resolves the issue at hand ?
Sorry for the late answer. Got confirmation that this patch fixes the test case. Thanks.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Ok, I'll push it linus wards and cc stable. I think thats the least intrusive safe bet we can have right now.
stable? I'd say thats way too intrusive for -stable...
So we better let the possible stack overruns unaddressed ?
-stable should have no regressions, first and foremost. And this is pretty certain to introduce some, at least on low-powered system with serial ports.
Quoted 6 lines
So yes, it is probably better to let the possible stack overruns unaddressed. We have lived with them for 15 years or so...
(Alternatively, just make the irq stacks bigger? Or just take Andi's patch, which solves the overruns, and only introduces latency regressions when it would otherwise crash?)
You've got serial ports with MSI interrupts?
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
In reply to Pavel MachekPavel,
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Thomas Gleixner
Quoted 15 lines · Pavel Machek
Quoted 13 lines · Thomas Gleixner
Quoted 8 lines · Andi Kleen
Quoted 5 lines
Why not simply force
IRQF_DISABLEDfor all MSI interrupts. That still allows nesting for non MSI ones, but it limits the chance of throwing up reasonably well. That's a two liner.Can you please test whether it resolves the issue at hand ?
Sorry for the late answer. Got confirmation that this patch fixes the test case. Thanks.
Ok, I'll push it linus wards and cc stable. I think thats the least intrusive safe bet we can have right now.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
stable? I'd say thats way too intrusive for -stable...
So we better let the possible stack overruns unaddressed ?
-stable should have no regressions, first and foremost. And this is pretty certain to introduce some, at least on low-powered system with serial ports.
I think you misunderstood what I'm going to push. The patch merily forces IRQF_DISABLED for MSI(X) based interrupts. So that does not affect low powered systems in any way.
It only affects high end systems where Dave Miller already said he did the IRQF_DISABLED magic already in some NIC drivers just to prevent that.
So I think your fear of regressions for low-powered systems is completely unsubstantiated.
Thanks,
tglx
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
Quoted 30 lines · Thomas Gleixner
Pavel,
Quoted 18 lines · Pavel Machek
Quoted 17 lines · Thomas Gleixner
Quoted 15 lines · Pavel Machek
Quoted 13 lines · Thomas Gleixner
Quoted 8 lines · Andi Kleen
Quoted 5 lines
Why not simply force
IRQF_DISABLEDfor all MSI interrupts. That still allows nesting for non MSI ones, but it limits the chance of throwing up reasonably well. That's a two liner.Can you please test whether it resolves the issue at hand ?
Sorry for the late answer. Got confirmation that this patch fixes the test case. Thanks.
Ok, I'll push it linus wards and cc stable. I think thats the least intrusive safe bet we can have right now.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
stable? I'd say thats way too intrusive for -stable...
So we better let the possible stack overruns unaddressed ?
-stable should have no regressions, first and foremost. And this is pretty certain to introduce some, at least on low-powered system with serial ports.
Quoted 7 lines
I think you misunderstood what I'm going to push. The patch merily forces
IRQF_DISABLEDfor MSI(X) based interrupts. So that does not affect low powered systems in any way.It only affects high end systems where Dave Miller already said he did the
IRQF_DISABLEDmagic already in some NIC drivers just to prevent that.
Oops, yes, I did; lost in all the mails.
Quoted 2 lines
So I think your fear of regressions for low-powered systems is completely unsubstantiated.
Yep. Sorry for the noise.
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[tip:irq/core] genirq: Run irq handlers with interrupts disabled
In reply to Thomas GleixnerCommit-ID: e58aa3d2d0cc01ad8d6f7f640a0670433f794922 Gitweb: http://git.kernel.org/tip/e58aa3d2d0cc01ad8d6f7f640a0670433f794922 Author: Ingo Molnar <[email protected]> AuthorDate: Fri, 26 Mar 2010 00:06:51 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 13 Apr 2010 16:36:40 +0200
genirq: Run irq handlers with interrupts disabled
Running interrupt handlers with interrupts enabled can cause stack overflows. That has been observed with multiqueue NICs delivering all their interrupts to a single core. We might band aid that somehow by checking the interrupt stacks, but the real safe fix is to run the irq handlers with interrupts disabled.
Drivers for whacky hardware still can reenable them in the handler itself, if the need arises. (They do already due to lockdep)
The risk of doing this is rather low:
- lockdep already enforces this
- CONFIG_NOHZ has shaken out the drivers which relied on jiffies updates
- time keeping is not longer sensitive to the timer interrupt being delayed
LKML-Reference: <[email protected]>
--- kernel/irq/handle.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
kernel/irq/handle.c +0 -3
@@ -370,9 +370,6 @@ irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action)irqreturn_t ret, retval =IRQ_NONE ;unsigned int status =0 ; -if (!(action->flags &IRQF_DISABLED )) -local_irq_enable_in_hardirq (); - do { trace_irq_handler_entry(irq, action); ret = action->handler(irq, action->dev_id);
Re: [tip:irq/core] genirq: Run irq handlers with interrupts disabled
Quoted 15 lines · tip-bot for Ingo Molnar
Commit-ID: e58aa3d2d0cc01ad8d6f7f640a0670433f794922 Gitweb: http://git.kernel.org/tip/e58aa3d2d0cc01ad8d6f7f640a0670433f794922 Author: Ingo Molnar <[email protected]> AuthorDate: Fri, 26 Mar 2010 00:06:51 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 13 Apr 2010 16:36:40 +0200genirq: Run irq handlers with interrupts disabled
Running interrupt handlers with interrupts enabled can cause stack overflows. That has been observed with multiqueue NICs delivering all their interrupts to a single core. We might band aid that somehow by checking the interrupt stacks, but the real safe fix is to run the irq handlers with interrupts disabled.
Quoted 8 lines
Drivers for whacky hardware still can reenable them in the handler itself, if the need arises. (They do already due to lockdep)
The risk of doing this is rather low:
- lockdep already enforces this
-CONFIG_NOHZhas shaken out the drivers which relied on jiffies updates
- time keeping is not longer sensitive to the timer interrupt being delayed
Clearly I don't mind this, but shouldn't we at least first convert the known problematic drivers to an alternative strategy?
IDE-PIO, that one ancient NIC etc..
Quoted 18 lines
--- kernel/irq/handle.c | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)kernel/irq/handle.c +0
-3@@ -370,9 +370,6 @@ irqreturn_t handle_IRQ_event(unsigned int irq, struct irqaction *action)irqreturn_t ret, retval =IRQ_NONE ;unsigned int status =0 ; -if (!(action->flags &IRQF_DISABLED )) -local_irq_enable_in_hardirq (); - do { trace_irq_handler_entry(irq, action); ret = action->handler(irq, action->dev_id);
Re: [patch 1/2] genirq: Run irq handlers with interrupts disabled
In reply to Thomas GleixnerJust noticed a minor side effect of this patch on /proc/stat.
As int handlers run with ints disabled, timer interrupt based samples will no longer account for any irq time. As a result, irq time in /proc/stat, top, etc will be mostly zero (unless some handler is enabling ints).
This is not a problem on s390, powerpc, ia64 when VIRT_CPU_ACCOUNTING is enabled.
May be we should gracefully call it out as zero, with patch like below?
--- Documentation/filesystems/proc.txt | 2 +- fs/proc/stat.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletions(-)
Documentation/filesystems/proc.txt +1 -1
@@ -1123,7 +1123,7 @@ second). The meanings of the columns are as follows, from left to right: - system: processes executing in kernel mode - idle: twiddling thumbs - iowait: waiting for I/O to complete -- irq: servicing interrupts +- irq: servicing interrupts (valid only with VIRT_CPU_ACCOUNTING, 0 otherwise) - softirq: servicing softirqs - steal: involuntary wait - guest: running a normal guest
fs/proc/stat.c +4 -0
@@ -46,7 +46,9 @@ static int show_stat(struct seq_file *p, void *v) idle =cputime64_add (idle,kstat_cpu (i).cpustat.idle); idle =cputime64_add (idle,arch_idle_time (i)); iowait =cputime64_add (iowait,kstat_cpu (i).cpustat.iowait); +#ifdef CONFIG_VIRT_CPU_ACCOUNTING irq =cputime64_add (irq,kstat_cpu (i).cpustat.irq); +#endif softirq =cputime64_add (softirq,kstat_cpu (i).cpustat.softirq); steal =cputime64_add (steal,kstat_cpu (i).cpustat.steal); guest =cputime64_add (guest,kstat_cpu (i).cpustat.guest);
@@ -87,7 +89,9 @@ static int show_stat(struct seq_file *p, void *v) idle =kstat_cpu (i).cpustat.idle; idle =cputime64_add (idle,arch_idle_time (i)); iowait =kstat_cpu (i).cpustat.iowait; +#ifdef CONFIG_VIRT_CPU_ACCOUNTING irq =kstat_cpu (i).cpustat.irq; +#endif softirq =kstat_cpu (i).cpustat.softirq; steal =kstat_cpu (i).cpustat.steal; guest =kstat_cpu (i).cpustat.guest;
Signature · 1 line
1.7.0.1
PATCH 2/2 genirq: Remove IRQF_DISABLED from core code
In reply to Thomas GleixnerRemove all code which is related to IRQF_DISABLED from the core kernel code. IRQF_DISABLED still exists as a flag, but becomes a NOOP and will be removed after a grace period. That way we can easily revert to the previous behaviour by just restoring the core code.
--- Documentation/feature-removal-schedule.txt | 7 +++++++ include/linux/interrupt.h | 3 ++- kernel/irq/manage.c | 20 -------------------- 3 files changed, 9 insertions(+), 21 deletions(-)
Documentation/feature-removal-schedule.txt +7 -0
@@ -589,3 +589,10 @@ Why: Useful in 2003, implementation is a Generally invoked by accident today. Seen as doing more harm than good. Who: Len Brown <[email protected]> + +---------------------------- + +What: IRQF_DISABLED +When: 2.6.36 +Why: The flag is a NOOP as we run interrupt handlers with interrupts disabled +Who: Thomas Gleixner <[email protected]>
include/linux/interrupt.h +2 -1
@@ -39,7 +39,8 @@* These flags used only by the kernel as part of the * irq handling routines. * -* IRQF_DISABLED - keep irqs disabled when calling the action handler +* IRQF_DISABLED - keep irqs disabled when calling the action handler. +* DEPRECATED. This flag is a NOOP and scheduled to be removed * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator * IRQF_SHARED - allow sharing the irq among several devices * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur
kernel/irq/manage.c +0 -20
@@ -995,7 +995,6 @@ EXPORT_SYMBOL(free_irq);* Flags: * * IRQF_SHARED Interrupt is shared -* IRQF_DISABLED Disable local interrupts while processing * IRQF_SAMPLE_RANDOM The interrupt can be used for entropy * IRQF_TRIGGER_* Specify active edge(s) or level *
@@ -1009,25 +1008,6 @@ int request_threaded_irq(unsigned int irint retval;/* -* handle_IRQ_event() always ignores IRQF_DISABLED except for -* the _first_ irqaction (sigh). That can cause oopsing, but -* the behavior is classified as "will not fix" so we need to -* start nudging drivers away from using that idiom. -*/ -if ((irqflags & (IRQF_SHARED |IRQF_DISABLED )) == - (IRQF_SHARED |IRQF_DISABLED )) { -pr_warning ( -"IRQ %d/%s: IRQF_DISABLED is not guaranteed on shared IRQs\n" , - irq, devname); - } - -#ifdef CONFIG_LOCKDEP -/* -* Lockdep wants atomic interrupt handlers: -*/ - irqflags |=IRQF_DISABLED ; -#endif -/* * Sanity-check: shared interrupts must pass in a real dev-ID, * otherwise we'll have trouble later trying to figure out * which interrupt is which (messes up the interrupt freeing
Re: [patch 2/2] genirq: Remove IRQF_DISABLED from core code
Quoted 4 lines · Thomas Gleixner
Remove all code which is related to
IRQF_DISABLEDfrom the core kernel code.IRQF_DISABLEDstill exists as a flag, but becomes a NOOP and will be removed after a grace period. That way we can easily revert to the previous behaviour by just restoring the core code.
Perhaps I'm dense but it's not fully clear to me why is suddenly safe to use the behaviour of this flags on shared interrupts when it wasn't before?
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Re: [patch 2/2] genirq: Remove IRQF_DISABLED from core code
Quoted 8 lines · Andi Kleen
Quoted 4 lines · Thomas Gleixner
Remove all code which is related to
IRQF_DISABLEDfrom the core kernel code.IRQF_DISABLEDstill exists as a flag, but becomes a NOOP and will be removed after a grace period. That way we can easily revert to the previous behaviour by just restoring the core code.Perhaps I'm dense but it's not fully clear to me why is suddenly safe to use the behaviour of this flags on shared interrupts when it wasn't before?
The shared handlers cannot guarantee to run one with irqs enabled and the other with irqs disabled. That's all. There is absolutely no reason why we would need interrupts enabled to process the shared handler chain.
Thanks,
tglx
[tip:irq/core] genirq: Remove IRQF_DISABLED from core code
In reply to Thomas GleixnerCommit-ID: 6932bf37bed45ce8ed531928b1b0f98162fe6df6 Gitweb: http://git.kernel.org/tip/6932bf37bed45ce8ed531928b1b0f98162fe6df6 Author: Thomas Gleixner <[email protected]> AuthorDate: Fri, 26 Mar 2010 00:06:55 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 13 Apr 2010 16:36:40 +0200
genirq: Remove IRQF_DISABLED from core code
Remove all code which is related to IRQF_DISABLED from the core kernel code. IRQF_DISABLED still exists as a flag, but becomes a NOOP and will be removed after a grace period. That way we can easily revert to the previous behaviour by just restoring the core code.
LKML-Reference: <[email protected]>
--- Documentation/feature-removal-schedule.txt | 7 ++++++ include/linux/interrupt.h | 3 +- kernel/irq/manage.c | 30 ---------------------------- 3 files changed, 9 insertions(+), 31 deletions(-)
Documentation/feature-removal-schedule.txt +7 -0
@@ -589,3 +589,10 @@ Why: Useful in 2003, implementation is a hack. Generally invoked by accident today. Seen as doing more harm than good. Who: Len Brown <[email protected]> + +---------------------------- + +What: IRQF_DISABLED +When: 2.6.36 +Why: The flag is a NOOP as we run interrupt handlers with interrupts disabled +Who: Thomas Gleixner <[email protected]>
include/linux/interrupt.h +2 -1
@@ -39,7 +39,8 @@* These flags used only by the kernel as part of the * irq handling routines. * -* IRQF_DISABLED - keep irqs disabled when calling the action handler +* IRQF_DISABLED - keep irqs disabled when calling the action handler. +* DEPRECATED. This flag is a NOOP and scheduled to be removed * IRQF_SAMPLE_RANDOM - irq is used to feed the random generator * IRQF_SHARED - allow sharing the irq among several devices * IRQF_PROBE_SHARED - set by callers when they expect sharing mismatches to occur
kernel/irq/manage.c +0 -30
@@ -757,16 +757,6 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)if (new->flags &IRQF_ONESHOT ) desc->status |=IRQ_ONESHOT ; -/* -* Force MSI interrupts to run with interrupts -* disabled. The multi vector cards can cause stack -* overflows due to nested interrupts when enough of -* them are directed to a core and fire at the same -* time. -*/ -if (desc->msi_desc) - new->flags |=IRQF_DISABLED ; -if (!(desc->status &IRQ_NOAUTOEN )) { desc->depth =0 ; desc->status &= ~IRQ_DISABLED ;
@@ -1027,7 +1017,6 @@ EXPORT_SYMBOL(free_irq);* Flags: * * IRQF_SHARED Interrupt is shared -* IRQF_DISABLED Disable local interrupts while processing * IRQF_SAMPLE_RANDOM The interrupt can be used for entropy * IRQF_TRIGGER_* Specify active edge(s) or level *
@@ -1041,25 +1030,6 @@ int request_threaded_irq(unsigned int irq, irq_handler_t handler,int retval;/* -* handle_IRQ_event() always ignores IRQF_DISABLED except for -* the _first_ irqaction (sigh). That can cause oopsing, but -* the behavior is classified as "will not fix" so we need to -* start nudging drivers away from using that idiom. -*/ -if ((irqflags & (IRQF_SHARED |IRQF_DISABLED )) == - (IRQF_SHARED |IRQF_DISABLED )) { -pr_warning ( -"IRQ %d/%s: IRQF_DISABLED is not guaranteed on shared IRQs\n" , - irq, devname); - } - -#ifdef CONFIG_LOCKDEP -/* -* Lockdep wants atomic interrupt handlers: -*/ - irqflags |=IRQF_DISABLED ; -#endif -/* * Sanity-check: shared interrupts must pass in a real dev-ID, * otherwise we'll have trouble later trying to figure out * which interrupt is which (messes up the interrupt freeing
From: Thomas Gleixner <[email protected]>
Date: Fri, 26 Mar 2010 00:06:44 -0000
Quoted 6 lines
The following patch series removes the
IRQF_DISABLEDfunctionality from the core interrupt code and runs all interrupt handlers with interrupts disabled.
IRQF_DISABLEDis kept as a define and scheduled for feature removal.
Quoted 8 lines
I booted and stressed that patches w/o any obvious fallout on more than 20 different systems in my arsenal of test machines which includes various embedded non x86 systems.
To debug eventual latency issues we (admittedly I talked acme into looking at that) want to extend perf with a top like tool to monitor the maximum runtime of interrupt handlers with the already existing tracepoints.
Quoted 3 lines · Thomas Gleixner
The following patch series removes the
IRQF_DISABLEDfunctionality from the core interrupt code and runs all interrupt handlers with interrupts disabled.
As was covered in previous discussions, what about drivers such as SMC91x which take a long time to retrieve packets from the hardware? Always running handlers with IRQs disabled will kill things such as serial on these platforms.
So based on your description, I have no option but to NAK this.
Signature · 3 lines
Russell King Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/ maintainer of:
Quoted 9 lines · Russell King
Quoted 3 lines · Thomas Gleixner
The following patch series removes the
IRQF_DISABLEDfunctionality from the core interrupt code and runs all interrupt handlers with interrupts disabled.As was covered in previous discussions, what about drivers such as SMC91x which take a long time to retrieve packets from the hardware? Always running handlers with IRQs disabled will kill things such as serial on these platforms.
As long as it's rare (which it is) i dont see a problem: you can enable interrupts in the handler by using local_irq_enable(), like the IDE PIO drivers do. That way it's documented a bit better as well, because it shows the precise source of the latency, with a big comment explaining it, etc.
Thanks,
Ingo
Quoted 12 lines · Ingo Molnar
Quoted 9 lines · Russell King
Quoted 3 lines · Thomas Gleixner
The following patch series removes the
IRQF_DISABLEDfunctionality from the core interrupt code and runs all interrupt handlers with interrupts disabled.As was covered in previous discussions, what about drivers such as SMC91x which take a long time to retrieve packets from the hardware? Always running handlers with IRQs disabled will kill things such as serial on these platforms.
Quoted 4 lines
As long as it's rare (which it is) i dont see a problem: you can enable interrupts in the handler by using
local_irq_enable(), like the IDE PIO drivers do. That way it's documented a bit better as well, because it shows the precise source of the latency, with a big comment explaining it, etc.
Or alternatively, use threaded interrupts for such slow hardware.
Quoted 13 lines · Peter Zijlstra
Quoted 12 lines · Ingo Molnar
Quoted 9 lines · Russell King
Quoted 3 lines · Thomas Gleixner
The following patch series removes the
IRQF_DISABLEDfunctionality from the core interrupt code and runs all interrupt handlers with interrupts disabled.As was covered in previous discussions, what about drivers such as SMC91x which take a long time to retrieve packets from the hardware? Always running handlers with IRQs disabled will kill things such as serial on these platforms.
Quoted 6 lines
Quoted 4 lines
As long as it's rare (which it is) i dont see a problem: you can enable interrupts in the handler by using
local_irq_enable(), like the IDE PIO drivers do. That way it's documented a bit better as well, because it shows the precise source of the latency, with a big comment explaining it, etc.Or alternatively, use threaded interrupts for such slow hardware.
What is the latency of threaded interrupts these days, compared with non-threaded interrupts?
Slow hardware is quite sensitive to increases in latency. Obviously not a problem for the sources of latency: it's a problem for the irq which is _sensitive_ to latency caused by the other one. That is typically a serial port or something.
But the benefit of kernel-settable interrupt priorities (i.e. due to the threads) may be worth it even for serial ports. I would love to see some measurements comparing with and without.
-- Jamie
Quoted 4 lines
As long as it's rare (which it is) i dont see a problem: you can enable interrupts in the handler by using
local_irq_enable(), like the IDE PIO drivers do. That way it's documented a bit better as well, because it shows the precise source of the latency, with a big comment explaining it, etc.
I don't think it's as rare as you think particularly in embedded, and the moment you start explicitly using local_irq_enable() you've simply moved the underlying problem back and made it far harder to grep for.
Alan
Quoted 8 lines · Alan Cox
Quoted 4 lines
As long as it's rare (which it is) i dont see a problem: you can enable interrupts in the handler by using
local_irq_enable(), like the IDE PIO drivers do. That way it's documented a bit better as well, because it shows the precise source of the latency, with a big comment explaining it, etc.I don't think it's as rare as you think particularly in embedded, and the moment you start explicitly using
local_irq_enable()you've simply moved the underlying problem back and made it far harder to grep for.
We've got local_irq_enable_in_hardirq() which should be used and can easily be grep'ed for.
But yes, I would much prefer to simply convert these known slow handlers to threaded interrupts.
Quoted 10 lines · Peter Zijlstra
Quoted 8 lines · Alan Cox
Quoted 4 lines
As long as it's rare (which it is) i dont see a problem: you can enable interrupts in the handler by using
local_irq_enable(), like the IDE PIO drivers do. That way it's documented a bit better as well, because it shows the precise source of the latency, with a big comment explaining it, etc.I don't think it's as rare as you think particularly in embedded, and the moment you start explicitly using
local_irq_enable()you've simply moved the underlying problem back and made it far harder to grep for.
Quoted 5 lines
We've got
local_irq_enable_in_hardirq()which should be used and can easily be grep'ed for.But yes, I would much prefer to simply convert these known slow handlers to threaded interrupts.
That could be potentially hundreds in old obscure drivers all over the tree.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Quoted 10 lines · Peter Zijlstra
Quoted 8 lines · Alan Cox
Quoted 4 lines
As long as it's rare (which it is) i dont see a problem: you can enable interrupts in the handler by using
local_irq_enable(), like the IDE PIO drivers do. That way it's documented a bit better as well, because it shows the precise source of the latency, with a big comment explaining it, etc.I don't think it's as rare as you think particularly in embedded, and the moment you start explicitly using
local_irq_enable()you've simply moved the underlying problem back and made it far harder to grep for.
Quoted 5 lines
We've got
local_irq_enable_in_hardirq()which should be used and can easily be grep'ed for.But yes, I would much prefer to simply convert these known slow handlers to threaded interrupts.
Yeah, agreed. So there's multiple solutions:
- On old hw with a driver that nobody is willing to convert to threaded IRQs:
use the existing local_irq_enable_in_hardirq() API. This preserves the status quo.
- On new hw with new drivers where there's such a level of IRQ parallelism that enabling IRQs in hardirqs is not an option, use threaded IRQ handlers.
Thanks,
Ingo
Quoted 10 lines · Peter Zijlstra
Quoted 8 lines · Alan Cox
Quoted 4 lines
As long as it's rare (which it is) i dont see a problem: you can enable interrupts in the handler by using
local_irq_enable(), like the IDE PIO drivers do. That way it's documented a bit better as well, because it shows the precise source of the latency, with a big comment explaining it, etc.I don't think it's as rare as you think particularly in embedded, and the moment you start explicitly using
local_irq_enable()you've simply moved the underlying problem back and made it far harder to grep for.
Quoted 5 lines
We've got
local_irq_enable_in_hardirq()which should be used and can easily be grep'ed for.But yes, I would much prefer to simply convert these known slow handlers to threaded interrupts.
Can't do that. The smc91x has a very small internal buffer which has to be emptied using PIO. Threaded interrupts simply have too high latencies for overruns not to occur. That's why the RX path is entirely done in hardirq context while the TX path is done in softirq context.
Nicolas
Quoted 15 lines · Nicolas Pitre
Quoted 13 lines · Peter Zijlstra
Quoted 8 lines · Alan Cox
Quoted 4 lines
As long as it's rare (which it is) i dont see a problem: you can enable interrupts in the handler by using
local_irq_enable(), like the IDE PIO drivers do. That way it's documented a bit better as well, because it shows the precise source of the latency, with a big comment explaining it, etc.I don't think it's as rare as you think particularly in embedded, and the moment you start explicitly using
local_irq_enable()you've simply moved the underlying problem back and made it far harder to grep for.We've got
local_irq_enable_in_hardirq()which should be used and can easily be grep'ed for.
Quoted 7 lines
Quoted 2 lines
But yes, I would much prefer to simply convert these known slow handlers to threaded interrupts.
Can't do that. The smc91x has a very small internal buffer which has to be emptied using PIO. Threaded interrupts simply have too high latencies for overruns not to occur. That's why the RX path is entirely done in hardirq context while the TX path is done in softirq context.
Although I wouldn't be surprised to find threaded interrupts are too slow on certain hardware, is that _fundamental_ to threaded interrupts, or is it just that our implementation doesn't have the funky hot path straight direct from hardirq -> running high priority RT irq thread when it exceeds previously running priority?
In other words, can we swizzle threaded irqs into something more resembling software-implemented hard irq priorities, while cunningly updating the kernel state just enough to look like it's a thread?
-- Jamie