lkml.org 
[lkml]   [2009]   [May]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] Fix print out of function which called WARN_ON()
Date
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


\
 
 \ /
  Last update: 2009-05-15 18:19    [W:0.073 / U:1.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site