Skip to contentSkip to conversation

x86, add hypervisor name to dump_stack()

PATCH In review Prarit Bhargava 2 participants 4 messages Oct 10, 2012 – Oct 24, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86, add hypervisor name to dump_stack()

Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and bare-metal boots can get difficult very quickly. While there are ways to decipher the output and determine if the output is from a virtual guest, the in-kernel hypervisors now have a single registration point and set x86_hyper. We can use this to output a single extra line on virtual machines that indicates the hypervisor type.

Cc Avi Kivity <[email protected]>
Cc Gleb Natapov <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Marcelo Tostatti <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 arch/x86/kernel/dumpstack.c |    3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/dumpstack.c +3 -0
index ae42418b..75a635e 100644
@@ -17,6 +17,7 @@
 #include <linux/sysfs.h>
 
 #include <asm/stacktrace.h>
+#include <asm/hypervisor.h>
 
 
 int panic_on_unrecovered_nmi;
@@ -193,6 +194,8 @@ void dump_stack(void)
 		init_utsname()->release,
 		(int)strcspn(init_utsname()->version, " "),
 		init_utsname()->version);
+	if (x86_hyper && x86_hyper->name)
+		printk("Hypervisor: %s\n",  x86_hyper->name);
 	show_trace(NULL, NULL, &stack, bp);
 }
 EXPORT_SYMBOL(dump_stack);
Signature · 1 line
1.7.9.3
#1 lore raw
Quoted 32 lines · Prarit Bhargava

Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and bare-metal boots can get difficult very quickly. While there are ways to decipher the output and determine if the output is from a virtual guest, the in-kernel hypervisors now have a single registration point and set x86_hyper. We can use this to output a single extra line on virtual machines that indicates the hypervisor type.

Cc Avi Kivity <[email protected]>
Cc Gleb Natapov <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Marcelo Tostatti <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 arch/x86/kernel/dumpstack.c |    3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/dumpstack.c +1 -0
index ae42418b..75a635e 100644
@@ -17,6 +17,7 @@
 #include <linux/sysfs.h>
 
 #include <asm/stacktrace.h>
+#include <asm/hypervisor.h>
 
 
 int panic_on_unrecovered_nmi;

arch/x86/kernel/dumpstack.c void dump_stack(void) · line 199

Quoted 6 lines
arch/x86/kernel/dumpstack.c +2 -0
@@ -193,6 +194,8 @@ void dump_stack(void)
 		init_utsname()->release,
 		(int)strcspn(init_utsname()->version, " "),
 		init_utsname()->version);
+	if (x86_hyper && x86_hyper->name)
+		printk("Hypervisor: %s\n",  x86_hyper->name);
 	show_trace(NULL, NULL, &stack, bp);

Looks useful, but please don't waste a full new line on it but embedd it in the already existing status line that prints details like release and version.

Thanks,

Ingo

#2 lore raw
Quoted 33 lines · Ingo Molnar
Quoted 30 lines · Prarit Bhargava

Debugging crash, panics, stack trace WARN_ONs, etc., from both virtual and bare-metal boots can get difficult very quickly. While there are ways to decipher the output and determine if the output is from a virtual guest, the in-kernel hypervisors now have a single registration point and set x86_hyper. We can use this to output a single extra line on virtual machines that indicates the hypervisor type.

Cc Avi Kivity <[email protected]>
Cc Gleb Natapov <[email protected]>
Cc Alex Williamson <[email protected]>
Cc Marcelo Tostatti <[email protected]>
Cc Ingo Molnar <[email protected]>
---
 arch/x86/kernel/dumpstack.c |    3 +++
 1 file changed, 3 insertions(+)
arch/x86/kernel/dumpstack.c +1 -0
index ae42418b..75a635e 100644
@@ -17,6 +17,7 @@
 #include <linux/sysfs.h>
 
 #include <asm/stacktrace.h>
+#include <asm/hypervisor.h>
 
 
Quoted 12 lines

arch/x86/kernel/dumpstack.c void dump_stack(void) · line 199

Quoted 8 lines
arch/x86/kernel/dumpstack.c +2 -0
 int panic_on_unrecovered_nmi;
@@ -193,6 +194,8 @@ void dump_stack(void)
 		init_utsname()->release,
 		(int)strcspn(init_utsname()->version, " "),
 		init_utsname()->version);
+	if (x86_hyper && x86_hyper->name)
+		printk("Hypervisor: %s\n",  x86_hyper->name);
 	show_trace(NULL, NULL, &stack, bp);

Looks useful, but please don't waste a full new line on it but embedd it in the already existing status line that prints details like release and version.

Ingo, I thought about doing that but since x86_hyper can be NULL (... maybe it should initialized to "Bare-metal" or "No Hypervisor"?) I didn't want to break up the printk line. I'll look into doing it a different way...

P.

Quoted 4 lines

Thanks,

Ingo

#3 lore raw
Quoted 8 lines · Prarit Bhargava
Quoted 3 lines

Looks useful, but please don't waste a full new line on it but embedd it in the already existing status line that prints details like release and version.

Ingo, I thought about doing that but since x86_hyper can be NULL (... maybe it should initialized to "Bare-metal" or "No Hypervisor"?) I didn't want to break up the printk line. I'll look into doing it a different way...

You don't have to break it up - just initialize a name string to:

	const char *machine_name = "x86";
	const char *kernel_type = "native";

	if (x86_hyperv) {
		machine_name = x86_hyperv->name;
		kernel_type = "guest";
	}

And print it as:

"[%s %s kernel]", machine_name, kernel_type

That way we'll get nice:

... [x86 native kernel]
... [KVM guest kernel]
... [Xen guest kernel]
etc.

Printouts. Please use the naming I outlined above, that's how we refer to these kernels within arch/x86/.

(The above code is pseudocode, untested.)

Thanks,

Ingo