public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix print out of function which called WARN_ON()
@ 2009-05-15 16:17 Ian Campbell
  2009-05-15 17:52 ` Linus Torvalds
  0 siblings, 1 reply; 12+ messages in thread
From: Ian Campbell @ 2009-05-15 16:17 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ian Campbell, Jesper Nilsson, Johannes Weiner, Arjan van de Ven,
	Andi Kleen, Hugh Dickins, Andrew Morton, Linus Torvalds

All WARN_ON()'s currently appear to come from warn_slowpath_null e.g.:
 WARNING: at kernel/softirq.c:143 warn_slowpath_null+0x1c/0x20()

This is because since:

  commit 57adc4d2dbf968fdbe516359688094eef4d46581
  Author: Andi Kleen <andi@firstfloor.org>
  Date:   Wed May 6 16:02:53 2009 -0700

      Eliminate thousands of warnings with gcc 3.2 build

the caller of warn_slowpath_fmt really is warn_flowpath_null not the
interesting caller next up the chain. Since __builtin_return_address(X) for X >
0 is not reliable, pass the real caller as an argument to warn_slowpath_fmt.

[If there was a __builtin_this_address() I would use that for the WARN() case
for consistency, I don't know of such a thing though]

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
---
 include/asm-generic/bug.h |    5 +++--
 kernel/panic.c            |   11 ++++++++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h
index 4f4f6e9..39d8dbd 100644
--- a/include/asm-generic/bug.h
+++ b/include/asm-generic/bug.h
@@ -59,12 +59,13 @@ struct bug_entry {
 #ifndef __WARN
 #ifndef __ASSEMBLY__
 extern void warn_slowpath_fmt(const char *file, const int line,
-		const char *fmt, ...) __attribute__((format(printf, 3, 4)));
+		unsigned long caller,
+		const char *fmt, ...) __attribute__((format(printf, 4, 5)));
 extern void warn_slowpath_null(const char *file, const int line);
 #define WANT_WARN_ON_SLOWPATH
 #endif
 #define __WARN()		warn_slowpath_null(__FILE__, __LINE__)
-#define __WARN_printf(arg...)	warn_slowpath_fmt(__FILE__, __LINE__, arg)
+#define __WARN_printf(arg...)	warn_slowpath_fmt(__FILE__, __LINE__, 0UL, arg)
 #else
 #define __WARN_printf(arg...)	do { printk(arg); __WARN(); } while (0)
 #endif
diff --git a/kernel/panic.c b/kernel/panic.c
index 874ecf1..4e1d746 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -340,13 +340,16 @@ void oops_exit(void)
 }
 
 #ifdef WANT_WARN_ON_SLOWPATH
-void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...)
+void warn_slowpath_fmt(const char *file, int line, unsigned long caller,
+		       const char *fmt, ...)
 {
 	va_list args;
 	char function[KSYM_SYMBOL_LEN];
-	unsigned long caller = (unsigned long)__builtin_return_address(0);
 	const char *board;
 
+	if (!caller)
+		caller = (unsigned long)__builtin_return_address(0);
+
 	sprint_symbol(function, caller);
 
 	printk(KERN_WARNING "------------[ cut here ]------------\n");
@@ -372,7 +375,9 @@ EXPORT_SYMBOL(warn_slowpath_fmt);
 void warn_slowpath_null(const char *file, int line)
 {
 	static const char *empty = "";
-	warn_slowpath_fmt(file, line, empty);
+	warn_slowpath_fmt(file, line,
+			  (unsigned long)__builtin_return_address(0),
+			  empty);
 }
 EXPORT_SYMBOL(warn_slowpath_null);
 #endif
-- 
1.5.6.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2009-05-18 14:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-15 16:17 [PATCH] Fix print out of function which called WARN_ON() Ian Campbell
2009-05-15 17:52 ` Linus Torvalds
2009-05-15 19:50   ` Andi Kleen
2009-05-16 20:47     ` Linus Torvalds
2009-05-17 14:43       ` Hugh Dickins
2009-05-17 22:18         ` Linus Torvalds
2009-05-17 22:24           ` David Miller
2009-05-17 22:47             ` Linus Torvalds
2009-05-17 22:45           ` Hugh Dickins
2009-05-17 22:54             ` Linus Torvalds
2009-05-18  9:09       ` Ian Campbell
2009-05-18 14:11         ` Arjan van de Ven

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox