mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: linux-kernel@vger.kernel.org
Cc: Ian Campbell <ian.campbell@citrix.com>,
	Jesper Nilsson <jesper.nilsson@axis.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Arjan van de Ven <arjan@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>, Hugh Dickins <hugh@veritas.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH] Fix print out of function which called WARN_ON()
Date: Fri, 15 May 2009 17:17:16 +0100	[thread overview]
Message-ID: <1242404236-17624-1-git-send-email-ian.campbell@citrix.com> (raw)

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


             reply	other threads:[~2009-05-15 16:17 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-15 16:17 Ian Campbell [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1242404236-17624-1-git-send-email-ian.campbell@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=arjan@linux.intel.com \
    --cc=hannes@cmpxchg.org \
    --cc=hugh@veritas.com \
    --cc=jesper.nilsson@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®