x86: Document the hotplug code is incompatible with x86 irq handling
PATCH 1/1 x86: Document the hotplug code is incompatible with x86 irq handling
I just realized that except for doing the code review and noticing that the current cpu hotplug code is fundamentally incompatible with x86 I haven't done anything about it. So here is my patch to document what is wrong.
The current cpu hotplug code requires irqs to be migrated from a cpu outside of irq context. On x86 ioapics simply do not support this, making the code unfixable without major redesign of the generic cpu hotplug code.
So this patch makes CPU_HOTPLUG on x86 depend on CONFIG_BROKEN and adds a WARN_ON so people that do enable it are not in doubt about which part of the code is broken, even if it does work for them.
--- arch/i386/Kconfig | 2 +- arch/i386/kernel/irq.c | 13 +++++++++++++ arch/x86_64/Kconfig | 2 +- arch/x86_64/kernel/irq.c | 13 +++++++++++++ 4 files changed, 28 insertions(+), 2 deletions(-)
arch/i386/Kconfig +1 -1
@@ -892,7 +892,7 @@ config PHYSICAL_ALIGN config HOTPLUG_CPU bool "Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)" - depends on SMP && HOTPLUG && EXPERIMENTAL && !X86_VOYAGER + depends on SMP && HOTPLUG && EXPERIMENTAL && !X86_VOYAGER && BROKEN ---help--- Say Y here to experiment with turning CPUs off and on, and to enable suspend on SMP systems. CPUs can be controlled through
arch/i386/kernel/irq.c +13 -0
@@ -312,6 +312,19 @@ void fixup_irqs(cpumask_t map)unsigned int irq;static int warned; +/* +* Function is so wrong at so many levels. +* - We migrate irqs that are directed at the cpu we are +* removing. +* - We cannot safely migrate ioapic irqs on x86 except in +* side of irq context. +* - We are enabling irqs when the interface requires irqs to +* be disabled. +* Since someone probably finds this useful just warn very +* loudly until cpu hotplug is redesigned. +*/ +WARN_ON (1 ); +for (irq =0 ; irq <NR_IRQS ; irq++) {cpumask_t mask;if (irq ==2 )
arch/x86_64/Kconfig +1 -1
@@ -429,7 +429,7 @@ config NR_CPUS config HOTPLUG_CPU bool "Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)" - depends on SMP && HOTPLUG && EXPERIMENTAL + depends on SMP && HOTPLUG && EXPERIMENTAL && BROKEN help Say Y here to experiment with turning CPUs off and on. CPUs can be controlled through /sys/devices/system/cpu/cpu#.
arch/x86_64/kernel/irq.c +13 -0
@@ -142,6 +142,19 @@ void fixup_irqs(cpumask_t map)unsigned int irq;static int warned; +/* +* Function is so wrong at so many levels. +* - We migrate irqs that are directed at the cpu we are +* removing. +* - We cannot safely migrate ioapic irqs on x86 except in +* side of irq context. +* - We are enabling irqs when the interface requires irqs to +* be disabled. +* Since someone probably finds this useful just warn very +* loudly until cpu hotplug is redesigned. +*/ +WARN_ON (1 ); +for (irq =0 ; irq <NR_IRQS ; irq++) {cpumask_t mask;if (irq ==2 )
Signature · 1 line
1.5.1.1.181.g2de0
Hi!
Quoted 18 lines
I just realized that except for doing the code review and noticing that the current cpu hotplug code is fundamentally incompatible with x86 I haven't done anything about it. So here is my patch to document what is wrong.
The current cpu hotplug code requires irqs to be migrated from a cpu outside of irq context. On x86 ioapics simply do not support this, making the code unfixable without major redesign of the generic cpu hotplug code.
So this patch makes
CPU_HOTPLUGon x86 depend onCONFIG_BROKENand adds aWARN_ONso people that do enable it are not in doubt about which part of the code is broken, even if it does work for them.
arch/i386/kernel/irq.c void fixup_irqs(cpumask_t map) · line 318
Quoted 7 lines
arch/i386/kernel/irq.c +4
-0@@ -312,6 +312,19 @@ void fixup_irqs(cpumask_t map)unsigned int irq;static int warned; +/* +* Function is so wrong at so many levels. +* - We migrate irqs that are directed at the cpu we are +* removing.
Is this about irq pinning?
arch/i386/kernel/irq.c void fixup_irqs(cpumask_t map) · line 320
Quoted 2 lines
arch/i386/kernel/irq.c +2
-0+* - We cannot safely migrate ioapic irqs on x86 except in +* side of irq context.
'inside'?
Can you be more specific for this one?
arch/i386/kernel/irq.c void fixup_irqs(cpumask_t map) · line 326
Quoted 4 lines
arch/i386/kernel/irq.c +4
-0+* Since someone probably finds this useful just warn very +* loudly until cpu hotplug is redesigned. +*/ +WARN_ON (1 );
Ugh, no, this does not warn anyone. This will just make people ask me why they see stack trace while suspending... and we are not interested in the stack trace, anyway.
printk(KERN_WARNING)?
arch/x86_64/Kconfig config NR_CPUS · line 433
Quoted 10 lines
index 5ce9443..a61c4f2 100644
arch/x86_64/Kconfig +1
-1@@ -429,7 +429,7 @@ config NR_CPUS config HOTPLUG_CPU bool "Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)" - depends on SMP && HOTPLUG && EXPERIMENTAL + depends on SMP && HOTPLUG && EXPERIMENTAL && BROKEN help
Great, this will force everyone and their dog to enable broken, making broken useless. Please don't.
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 23 lines · Pavel Machek
Hi!
Quoted 21 lines
I just realized that except for doing the code review and noticing that the current cpu hotplug code is fundamentally incompatible with x86 I haven't done anything about it. So here is my patch to document what is wrong.
The current cpu hotplug code requires irqs to be migrated from a cpu outside of irq context. On x86 ioapics simply do not support this, making the code unfixable without major redesign of the generic cpu hotplug code.
So this patch makes
CPU_HOTPLUGon x86 depend onCONFIG_BROKENand adds aWARN_ONso people that do enable it are not in doubt about which part of the code is broken, even if it does work for them.arch/i386/kernel/irq.c +0
-0@@ -312,6 +312,19 @@ void fixup_irqs(cpumask_t map)unsigned int irq;static int warned;
Quoted 6 lines
arch/i386/kernel/irq.c void fixup_irqs(cpumask_t map) · line 318
Quoted 4 lines
arch/i386/kernel/irq.c +4
-0+/* +* Function is so wrong at so many levels. +* - We migrate irqs that are directed at the cpu we are +* removing. Is this about irq pinning?
Sorry. That should have been: We migrate irqs that are not directed at the cpu we are removing. (We are migrating irqs when it is unnecessary).
Quoted 6 lines
arch/i386/kernel/irq.c void fixup_irqs(cpumask_t map) · line 320
Quoted 2 lines
arch/i386/kernel/irq.c +2
-0+* - We cannot safely migrate ioapic irqs on x86 except in +* side of irq context. 'inside'?
Can you be more specific for this one?
Yes inside.
An irq migration currently requires two instances of the irq firing to complete. Once on the source cpu once on the target cpu.
Migrating irqs while the irq is alive is a royal pain.
Quoted 10 lines
arch/i386/kernel/irq.c void fixup_irqs(cpumask_t map) · line 326
Quoted 4 lines
arch/i386/kernel/irq.c +4
-0+* Since someone probably finds this useful just warn very +* loudly until cpu hotplug is redesigned. +*/ +WARN_ON (1 );Ugh, no, this does not warn anyone. This will just make people ask me why they see stack trace while suspending... and we are not interested in the stack trace, anyway.
printk(KERN_WARNING)?
Because you are calling unfixably broken code. That should be a decent incentive to do something else won't it?
IOAPICs do not support what the code is doing here. There is lots of practical evidence including bad experiences and practical tests that support this.
I suspect the only reason you don't have problems is that the irqs are already shut down at the source before we get to this code path.
Quoted 5 lines
Quoted 5 lines
index 5ce9443..a61c4f2 100644
arch/x86_64/Kconfig +0
-0@@ -429,7 +429,7 @@ config NR_CPUS
Quoted 8 lines
arch/x86_64/Kconfig config NR_CPUS · line 433
Quoted 5 lines
arch/x86_64/Kconfig +1
-1config HOTPLUG_CPU bool "Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)" - depends on SMP && HOTPLUG && EXPERIMENTAL + depends on SMP && HOTPLUG && EXPERIMENTAL && BROKEN helpGreat, this will force everyone and their dog to enable broken, making broken useless. Please don't.
CONFIG_BROKEN is quite likely excessive but the code is totally and unfixably broken. So it still doesn't feel wrong to me.
Perhaps we should just disable swap suspend on SMP until we get a design that can be implemented correctly on existing hardware. I am not happy with people telling me that we must keep broken code because people with brand new SMP laptops will scream otherwise. Since the fundamental problems in this code path don't appear to bite people very frequently I don't mind waiting while an alternative solution is debugged and tested, but there is no way it makes sense to keep this code in service more for more than a kernel release or two.
Eric
Quoted 58 lines · Eric W. Biederman
Quoted 23 lines · Pavel Machek
Hi!
Quoted 21 lines
I just realized that except for doing the code review and noticing that the current cpu hotplug code is fundamentally incompatible with x86 I haven't done anything about it. So here is my patch to document what is wrong.
The current cpu hotplug code requires irqs to be migrated from a cpu outside of irq context. On x86 ioapics simply do not support this, making the code unfixable without major redesign of the generic cpu hotplug code.
So this patch makes
CPU_HOTPLUGon x86 depend onCONFIG_BROKENand adds aWARN_ONso people that do enable it are not in doubt about which part of the code is broken, even if it does work for them.arch/i386/kernel/irq.c +0
-0@@ -312,6 +312,19 @@ void fixup_irqs(cpumask_t map)unsigned int irq;static int warned;Quoted 6 lines
arch/i386/kernel/irq.c void fixup_irqs(cpumask_t map) · line 318
Quoted 4 lines
arch/i386/kernel/irq.c +4
-0+/* +* Function is so wrong at so many levels. +* - We migrate irqs that are directed at the cpu we are +* removing. Is this about irq pinning?
Sorry. That should have been: We migrate irqs that are not directed at the cpu we are removing. (We are migrating irqs when it is unnecessary).
Quoted 6 lines
arch/i386/kernel/irq.c void fixup_irqs(cpumask_t map) · line 320
Quoted 2 lines
arch/i386/kernel/irq.c +2
-0+* - We cannot safely migrate ioapic irqs on x86 except in +* side of irq context. 'inside'?
Can you be more specific for this one?
Yes inside.
An irq migration currently requires two instances of the irq firing to complete. Once on the source cpu once on the target cpu.
Migrating irqs while the irq is alive is a royal pain.
Quoted 9 lines
arch/i386/kernel/irq.c void fixup_irqs(cpumask_t map) · line 326
Quoted 4 lines
arch/i386/kernel/irq.c +4
-0+* Since someone probably finds this useful just warn very +* loudly until cpu hotplug is redesigned. +*/ +WARN_ON (1 );Ugh, no, this does not warn anyone. This will just make people ask me why they see stack trace while suspending... and we are not interested in the stack trace, anyway.
Quoted 5 lines
Quoted 1 line
printk(KERN_WARNING)?Because you are calling unfixably broken code. That should be a decent incentive to do something else won't it?
Can you please tell me _what_ else can be done?
Quoted 3 lines
IOAPICs do not support what the code is doing here. There is lots of practical evidence including bad experiences and practical tests that support this.
Well, AFAICS, Suresh has tried to debug one failing case recently without any consistent conclusions. I don't know of any other test cases (links, please?).
Quoted 2 lines
I suspect the only reason you don't have problems is that the irqs are already shut down at the source before we get to this code path.
You are probably right, but OTOH I've tried the CPU hotplug via the sysfs interface for _many_ times and it has _never_ failed for me.
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
index 5ce9443..a61c4f2 100644
arch/x86_64/Kconfig +0
-0@@ -429,7 +429,7 @@ config NR_CPUSQuoted 8 lines
arch/x86_64/Kconfig config NR_CPUS · line 433
Quoted 5 lines
arch/x86_64/Kconfig +1
-1config HOTPLUG_CPU bool "Support for suspend on SMP and hot-pluggable CPUs (EXPERIMENTAL)" - depends on SMP && HOTPLUG && EXPERIMENTAL + depends on SMP && HOTPLUG && EXPERIMENTAL && BROKEN helpGreat, this will force everyone and their dog to enable broken, making broken useless. Please don't.
Quoted 5 lines
CONFIG_BROKENis quite likely excessive but the code is totally and unfixably broken. So it still doesn't feel wrong to me.Perhaps we should just disable swap suspend on SMP until we get a design that can be implemented correctly on existing hardware.
All kinds of suspend, not only hibernation.
Quoted 2 lines
I am not happy with people telling me that we must keep broken code because people with brand new SMP laptops will scream otherwise.
Sorry, but that's how it goes.
We've been using that code for more then a year now and I'd expect someone to tell us that it's wrong a bit earlier.
If you are telling us to drop it now, then _please_ advise what we can use instead, because we obviously need the functionality.
Quoted 4 lines
Since the fundamental problems in this code path don't appear to bite people very frequently I don't mind waiting while an alternative solution is debugged and tested, but there is no way it makes sense to keep this code in service more for more than a kernel release or two.
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Eric W. Biederman
Because you are calling unfixably broken code. That should be a decent incentive to do something else won't it?
Can you please tell me _what_ else can be done?
Quoted 7 lines
Quoted 3 lines
IOAPICs do not support what the code is doing here. There is lots of practical evidence including bad experiences and practical tests that support this.
Well, AFAICS, Suresh has tried to debug one failing case recently without any consistent conclusions. I don't know of any other test cases (links, please?).
Rafael, Darrick Wong's issue looks different and hence I was motivated to look and fix if it was a SW issue. For now, I am not able to comprehend what is happening on Darrick Wong's system. Need more help from Darrick as he has the golden failing system.
Meanwhile I talked to our hardware folks about the irq migration in general.
One good news is that future versions of chipsets will have an Interrupt Remapping feature(for more details please refer to
http://download.intel.com/technology/computing/vptech/Intel(r)_VT_for_Direct_IO.pdf)
where in we can reliably migrate the irq to someother cpu in the process context.
And for the existing platforms, chipset folks don't see a reason why the Eric's algorithm(specified below) should fail.
Eric's algorithm for level triggered(edge triggered should be easier than level triggered):
- Mask the irq in process context.
- Poll RIRR until an ack of for the irq was not pending.
- Migrate the irq.
Eric had a problem of stuck remote IRR on E75xx chipset with this algorithm and my next step is to reproduce this issue on this platform and understand the behavior.
thanks,
suresh
Quoted 37 lines · Suresh B
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Eric W. Biederman
Because you are calling unfixably broken code. That should be a decent incentive to do something else won't it?
Can you please tell me _what_ else can be done?
Quoted 7 lines
Quoted 3 lines
IOAPICs do not support what the code is doing here. There is lots of practical evidence including bad experiences and practical tests that support this.
Well, AFAICS, Suresh has tried to debug one failing case recently without any consistent conclusions. I don't know of any other test cases (links, please?).
Rafael, Darrick Wong's issue looks different and hence I was motivated to look and fix if it was a SW issue. For now, I am not able to comprehend what is happening on Darrick Wong's system. Need more help from Darrick as he has the golden failing system.
Meanwhile I talked to our hardware folks about the irq migration in general.
One good news is that future versions of chipsets will have an Interrupt Remapping feature(for more details please refer to
http://download.intel.com/technology/computing/vptech/Intel(r)_VT_for_Direct_IO.pdf)
where in we can reliably migrate the irq to someother cpu in the process context.And for the existing platforms, chipset folks don't see a reason why the Eric's algorithm(specified below) should fail.
Eric's algorithm for level triggered(edge triggered should be easier than level triggered):
- Mask the irq in process context.
- Poll RIRR until an ack of for the irq was not pending.
- Migrate the irq.
Quoted 3 lines
Eric had a problem of stuck remote IRR on E75xx chipset with this algorithm and my next step is to reproduce this issue on this platform and understand the behavior.
OK
In that case, do I understand correctly that we are going to implement the Eric's algorithm above for the CPU hotunplugging on x86 once you've figured out what's the E75xx issue?
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Quoted 42 lines · Rafael J. Wysocki
Quoted 37 lines · Suresh B
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Eric W. Biederman
Because you are calling unfixably broken code. That should be a decent incentive to do something else won't it?
Can you please tell me _what_ else can be done?
Quoted 7 lines
Quoted 3 lines
IOAPICs do not support what the code is doing here. There is lots of practical evidence including bad experiences and practical tests that support this.
Well, AFAICS, Suresh has tried to debug one failing case recently without any consistent conclusions. I don't know of any other test cases (links, please?).
Rafael, Darrick Wong's issue looks different and hence I was motivated to look and fix if it was a SW issue. For now, I am not able to comprehend what is happening on Darrick Wong's system. Need more help from Darrick as he has the golden failing system.
Meanwhile I talked to our hardware folks about the irq migration in general.
One good news is that future versions of chipsets will have an Interrupt Remapping feature(for more details please refer to
http://download.intel.com/technology/computing/vptech/Intel(r)_VT_for_Direct_IO.pdf)
where in we can reliably migrate the irq to someother cpu in the process context.And for the existing platforms, chipset folks don't see a reason why the Eric's algorithm(specified below) should fail.
Eric's algorithm for level triggered(edge triggered should be easier than level triggered):
- Mask the irq in process context.
- Poll RIRR until an ack of for the irq was not pending.
- Migrate the irq.Quoted 3 lines
Eric had a problem of stuck remote IRR on E75xx chipset with this algorithm and my next step is to reproduce this issue on this platform and understand the behavior.
Quoted 5 lines
OK
In that case, do I understand correctly that we are going to implement the Eric's algorithm above for the CPU hotunplugging on x86 once you've figured out what's the E75xx issue?
That is the idea. Thanks.
Quoted 43 lines · Suresh B
Quoted 42 lines · Rafael J. Wysocki
Quoted 40 lines · Suresh B
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Eric W. Biederman
Because you are calling unfixably broken code. That should be a decent incentive to do something else won't it?
Can you please tell me _what_ else can be done?
Quoted 7 lines
Quoted 3 lines
IOAPICs do not support what the code is doing here. There is lots of practical evidence including bad experiences and practical tests that support this.
Well, AFAICS, Suresh has tried to debug one failing case recently without any consistent conclusions. I don't know of any other test cases (links, please?).
Rafael, Darrick Wong's issue looks different and hence I was motivated to look and fix if it was a SW issue. For now, I am not able to comprehend what is happening on Darrick Wong's system. Need more help from Darrick as he has the golden failing system.
Meanwhile I talked to our hardware folks about the irq migration in general.
One good news is that future versions of chipsets will have an Interrupt Remapping feature(for more details please refer to
http://download.intel.com/technology/computing/vptech/Intel(r)_VT_for_Direct_IO.pdf)
where in we can reliably migrate the irq to someother cpu in the process context.And for the existing platforms, chipset folks don't see a reason why the Eric's algorithm(specified below) should fail.
Eric's algorithm for level triggered(edge triggered should be easier than level triggered):
- Mask the irq in process context.
- Poll RIRR until an ack of for the irq was not pending.
- Migrate the irq.Eric had a problem of stuck remote IRR on E75xx chipset with this algorithm and my next step is to reproduce this issue on this platform and understand the behavior.
Quoted 7 lines
Quoted 5 lines
OK
In that case, do I understand correctly that we are going to implement the Eric's algorithm above for the CPU hotunplugging on x86 once you've figured out what's the E75xx issue?
That is the idea. Thanks.
OK, thanks.
Eric, would you agree to follow this plan without making the entire CPU hotplug (on x86) depend on BROKEN?
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Quoted 5 lines · Rafael J. Wysocki
OK, thanks.
Eric, would you agree to follow this plan without making the entire CPU hotplug (on x86) depend on BROKEN?
Sorry for the delay, I missed this email. If we can actually move irq migration into process context on x86. I would be happy to.
Currently I am dubious if this can be done reliably. But I think the benefits of doing irq migration outside of the irq handler are sufficient to give another go at making it work.
However this isn't just Intel's ioapics we have to worry about, but Intel's were the worst so that is a reasonable starting point.
Eric