x86: fix IO APIC resource allocation error message
PATCH 1/1 x86: fix IO APIC resource allocation error message
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] x86: fix IO APIC resource allocation error message
Impact: fix incorrect error message
- IO APIC resource allocation error message contains one too many "be".
- Print the error message iff there are IO APICs in the system.
---
I've seen this error message for some time on my x86-32 laptop...
arch/x86/kernel/io_apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/io_apic.c +2 -2
@@ -4150,9 +4150,9 @@ static int __init ioapic_insert_resourceint i;struct resource *r = ioapic_resources; -if (!r) { +if (!r && nr_ioapics >0 ) {printk (KERN_ERR -"IO APIC resources could be not be allocated.\n" ); +"IO APIC resources couldn't be allocated.\n" );return -1 ; }
Quoted 22 lines · Bartlomiej Zolnierkiewicz
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] x86: fix IO APIC resource allocation error messageImpact: fix incorrect error message
- IO APIC resource allocation error message contains one too many "be".
- Print the error message iff there are IO APICs in the system.
Cc Alan Bartlett <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>---
I've seen this error message for some time on my x86-32 laptop...arch/x86/kernel/io_apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Index:
b/arch/x86/kernel/io_apic.c
===================================================================
arch/x86/kernel/io_apic.c static int __init ioapic_insert_resource · line 4157
Quoted 10 lines
arch/x86/kernel/io_apic.c +2
-2@@ -4150,9 +4150,9 @@ static int __init ioapic_insert_resourceint i;struct resource *r = ioapic_resources; -if (!r) { +if (!r && nr_ioapics >0 ) {printk (KERN_ERR -"IO APIC resources could be not be allocated.\n" ); +"IO APIC resources couldn't be allocated.\n" );return -1 ; }
looks good, but there's one weirdness:
so if nr_ioapics == 0 && !r we'll drop into this codepath:
for (i = 0; i < nr_ioapics; i++) {
insert_resource(&iomem_resource, r);
r++;
}
return 0;we survive the loop by luck, and then return 0 - which we'll survive too but still it's a bit unexpected and hence fragile.
So i think we should rather add a standalone:
if (nr_ioapics > 0)
printk(KERN_ERR
check to the printk only. That wont affect the remaining code flow.
Ingo
Quoted 40 lines · Ingo Molnar
Quoted 22 lines · Bartlomiej Zolnierkiewicz
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] x86: fix IO APIC resource allocation error messageImpact: fix incorrect error message
- IO APIC resource allocation error message contains one too many "be".
- Print the error message iff there are IO APICs in the system.
Cc Alan Bartlett <[email protected]>Signed-off-by Bartlomiej Zolnierkiewicz <[email protected]>---
I've seen this error message for some time on my x86-32 laptop...arch/x86/kernel/io_apic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)Index:
b/arch/x86/kernel/io_apic.c
===================================================================arch/x86/kernel/io_apic.c static int __init ioapic_insert_resource · line 4157
Quoted 10 lines
arch/x86/kernel/io_apic.c +2
-2@@ -4150,9 +4150,9 @@ static int __init ioapic_insert_resourceint i;struct resource *r = ioapic_resources; -if (!r) { +if (!r && nr_ioapics >0 ) {printk (KERN_ERR -"IO APIC resources could be not be allocated.\n" ); +"IO APIC resources couldn't be allocated.\n" );return -1 ; }looks good, but there's one weirdness:
so if
nr_ioapics== 0 && !r we'll drop into this codepath:
Quoted 8 lines
for (i = 0; i < nr_ioapics; i++) { insert_resource(&iomem_resource, r); r++; } return 0;we survive the loop by luck, and then return 0 - which we'll survive
s/by luck/by design/ -- we want to return 0 and thus have the correct return value of the initcall
Quoted 1 line
too but still it's a bit unexpected and hence fragile.
agreed on this one
Quoted 6 lines
So i think we should rather add a standalone:
if (nr_ioapics > 0)printk(KERN_ERR
check to the printk only. That wont affect the remaining code flow.
here is the revised version
From: Bartlomiej Zolnierkiewicz <[email protected]>
Subject: [PATCH] x86: fix IO APIC resource allocation error message (take 2)
Impact: fix incorrect error message
- IO APIC resource allocation error message contains one too many "be".
- Print the error message iff there are IO APICs in the system.
---
I've seen this error message for some time on my x86-32 laptop...
arch/x86/kernel/io_apic.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/kernel/io_apic.c +6 -3
@@ -4151,9 +4151,12 @@ static int __init ioapic_insert_resourcestruct resource *r = ioapic_resources;if (!r) { -printk (KERN_ERR -"IO APIC resources could be not be allocated.\n" ); -return -1 ; +if (nr_ioapics >0 ) { +printk (KERN_ERR +"IO APIC resources couldn't be allocated.\n" ); +return -1 ; + } +return 0 ; }for (i =0 ; i < nr_ioapics; i++) {
Commit-ID: 04c93ce4991fce731dab346d03964504339347db Gitweb: http://git.kernel.org/tip/04c93ce4991fce731dab346d03964504339347db Author: Bartlomiej Zolnierkiewicz <[email protected]> AuthorDate: Fri, 20 Mar 2009 21:02:55 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 20 Mar 2009 21:02:55 +0100
x86: fix IO APIC resource allocation error message
Impact: fix incorrect error message
- IO APIC resource allocation error message contains one too many "be".
- Print the error message iff there are IO APICs in the system.
I've seen this error message for some time on my x86-32 laptop...
LKML-Reference: <[email protected]>
--- arch/x86/kernel/apic/io_apic.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
arch/x86/kernel/apic/io_apic.c +6 -3
@@ -4130,9 +4130,12 @@ static int __init ioapic_insert_resources(void)struct resource *r = ioapic_resources;if (!r) { -printk (KERN_ERR -"IO APIC resources could be not be allocated.\n" ); -return -1 ; +if (nr_ioapics >0 ) { +printk (KERN_ERR +"IO APIC resources couldn't be allocated.\n" ); +return -1 ; + } +return 0 ; }for (i =0 ; i < nr_ioapics; i++) {
[Bartlomiej Zolnierkiewicz - Fri, Mar 20, 2009 at 08:12:41PM +0100]
| From: Bartlomiej Zolnierkiewicz <[email protected]> | Subject: [PATCH] x86: fix IO APIC resource allocation error message | | Impact: fix incorrect error message | | - IO APIC resource allocation error message contains one too many "be". | | - Print the error message iff there are IO APICs in the system. | | Cc: Alan Bartlett <[email protected]> | Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]> | --- | I've seen this error message for some time on my x86-32 laptop... | | arch/x86/kernel/io_apic.c | 4 ++-- | 1 file changed, 2 insertions(+), 2 deletions(-) | | Index: b/arch/x86/kernel/io_apic.c | =================================================================== | --- a/arch/x86/kernel/io_apic.c | +++ b/arch/x86/kernel/io_apic.c | @@ -4150,9 +4150,9 @@ static int __init ioapic_insert_resource | int i; | struct resource *r = ioapic_resources; | | - if (!r) { | + if (!r && nr_ioapics > 0) { | printk(KERN_ERR | - "IO APIC resources could be not be allocated.\n"); | + "IO APIC resources couldn't be allocated.\n"); | return -1; | } | |
Hi Bartlomiej,
until I miss something I guess you could even make it simplier :) Something like
---
static int __init ioapic_insert_resources(void)
{
struct resource *r = ioapic_resources;
int err;
int i;
for (i = 0; i < nr_ioapics; i++) {
err = insert_resource(&iomem_resource, r);
if (err) {
pr_err("IO APIC resources could not be allocated.\n");
return err;
}
r++;
}
return 0;
}---
Now we would have 'err' here and get out only on conflicting resource. Did I miss something?
- Cyrill -
Quoted 59 lines · Cyrill Gorcunov
[Bartlomiej Zolnierkiewicz - Fri, Mar 20, 2009 at 08:12:41PM +0100]
| From: Bartlomiej Zolnierkiewicz <[email protected]> | Subject: [PATCH] x86: fix IO APIC resource allocation error message | | Impact: fix incorrect error message | | - IO APIC resource allocation error message contains one too many "be". | | - Print the error message iff there are IO APICs in the system. | | Cc: Alan Bartlett <[email protected]> | Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]> | --- | I've seen this error message for some time on my x86-32 laptop... | | arch/x86/kernel/io_apic.c | 4 ++-- | 1 file changed, 2 insertions(+), 2 deletions(-) | | Index: b/arch/x86/kernel/io_apic.c | =================================================================== | --- a/arch/x86/kernel/io_apic.c | +++ b/arch/x86/kernel/io_apic.c | @@ -4150,9 +4150,9 @@ static int __init ioapic_insert_resource | int i; | struct resource *r = ioapic_resources; | | - if (!r) { | + if (!r && nr_ioapics > 0) { | printk(KERN_ERR | - "IO APIC resources could be not be allocated.\n"); | + "IO APIC resources couldn't be allocated.\n"); | return -1; | } | |Hi Bartlomiej,
until I miss something I guess you could even make it simplier :) Something like
---
static int__initioapic_insert_resources(void){ struct resource *r = ioapic_resources; int err; int i; for (i = 0; i < nr_ioapics; i++) { err = insert_resource(&iomem_resource, r); if (err) { pr_err("IO APIC resources could not be allocated.\n"); return err; } r++; } return 0; }
Quoted 4 lines
---
Now we would have 'err' here and get out only on conflicting resource. Did I miss something?
nr_ioapics > 0 && r == NULL ?
[Bartlomiej Zolnierkiewicz - Fri, Mar 20, 2009 at 09:02:28PM +0100]
| On Friday 20 March 2009, Cyrill Gorcunov wrote: | > [Bartlomiej Zolnierkiewicz - Fri, Mar 20, 2009 at 08:12:41PM +0100] | > | From: Bartlomiej Zolnierkiewicz <[email protected]> | > | Subject: [PATCH] x86: fix IO APIC resource allocation error message | > | | > | Impact: fix incorrect error message | > | | > | - IO APIC resource allocation error message contains one too many "be". | > | | > | - Print the error message iff there are IO APICs in the system. | > | | > | Cc: Alan Bartlett <[email protected]> | > | Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]> | > | --- | > | I've seen this error message for some time on my x86-32 laptop... | > | | > | arch/x86/kernel/io_apic.c | 4 ++-- | > | 1 file changed, 2 insertions(+), 2 deletions(-) | > | | > | Index: b/arch/x86/kernel/io_apic.c | > | =================================================================== | > | --- a/arch/x86/kernel/io_apic.c | > | +++ b/arch/x86/kernel/io_apic.c | > | @@ -4150,9 +4150,9 @@ static int __init ioapic_insert_resource | > | int i; | > | struct resource *r = ioapic_resources; | > | | > | - if (!r) { | > | + if (!r && nr_ioapics > 0) { | > | printk(KERN_ERR | > | - "IO APIC resources could be not be allocated.\n"); | > | + "IO APIC resources couldn't be allocated.\n"); | > | return -1; | > | } | > | | > | | > | > Hi Bartlomiej, | > | > until I miss something I guess you could even make it simplier :) | > Something like | > | > --- | > static int __init ioapic_insert_resources(void) | > { | > struct resource *r = ioapic_resources; | > int err; | > int i; | > | > for (i = 0; i < nr_ioapics; i++) { | > err = insert_resource(&iomem_resource, r); | > if (err) { | > pr_err("IO APIC resources could not be allocated.\n"); | > return err; | > } | > r++; | > } | > | > return 0; | > } | > --- | > | > Now we would have 'err' here and get out only on conflicting resource. | > Did I miss something? | | nr_ioapics > 0 && r == NULL ? |
This case happens when alloc_bootmem fails but we already panic'ed!
Here is what I mean
Quoted 1 line
From
ioapic_setup_resources()
if (nr_ioapics <= 0) return NULL; mem = alloc_bootmem(n); <- we panic here anyway ... ioapic_resources = res; - Cyrill -
Quoted 71 lines · Cyrill Gorcunov
[Bartlomiej Zolnierkiewicz - Fri, Mar 20, 2009 at 09:02:28PM +0100]
| On Friday 20 March 2009, Cyrill Gorcunov wrote: | > [Bartlomiej Zolnierkiewicz - Fri, Mar 20, 2009 at 08:12:41PM +0100] | > | From: Bartlomiej Zolnierkiewicz <[email protected]> | > | Subject: [PATCH] x86: fix IO APIC resource allocation error message | > | | > | Impact: fix incorrect error message | > | | > | - IO APIC resource allocation error message contains one too many "be". | > | | > | - Print the error message iff there are IO APICs in the system. | > | | > | Cc: Alan Bartlett <[email protected]> | > | Signed-off-by: Bartlomiej Zolnierkiewicz <[email protected]> | > | --- | > | I've seen this error message for some time on my x86-32 laptop... | > | | > | arch/x86/kernel/io_apic.c | 4 ++-- | > | 1 file changed, 2 insertions(+), 2 deletions(-) | > | | > | Index: b/arch/x86/kernel/io_apic.c | > | =================================================================== | > | --- a/arch/x86/kernel/io_apic.c | > | +++ b/arch/x86/kernel/io_apic.c | > | @@ -4150,9 +4150,9 @@ static int __init ioapic_insert_resource | > | int i; | > | struct resource *r = ioapic_resources; | > | | > | - if (!r) { | > | + if (!r && nr_ioapics > 0) { | > | printk(KERN_ERR | > | - "IO APIC resources could be not be allocated.\n"); | > | + "IO APIC resources couldn't be allocated.\n"); | > | return -1; | > | } | > | | > | | > | > Hi Bartlomiej, | > | > until I miss something I guess you could even make it simplier :) | > Something like | > | > --- | > static int __init ioapic_insert_resources(void) | > { | > struct resource *r = ioapic_resources; | > int err; | > int i; | > | > for (i = 0; i < nr_ioapics; i++) { | > err = insert_resource(&iomem_resource, r); | > if (err) { | > pr_err("IO APIC resources could not be allocated.\n"); | > return err; | > } | > r++; | > } | > | > return 0; | > } | > --- | > | > Now we would have 'err' here and get out only on conflicting resource. | > Did I miss something? | | nr_ioapics > 0 && r == NULL ? |This case happens when
alloc_bootmemfails but we already panic'ed!
Quoted 8 lines
Here is what I mean
From
ioapic_setup_resources()if (nr_ioapics <= 0) return NULL; mem = alloc_bootmem(n); <- we panic here anyway
Seems like the following check is superfluous then:
if (mem != NULL) {Quoted 2 lines
... ioapic_resources = res;
In either case I don't think we that failing all resource insertions (for all IO APICs) if only one has failed is a desirable behavior...
Thanks,
Bart
[Bartlomiej Zolnierkiewicz - Fri, Mar 20, 2009 at 09:27:14PM +0100]
...
| > | > Now we would have 'err' here and get out only on conflicting resource.
| > | > Did I miss something?
| > |
| > | nr_ioapics > 0 && r == NULL ?
| > |
| >
| > This case happens when alloc_bootmem fails but we already panic'ed!
| >
| > Here is what I mean
| >
| > From ioapic_setup_resources()
| >
| > if (nr_ioapics <= 0)
| > return NULL;
| >
| > mem = alloc_bootmem(n); <- we panic here anyway
|
| Seems like the following check is superfluous then:
|
| if (mem != NULL) {Yes I believe
| | > ... | > ioapic_resources = res; | | In either case I don't think we that failing all resource insertions | (for all IO APICs) if only one has failed is a desirable behavior...
Indeed, which is even better
| | Thanks, | Bart |
Your patch is already merged, so all is fine -- sorry for noise.
- Cyrill -