Skip to contentSkip to conversation

warn: consolidate warn_slowpath and warn_on_slowpath

PATCH In review Arjan van de Ven 3 participants 5 messages Nov 28, 2008 Generic include/asm header files

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 warn: consolidate warn_slowpath and warn_on_slowpath

Quoted 1 line

From 7aaa8478fe22e944adf185e465fa07799b87e573 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Fri, 28 Nov 2008 08:30:46 -0800
Subject: [PATCH] warn: consolidate warn_slowpath and warn_on_slowpath

warn_slowpath is a superset of warn_on_slowpath; just have warn_on_slowpath call warn_slowpath with a NULL 3rd argument.

---
 kernel/panic.c |   32 ++++++++++++--------------------
 1 files changed, 12 insertions(+), 20 deletions(-)
kernel/panic.c +12 -20
index d1ac662..2b913aa 100644
@@ -324,23 +324,6 @@ void oops_exit(void)
 }
 
 #ifdef WANT_WARN_ON_SLOWPATH
-void warn_on_slowpath(const char *file, int line)
-{
-	char function[KSYM_SYMBOL_LEN];
-	unsigned long caller = (unsigned long) __builtin_return_address(0);
-	sprint_symbol(function, caller);
-
-	printk(KERN_WARNING "------------[ cut here ]------------\n");
-	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
-		line, function);
-	print_modules();
-	dump_stack();
-	print_oops_end_marker();
-	add_taint(TAINT_WARN);
-}
-EXPORT_SYMBOL(warn_on_slowpath);
-
-
 void warn_slowpath(const char *file, int line, const char *fmt, ...)
 {
 	va_list args;
@@ -351,9 +334,12 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
 	printk(KERN_WARNING "------------[ cut here ]------------\n");
 	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
 		line, function);
-	va_start(args, fmt);
-	vprintk(fmt, args);
-	va_end(args);
+
+	if (fmt) {
+		va_start(args, fmt);
+		vprintk(fmt, args);
+		va_end(args);
+	}
 
 	print_modules();
 	dump_stack();
@@ -361,6 +347,12 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
 	add_taint(TAINT_WARN);
 }
 EXPORT_SYMBOL(warn_slowpath);
+
+void warn_on_slowpath(const char *file, int line)
+{
+	warn_slowpath(file, line, NULL);
+}
+EXPORT_SYMBOL(warn_on_slowpath);
 #endif
 
 #ifdef CONFIG_CC_STACKPROTECTOR
Signature · 8 lines
1.6.0.4



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#1 lore raw

PATCH 2/2 warn: print the DMI board info name in a WARN/WARN_ON

Quoted 1 line

From acdc8771dfaf6e8236b9122364301f65f46d4b59 Mon Sep 17 00:00:00 2001

From: Arjan van de Ven <[email protected]>
Date: Fri, 28 Nov 2008 08:32:44 -0800
Subject: [PATCH] warn: print the DMI board info name in a WARN/WARN_ON

it's very useful for many low level WARN_ON's to find out which motherboard has the broken BIOS etc... this patch adds a printk to the WARN_ON code for this.
On architectures without DMI, gcc should optimize the code out.

---
 kernel/panic.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
kernel/panic.c +5 -0
index 2b913aa..9c1b7e0 100644
@@ -21,6 +21,7 @@
 #include <linux/debug_locks.h>
 #include <linux/random.h>
 #include <linux/kallsyms.h>
+#include <linux/dmi.h>
 
 int panic_on_oops;
 static unsigned long tainted_mask;
@@ -328,12 +329,16 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
 {
 	va_list args;
 	char function[KSYM_SYMBOL_LEN];
+	const char *board;
 	unsigned long caller = (unsigned long)__builtin_return_address(0);
 	sprint_symbol(function, caller);
 
 	printk(KERN_WARNING "------------[ cut here ]------------\n");
 	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
 		line, function);
+	board = dmi_get_system_info(DMI_PRODUCT_NAME);
+	if (board)
+		printk(KERN_WARNING "Hardware name: %s\n", board);
 
 	if (fmt) {
 		va_start(args, fmt);
Signature · 9 lines
1.6.0.4




-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org
#4 lore raw
In reply to Arjan van de Ven
Quoted 58 lines · Arjan van de Ven

From 7aaa8478fe22e944adf185e465fa07799b87e573 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 28 Nov 2008 08:30:46 -0800
Subject: [PATCH] warn: consolidate warn_slowpath and warn_on_slowpath

warn_slowpath is a superset of warn_on_slowpath; just have warn_on_slowpath call warn_slowpath with a NULL 3rd argument.

---
 kernel/panic.c |   32 ++++++++++++--------------------
 1 files changed, 12 insertions(+), 20 deletions(-)
kernel/panic.c +6 -20
index d1ac662..2b913aa 100644
@@ -324,23 +324,6 @@ void oops_exit(void)
 }
 
 #ifdef WANT_WARN_ON_SLOWPATH
-void warn_on_slowpath(const char *file, int line)
-{
-	char function[KSYM_SYMBOL_LEN];
-	unsigned long caller = (unsigned long) __builtin_return_address(0);
-	sprint_symbol(function, caller);
-
-	printk(KERN_WARNING "------------[ cut here ]------------\n");
-	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
-		line, function);
-	print_modules();
-	dump_stack();
-	print_oops_end_marker();
-	add_taint(TAINT_WARN);
-}
-EXPORT_SYMBOL(warn_on_slowpath);
-
-
 void warn_slowpath(const char *file, int line, const char *fmt, ...)
 {
 	va_list args;
@@ -351,9 +334,12 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
 	printk(KERN_WARNING "------------[ cut here ]------------\n");
 	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
 		line, function);
-	va_start(args, fmt);
-	vprintk(fmt, args);
-	va_end(args);
+
+	if (fmt) {
+		va_start(args, fmt);
+		vprintk(fmt, args);
+		va_end(args);
+	}
 
 	print_modules();
 	dump_stack();

kernel/panic.c void warn_slowpath(const char *file, int line, const char *fmt, ...) · line 356

Quoted 10 lines
kernel/panic.c +6 -0
@@ -361,6 +347,12 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
 	add_taint(TAINT_WARN);
 }
 EXPORT_SYMBOL(warn_slowpath);
+
+void warn_on_slowpath(const char *file, int line)
+{
+	warn_slowpath(file, line, NULL);
+}
+EXPORT_SYMBOL(warn_on_slowpath);
 #endif

well spotted! Applied to tip/core/debug, thanks Arjan!

I've also done the change below that goes one step further, and turns eliminates warn_on_slowpath() altogether and calls warn_slowpath(file, line, NULL) straight from include/asm-generic/bug.h's __WARN() definition.

Ingo

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

Quoted 1 line

From ec5679e513305f1411753e5f5489935bd638af23 Mon Sep 17 00:00:00 2001

From: Ingo Molnar <[email protected]>
Date: Fri, 28 Nov 2008 17:56:14 +0100
Subject: [PATCH] debug warnings: eliminate warn_on_slowpath()

Impact: cleanup, eliminate code

now that warn_on_slowpath() uses warn_slowpath(...,NULL), we can eliminate warn_on_slowpath() altogether and use warn_slowpath().

---
 include/asm-generic/bug.h |    7 +++----
 kernel/panic.c            |    6 ------
 2 files changed, 3 insertions(+), 10 deletions(-)
include/asm-generic/bug.h +3 -4
index 12c07c1..b8ba694 100644
@@ -33,15 +33,14 @@ struct bug_entry {
 
 #ifndef __WARN
 #ifndef __ASSEMBLY__
-extern void warn_on_slowpath(const char *file, const int line);
 extern void warn_slowpath(const char *file, const int line,
 		const char *fmt, ...) __attribute__((format(printf, 3, 4)));
 #define WANT_WARN_ON_SLOWPATH
 #endif
-#define __WARN() warn_on_slowpath(__FILE__, __LINE__)
-#define __WARN_printf(arg...) warn_slowpath(__FILE__, __LINE__, arg)
+#define __WARN()		warn_slowpath(__FILE__, __LINE__, NULL)
+#define __WARN_printf(arg...)	warn_slowpath(__FILE__, __LINE__, arg)
 #else
-#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
+#define __WARN_printf(arg...)	do { printk(arg); __WARN(); } while (0)
 #endif
 
 #ifndef WARN_ON
kernel/panic.c +0 -6
index 73d3651..50349a4 100644
@@ -349,12 +349,6 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
 	add_taint(TAINT_WARN);
 }
 EXPORT_SYMBOL(warn_slowpath);
-
-void warn_on_slowpath(const char *file, int line)
-{
-	warn_slowpath(file, line, NULL);
-}
-EXPORT_SYMBOL(warn_on_slowpath);
 #endif
 
 #ifdef CONFIG_CC_STACKPROTECTOR
#2 lore raw

Re: [PATCH 2/2] warn: print the DMI board info name in a WARN/WARN_ON

In reply to Arjan van de Ven
Quoted 34 lines · Arjan van de Ven

From acdc8771dfaf6e8236b9122364301f65f46d4b59 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 28 Nov 2008 08:32:44 -0800
Subject: [PATCH] warn: print the DMI board info name in a WARN/WARN_ON

it's very useful for many low level WARN_ON's to find out which motherboard has the broken BIOS etc... this patch adds a printk to the WARN_ON code for this.
On architectures without DMI, gcc should optimize the code out.

---
 kernel/panic.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
kernel/panic.c +2 -0
index 2b913aa..9c1b7e0 100644
@@ -21,6 +21,7 @@
 #include <linux/debug_locks.h>
 #include <linux/random.h>
 #include <linux/kallsyms.h>
+#include <linux/dmi.h>
 
 int panic_on_oops;
 static unsigned long tainted_mask;
@@ -328,12 +329,16 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
 {
 	va_list args;
 	char function[KSYM_SYMBOL_LEN];
+	const char *board;
 	unsigned long caller = (unsigned long)__builtin_return_address(0);
 	sprint_symbol(function, caller);

kernel/panic.c void warn_slowpath(const char *file, int line, const char *fmt, ...) · line 344

Quoted 10 lines
kernel/panic.c +3 -0
 
 	printk(KERN_WARNING "------------[ cut here ]------------\n");
 	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
 		line, function);
+	board = dmi_get_system_info(DMI_PRODUCT_NAME);
+	if (board)
+		printk(KERN_WARNING "Hardware name: %s\n", board);
 
 	if (fmt) {
 		va_start(args, fmt);

nice idea - applied to tip/core/debug.

On architectures (or systems) where there's no DMI_PRODUCT_NAME string available, we'll print nothing. It's also a simple lockless call so can be called from any context.

Andrew, any objections?

Ingo

#3 lore raw

Re: [PATCH 2/2] warn: print the DMI board info name in a WARN/WARN_ON

Quoted 50 lines · On Fri, 28 Nov 2008 18:00:29 +0100 Ingo Molnar <[email protected]> wrote:
Quoted 34 lines · Arjan van de Ven

From acdc8771dfaf6e8236b9122364301f65f46d4b59 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <[email protected]>
Date: Fri, 28 Nov 2008 08:32:44 -0800
Subject: [PATCH] warn: print the DMI board info name in a WARN/WARN_ON

it's very useful for many low level WARN_ON's to find out which motherboard has the broken BIOS etc... this patch adds a printk to the WARN_ON code for this.
On architectures without DMI, gcc should optimize the code out.

---
 kernel/panic.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
kernel/panic.c +2 -0
index 2b913aa..9c1b7e0 100644
@@ -21,6 +21,7 @@
 #include <linux/debug_locks.h>
 #include <linux/random.h>
 #include <linux/kallsyms.h>
+#include <linux/dmi.h>
 
 int panic_on_oops;
 static unsigned long tainted_mask;
@@ -328,12 +329,16 @@ void warn_slowpath(const char *file, int line, const char *fmt, ...)
 {
 	va_list args;
 	char function[KSYM_SYMBOL_LEN];
+	const char *board;
 	unsigned long caller = (unsigned long)__builtin_return_address(0);
 	sprint_symbol(function, caller);

kernel/panic.c void warn_slowpath(const char *file, int line, const char *fmt, ...) · line 344

Quoted 10 lines
kernel/panic.c +3 -0
 
 	printk(KERN_WARNING "------------[ cut here ]------------\n");
 	printk(KERN_WARNING "WARNING: at %s:%d %s()\n", file,
 		line, function);
+	board = dmi_get_system_info(DMI_PRODUCT_NAME);
+	if (board)
+		printk(KERN_WARNING "Hardware name: %s\n", board);
 
 	if (fmt) {
 		va_start(args, fmt);

nice idea - applied to tip/core/debug.

Quoted 6 lines

On architectures (or systems) where there's no DMI_PRODUCT_NAME string available, we'll print nothing. It's also a simple lockless call so can be called from any context.

Andrew, any objections?

Nope. This is the first time we've included dmi.h from such a core place, but afaict all architectures should have encountered that file by now.