Skip to contentSkip to conversation

: xen: fix too early kmalloc call

PATCH In review Mike Travis 4 participants 8 messages Jan 11, 2009 – Jan 12, 2009 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : xen: fix too early kmalloc call

Subject: xen: fix too early kmalloc call

From: Christophe Saout <[email protected]>

Impact: fixes bootup of xen.

Christophe reported the following problem:

Quoted 2 lines

(basically it seems that SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc before)

Replace call to kmalloc with alloc_bootmem.

Also from Christophe:

Quoted 5 lines

(me)

Quoted 1 line

Or I could copy the text and submit it as a new patch?

Yes, I would prefer that. Also, my commit message was not really following Kernel standards and it's only a very simple change.

---
 drivers/xen/events.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/xen/events.c +3 -2
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/bootmem.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq.h>
@@ -831,8 +832,8 @@ void __init xen_init_IRQ(void)
 	int i;
 	size_t size = nr_cpu_ids * sizeof(struct cpu_evtchn_s);
 
-	cpu_evtchn_mask_p = kmalloc(size, GFP_KERNEL);
-	BUG_ON(cpu_evtchn_mask == NULL);
+	cpu_evtchn_mask_p = alloc_bootmem(size);
+	BUG_ON(cpu_evtchn_mask_p == NULL);
 
 	init_evtchn_cpu_bindings();
 
#1 lore raw
Quoted 13 lines · Mike Travis

Subject: xen: fix too early kmalloc call

From: Christophe Saout <[email protected]>

Impact: fixes bootup of xen.

Christophe reported the following problem:

Quoted 2 lines

(basically it seems that SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc before)

Replace call to kmalloc with alloc_bootmem.

Quoted 8 lines

Also from Christophe:

Quoted 5 lines

(me)

Quoted 1 line

Or I could copy the text and submit it as a new patch?

Yes, I would prefer that. Also, my commit message was not really following Kernel standards and it's only a very simple change.

i've applied the fix to tip/cpus4096, in the form below.

Please submit clean log messages. Your commit description was confused - the patch is From: Christophe, but the message talks about Christophe in the third person. Also, it included conversational bits that have no value for the Git history.

Ingo

-------------------->

Quoted 1 line

From 28e08861b9afab4168b758fb7b95aa7a4da0f668 Mon Sep 17 00:00:00 2001

From: Christophe Saout <[email protected]>
Date: Sun, 11 Jan 2009 11:46:23 -0800
Subject: [PATCH] xen: fix too early kmalloc call

Impact: fix bootup crash on xen guests

SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc.

Replace call to kmalloc() with alloc_bootmem().

---
 drivers/xen/events.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/xen/events.c +3 -2
index ed7527b..3141e14 100644
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/bootmem.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq.h>
@@ -831,8 +832,8 @@ void __init xen_init_IRQ(void)
 	int i;
 	size_t size = nr_cpu_ids * sizeof(struct cpu_evtchn_s);
 
-	cpu_evtchn_mask_p = kmalloc(size, GFP_KERNEL);
-	BUG_ON(cpu_evtchn_mask == NULL);
+	cpu_evtchn_mask_p = alloc_bootmem(size);
+	BUG_ON(cpu_evtchn_mask_p == NULL);
 
 	init_evtchn_cpu_bindings();
 
#2 lore raw
Quoted 66 lines · Ingo Molnar
Quoted 13 lines · Mike Travis

Subject: xen: fix too early kmalloc call

From: Christophe Saout <[email protected]>

Impact: fixes bootup of xen.

Christophe reported the following problem:

Quoted 2 lines

(basically it seems that SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc before)

Replace call to kmalloc with alloc_bootmem.

Quoted 8 lines

Also from Christophe:

Quoted 5 lines

(me)

Quoted 1 line

Or I could copy the text and submit it as a new patch?

Yes, I would prefer that. Also, my commit message was not really following Kernel standards and it's only a very simple change.

i've applied the fix to tip/cpus4096, in the form below.

Please submit clean log messages. Your commit description was confused - the patch is From: Christophe, but the message talks about Christophe in the third person. Also, it included conversational bits that have no value for the Git history.

Ingo

-------------------->

Quoted 1 line
Quoted 1 line

From 28e08861b9afab4168b758fb7b95aa7a4da0f668 Mon Sep 17 00:00:00 2001

From: Christophe Saout <[email protected]>
Date: Sun, 11 Jan 2009 11:46:23 -0800
Subject: [PATCH] xen: fix too early kmalloc call

Impact: fix bootup crash on xen guests

SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc.

Replace call to kmalloc() with alloc_bootmem().

---
 drivers/xen/events.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/xen/events.c +1 -0
index ed7527b..3141e14 100644
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/bootmem.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq.h>

drivers/xen/events.c void __init xen_init_IRQ(void) · line 836

Quoted 7 lines
drivers/xen/events.c +2 -2
@@ -831,8 +832,8 @@ void __init xen_init_IRQ(void)
 	int i;
 	size_t size = nr_cpu_ids * sizeof(struct cpu_evtchn_s);
 
-	cpu_evtchn_mask_p = kmalloc(size, GFP_KERNEL);
-	BUG_ON(cpu_evtchn_mask == NULL);
+	cpu_evtchn_mask_p = alloc_bootmem(size);
+	BUG_ON(cpu_evtchn_mask_p == NULL);

Impossible condition :-) alloc_bootmem() crashes before you could catch it here.

Hannes

#3 lore raw
Quoted 70 lines · Johannes Weiner
Quoted 69 lines · Ingo Molnar
Quoted 13 lines · Mike Travis

Subject: xen: fix too early kmalloc call

From: Christophe Saout <[email protected]>

Impact: fixes bootup of xen.

Christophe reported the following problem:

Quoted 2 lines

(basically it seems that SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc before)

Replace call to kmalloc with alloc_bootmem.

Quoted 8 lines

Also from Christophe:

Quoted 5 lines

(me)

Quoted 1 line

Or I could copy the text and submit it as a new patch?

Yes, I would prefer that. Also, my commit message was not really following Kernel standards and it's only a very simple change.

i've applied the fix to tip/cpus4096, in the form below.

Please submit clean log messages. Your commit description was confused - the patch is From: Christophe, but the message talks about Christophe in the third person. Also, it included conversational bits that have no value for the Git history.

Ingo

-------------------->

Quoted 1 line
Quoted 1 line

From 28e08861b9afab4168b758fb7b95aa7a4da0f668 Mon Sep 17 00:00:00 2001

From: Christophe Saout <[email protected]>
Date: Sun, 11 Jan 2009 11:46:23 -0800
Subject: [PATCH] xen: fix too early kmalloc call

Impact: fix bootup crash on xen guests

SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc.

Replace call to kmalloc() with alloc_bootmem().

---
 drivers/xen/events.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/xen/events.c +1 -0
index ed7527b..3141e14 100644
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/bootmem.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq.h>
@@ -831,8 +832,8 @@ void __init xen_init_IRQ(void)
 	int i;
 	size_t size = nr_cpu_ids * sizeof(struct cpu_evtchn_s);
 
Quoted 7 lines

drivers/xen/events.c void __init xen_init_IRQ(void) · line 836

Quoted 4 lines
drivers/xen/events.c +2 -2
-	cpu_evtchn_mask_p = kmalloc(size, GFP_KERNEL);
-	BUG_ON(cpu_evtchn_mask == NULL);
+	cpu_evtchn_mask_p = alloc_bootmem(size);
+	BUG_ON(cpu_evtchn_mask_p == NULL);

Impossible condition :-) alloc_bootmem() crashes before you could catch it here.

yeah ... but that's just a current behavior of bootmem. It's always prudent to check for allocation errors.

Ingo

#4 lore raw
In reply to Johannes Weiner
Quoted 73 lines · Johannes Weiner
Quoted 61 lines · Ingo Molnar
Quoted 10 lines · Mike Travis

Subject: xen: fix too early kmalloc call

From: Christophe Saout <[email protected]>

Impact: fixes bootup of xen.

Christophe reported the following problem:

Quoted 2 lines

(basically it seems that SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc before)

Quoted 8 lines

Replace call to kmalloc with alloc_bootmem.

Also from Christophe:

Quoted 4 lines

(me)

Quoted 1 line

Or I could copy the text and submit it as a new patch?

Yes, I would prefer that. Also, my commit message was not really following Kernel standards and it's only a very simple change.

i've applied the fix to tip/cpus4096, in the form below.

Please submit clean log messages. Your commit description was confused - the patch is From: Christophe, but the message talks about Christophe in the third person. Also, it included conversational bits that have no value for the Git history.

Ingo

-------------------->

Quoted 1 line
Quoted 1 line

From 28e08861b9afab4168b758fb7b95aa7a4da0f668 Mon Sep 17 00:00:00 2001

From: Christophe Saout <[email protected]>
Date: Sun, 11 Jan 2009 11:46:23 -0800
Subject: [PATCH] xen: fix too early kmalloc call

Impact: fix bootup crash on xen guests

SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc.

Replace call to kmalloc() with alloc_bootmem().

---
 drivers/xen/events.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/xen/events.c +1 -0
index ed7527b..3141e14 100644
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/bootmem.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq.h>

drivers/xen/events.c void __init xen_init_IRQ(void) · line 836

Quoted 7 lines
drivers/xen/events.c +2 -2
@@ -831,8 +832,8 @@ void __init xen_init_IRQ(void)
 	int i;
 	size_t size = nr_cpu_ids * sizeof(struct cpu_evtchn_s);
 
-	cpu_evtchn_mask_p = kmalloc(size, GFP_KERNEL);
-	BUG_ON(cpu_evtchn_mask == NULL);
+	cpu_evtchn_mask_p = alloc_bootmem(size);
+	BUG_ON(cpu_evtchn_mask_p == NULL);

Impossible condition :-) alloc_bootmem() crashes before you could catch it here.

Quoted 1 line

Hannes

Yes, that's picked up in a subsequent patch (I didn't catch it the first time I reviewed it as well.) There appears to be a queue of patches for Xen coming, so this last "memory reduction patch" will follow (or be included with) those.

Thanks,
Mike

#5 lore raw

Hi Mike,

Quoted 4 lines

Yes, that's picked up in a subsequent patch (I didn't catch it the first time I reviewed it as well.) There appears to be a queue of patches for Xen coming, so this last "memory reduction patch" will follow (or be included with) those.

It appears Jeremy is on vacation and I also don't know which of the patches are meant for upstream (there seem still to be some bugs that might need fixing), and it doesn't really matter if the XEN patches are updated to your patch or the other way around. The patches in the XEN mercurial tree already do not apply the way they were before Jeremy went on vacation, so in my opinion you can as well just go ahead.

Cheers,
Christophe

#6 lore raw
In reply to Ingo Molnar
Quoted 21 lines · Ingo Molnar
Quoted 10 lines · Mike Travis

Subject: xen: fix too early kmalloc call

From: Christophe Saout <[email protected]>

Impact: fixes bootup of xen.

Christophe reported the following problem:

Quoted 2 lines

(basically it seems that SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc before)

Quoted 8 lines

Replace call to kmalloc with alloc_bootmem.

Also from Christophe:

Quoted 4 lines

(me)

Quoted 1 line

Or I could copy the text and submit it as a new patch?

Yes, I would prefer that. Also, my commit message was not really following Kernel standards and it's only a very simple change.

Quoted 8 lines

i've applied the fix to tip/cpus4096, in the form below.

Please submit clean log messages. Your commit description was confused - the patch is From: Christophe, but the message talks about Christophe in the third person. Also, it included conversational bits that have no value for the Git history.

Ingo

Ahh, ok, will do. I wasn't sure how many "liberties" we can take in submitting/changing something from someone else.

THanks,
Mike

Quoted 43 lines

-------------------->

Quoted 1 line

From 28e08861b9afab4168b758fb7b95aa7a4da0f668 Mon Sep 17 00:00:00 2001

From: Christophe Saout <[email protected]>
Date: Sun, 11 Jan 2009 11:46:23 -0800
Subject: [PATCH] xen: fix too early kmalloc call

Impact: fix bootup crash on xen guests

SLAB is not yet up, with earlyprintk it is giving me an Oops in __kmalloc.

Replace call to kmalloc() with alloc_bootmem().

---
 drivers/xen/events.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/xen/events.c +3 -2
index ed7527b..3141e14 100644
@@ -26,6 +26,7 @@
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/string.h>
+#include <linux/bootmem.h>
 
 #include <asm/ptrace.h>
 #include <asm/irq.h>
@@ -831,8 +832,8 @@ void __init xen_init_IRQ(void)
 	int i;
 	size_t size = nr_cpu_ids * sizeof(struct cpu_evtchn_s);
 
-	cpu_evtchn_mask_p = kmalloc(size, GFP_KERNEL);
-	BUG_ON(cpu_evtchn_mask == NULL);
+	cpu_evtchn_mask_p = alloc_bootmem(size);
+	BUG_ON(cpu_evtchn_mask_p == NULL);
 
 	init_evtchn_cpu_bindings();
 
#7 lore raw
Quoted 11 lines · Mike Travis
Quoted 8 lines

i've applied the fix to tip/cpus4096, in the form below.

Please submit clean log messages. Your commit description was confused
- the patch is From: Christophe, but the message talks about Christophe in the third person. Also, it included conversational bits that have no value for the Git history.

Ingo

Ahh, ok, will do. I wasn't sure how many "liberties" we can take in submitting/changing something from someone else.

You are free to perfect anyone's commit log in essence - i do it for 90% of all commits that go via -tip. I fix tyops and grammar mistaiks in every second commit, and have to fix basic formatting, structure, explanations and reported-by credits and tags in most of them. Submitting patches with a well-structured commit log gives you extra credit :-)

[ Obviously you are not free to make a commit log worse and then make it
appear as if the guy who submitted it did it ;-) ]

Ingo