2008-01-17 00:51:13

by Olof Johansson

[permalink] [raw]
Subject: [patch 0/3] Remaining bits of WARN_ON series

Arjan posted a series of WARN_ON enhancements, parts of those were from
two previous patches from me.

Ingo picked up 3 of the 5 patches. Here are the rest-reposted again,
plus another patch bringing the generic report_bug() code up to the same
format as the x86-specific one.

These have to be applied on top of x86.git, since they depend on changes
in there. Ingo didn't want to take them directly since they touch code
in other architectures.

-Olof


2008-01-17 00:58:51

by Olof Johansson

[permalink] [raw]
Subject: [patch 1/3] bug.h: Remove HAVE_ARCH_BUG and HAVE_ARCH_WARN

No need to have the HAVE_ARCH_BUG.* / HAVE_ARCH_WARN.* defines, when
the generic implementation can just use #ifndef on the macros themselves.

Signed-off-by: Olof Johansson <[email protected]>
Cc: <[email protected]>

---

include/asm-alpha/bug.h | 1 -
include/asm-arm/bug.h | 1 -
include/asm-avr32/bug.h | 3 ---
include/asm-frv/bug.h | 1 -
include/asm-generic/bug.h | 10 +++++-----
include/asm-ia64/bug.h | 1 -
include/asm-m68k/bug.h | 1 -
include/asm-mips/bug.h | 4 ----
include/asm-parisc/bug.h | 2 --
include/asm-powerpc/bug.h | 3 ---
include/asm-s390/bug.h | 2 --
include/asm-sparc/bug.h | 1 -
include/asm-sparc64/bug.h | 1 -
include/asm-v850/bug.h | 1 -
include/asm-x86/bug.h | 1 -
15 files changed, 5 insertions(+), 28 deletions(-)

Index: linux-2.6.24-rc6/include/asm-alpha/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-alpha/bug.h
+++ linux-2.6.24-rc6/include/asm-alpha/bug.h
@@ -10,7 +10,6 @@
__asm__ __volatile__("call_pal %0 # bugchk\n\t"".long %1\n\t.8byte %2" \
: : "i" (PAL_bugchk), "i"(__LINE__), "i"(__FILE__))

-#define HAVE_ARCH_BUG
#endif

#include <asm-generic/bug.h>
Index: linux-2.6.24-rc6/include/asm-arm/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-arm/bug.h
+++ linux-2.6.24-rc6/include/asm-arm/bug.h
@@ -16,7 +16,6 @@ extern void __bug(const char *file, int

#endif

-#define HAVE_ARCH_BUG
#endif

#include <asm-generic/bug.h>
Index: linux-2.6.24-rc6/include/asm-avr32/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-avr32/bug.h
+++ linux-2.6.24-rc6/include/asm-avr32/bug.h
@@ -63,9 +63,6 @@
unlikely(__ret_warn_on); \
})

-#define HAVE_ARCH_BUG
-#define HAVE_ARCH_WARN_ON
-
#endif /* CONFIG_BUG */

#include <asm-generic/bug.h>
Index: linux-2.6.24-rc6/include/asm-frv/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-frv/bug.h
+++ linux-2.6.24-rc6/include/asm-frv/bug.h
@@ -32,7 +32,6 @@ do { \
asm volatile("nop"); \
} while(0)

-#define HAVE_ARCH_BUG
#define BUG() \
do { \
_debug_bug_printk(); \
Index: linux-2.6.24-rc6/include/asm-generic/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-generic/bug.h
+++ linux-2.6.24-rc6/include/asm-generic/bug.h
@@ -20,14 +20,14 @@ struct bug_entry {
#define BUGFLAG_WARNING (1<<0)
#endif /* CONFIG_GENERIC_BUG */

-#ifndef HAVE_ARCH_BUG
+#ifndef BUG
#define BUG() do { \
printk("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __FUNCTION__); \
panic("BUG!"); \
} while (0)
#endif

-#ifndef HAVE_ARCH_BUG_ON
+#ifndef BUG_ON
#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while(0)
#endif

@@ -49,15 +49,15 @@ extern void warn_on_slowpath(const char
#endif

#else /* !CONFIG_BUG */
-#ifndef HAVE_ARCH_BUG
+#ifndef BUG
#define BUG()
#endif

-#ifndef HAVE_ARCH_BUG_ON
+#ifndef BUG_ON
#define BUG_ON(condition) do { if (condition) ; } while(0)
#endif

-#ifndef HAVE_ARCH_WARN_ON
+#ifndef WARN_ON
#define WARN_ON(condition) ({ \
int __ret_warn_on = !!(condition); \
unlikely(__ret_warn_on); \
Index: linux-2.6.24-rc6/include/asm-ia64/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-ia64/bug.h
+++ linux-2.6.24-rc6/include/asm-ia64/bug.h
@@ -6,7 +6,6 @@
#define BUG() do { printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); ia64_abort(); } while (0)

/* should this BUG be made generic? */
-#define HAVE_ARCH_BUG
#endif

#include <asm-generic/bug.h>
Index: linux-2.6.24-rc6/include/asm-m68k/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-m68k/bug.h
+++ linux-2.6.24-rc6/include/asm-m68k/bug.h
@@ -21,7 +21,6 @@
} while (0)
#endif

-#define HAVE_ARCH_BUG
#endif

#include <asm-generic/bug.h>
Index: linux-2.6.24-rc6/include/asm-mips/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-mips/bug.h
+++ linux-2.6.24-rc6/include/asm-mips/bug.h
@@ -12,8 +12,6 @@ do { \
__asm__ __volatile__("break %0" : : "i" (BRK_BUG)); \
} while (0)

-#define HAVE_ARCH_BUG
-
#if (_MIPS_ISA > _MIPS_ISA_MIPS1)

#define BUG_ON(condition) \
@@ -22,8 +20,6 @@ do { \
: : "r" (condition), "i" (BRK_BUG)); \
} while (0)

-#define HAVE_ARCH_BUG_ON
-
#endif /* _MIPS_ISA > _MIPS_ISA_MIPS1 */

#endif
Index: linux-2.6.24-rc6/include/asm-parisc/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-parisc/bug.h
+++ linux-2.6.24-rc6/include/asm-parisc/bug.h
@@ -7,8 +7,6 @@
*/

#ifdef CONFIG_BUG
-#define HAVE_ARCH_BUG
-#define HAVE_ARCH_WARN_ON

/* the break instruction is used as BUG() marker. */
#define PARISC_BUG_BREAK_ASM "break 0x1f, 0x1fff"
Index: linux-2.6.24-rc6/include/asm-powerpc/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-powerpc/bug.h
+++ linux-2.6.24-rc6/include/asm-powerpc/bug.h
@@ -109,9 +109,6 @@
unlikely(__ret_warn_on); \
})

-#define HAVE_ARCH_BUG
-#define HAVE_ARCH_BUG_ON
-#define HAVE_ARCH_WARN_ON
#endif /* __ASSEMBLY __ */
#endif /* CONFIG_BUG */

Index: linux-2.6.24-rc6/include/asm-s390/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-s390/bug.h
+++ linux-2.6.24-rc6/include/asm-s390/bug.h
@@ -61,8 +61,6 @@
unlikely(__ret_warn_on); \
})

-#define HAVE_ARCH_BUG
-#define HAVE_ARCH_WARN_ON
#endif /* CONFIG_BUG */

#include <asm-generic/bug.h>
Index: linux-2.6.24-rc6/include/asm-sparc/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-sparc/bug.h
+++ linux-2.6.24-rc6/include/asm-sparc/bug.h
@@ -26,7 +26,6 @@ extern void do_BUG(const char *file, int
#define BUG() __bug_trap()
#endif

-#define HAVE_ARCH_BUG
#endif

#include <asm-generic/bug.h>
Index: linux-2.6.24-rc6/include/asm-sparc64/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-sparc64/bug.h
+++ linux-2.6.24-rc6/include/asm-sparc64/bug.h
@@ -14,7 +14,6 @@ extern void do_BUG(const char *file, int
#define BUG() __builtin_trap()
#endif

-#define HAVE_ARCH_BUG
#endif

#include <asm-generic/bug.h>
Index: linux-2.6.24-rc6/include/asm-v850/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-v850/bug.h
+++ linux-2.6.24-rc6/include/asm-v850/bug.h
@@ -17,7 +17,6 @@
#ifdef CONFIG_BUG
extern void __bug (void) __attribute__ ((noreturn));
#define BUG() __bug()
-#define HAVE_ARCH_BUG
#endif

#include <asm-generic/bug.h>
Index: linux-2.6.24-rc6/include/asm-x86/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-x86/bug.h
+++ linux-2.6.24-rc6/include/asm-x86/bug.h
@@ -2,7 +2,6 @@
#define _ASM_X86_BUG_H

#ifdef CONFIG_BUG
-#define HAVE_ARCH_BUG

#ifdef CONFIG_DEBUG_BUGVERBOSE


2008-01-17 00:59:15

by Olof Johansson

[permalink] [raw]
Subject: [patch 2/3] [POWERPC] switch to generic WARN_ON / BUG_ON

Not using the ppc-specific WARN_ON/BUG_ON constructs actually saves about
4K text on a ppc64_defconfig. The main reason seems to be that prepping
the arguments to the conditional trap instructions is more work than just
doing a compare and branch.

Signed-off-by: Olof Johansson <[email protected]>
Cc: <[email protected]>
Cc: Paul Mackerras <[email protected]>
---

include/asm-powerpc/bug.h | 37 -------------------------------------
1 file changed, 37 deletions(-)

Index: linux-2.6.24-rc6/include/asm-powerpc/bug.h
===================================================================
--- linux-2.6.24-rc6.orig/include/asm-powerpc/bug.h
+++ linux-2.6.24-rc6/include/asm-powerpc/bug.h
@@ -54,12 +54,6 @@
".previous\n"
#endif

-/*
- * BUG_ON() and WARN_ON() do their best to cooperate with compile-time
- * optimisations. However depending on the complexity of the condition
- * some compiler versions may not produce optimal results.
- */
-
#define BUG() do { \
__asm__ __volatile__( \
"1: twi 31,0,0\n" \
@@ -69,20 +63,6 @@
for(;;) ; \
} while (0)

-#define BUG_ON(x) do { \
- if (__builtin_constant_p(x)) { \
- if (x) \
- BUG(); \
- } else { \
- __asm__ __volatile__( \
- "1: "PPC_TLNEI" %4,0\n" \
- _EMIT_BUG_ENTRY \
- : : "i" (__FILE__), "i" (__LINE__), "i" (0), \
- "i" (sizeof(struct bug_entry)), \
- "r" ((__force long)(x))); \
- } \
-} while (0)
-
#define __WARN() do { \
__asm__ __volatile__( \
"1: twi 31,0,0\n" \
@@ -92,23 +72,6 @@
"i" (sizeof(struct bug_entry))); \
} while (0)

-#define WARN_ON(x) ({ \
- int __ret_warn_on = !!(x); \
- if (__builtin_constant_p(__ret_warn_on)) { \
- if (__ret_warn_on) \
- __WARN(); \
- } else { \
- __asm__ __volatile__( \
- "1: "PPC_TLNEI" %4,0\n" \
- _EMIT_BUG_ENTRY \
- : : "i" (__FILE__), "i" (__LINE__), \
- "i" (BUGFLAG_WARNING), \
- "i" (sizeof(struct bug_entry)), \
- "r" (__ret_warn_on)); \
- } \
- unlikely(__ret_warn_on); \
-})
-
#endif /* __ASSEMBLY __ */
#endif /* CONFIG_BUG */


2008-01-17 00:59:40

by Olof Johansson

[permalink] [raw]
Subject: [patch 3/3] Add bug/warn marker to generic report_bug()

Powerpc uses the generic report_bug() from lib/bug.c to report warnings,
and I'm guessing other arches do as well.

Add the module list as well as the end-of-trace marker to the output. This
required making print_oops_end_marker() nonstatic.


Signed-off-by: Olof Johansson <[email protected]>


diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 94bc996..88d1aa3 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -133,6 +133,7 @@ NORET_TYPE void panic(const char * fmt, ...)
extern void oops_enter(void);
extern void oops_exit(void);
extern int oops_may_print(void);
+extern void print_oops_end_marker(void);
fastcall NORET_TYPE void do_exit(long error_code)
ATTRIB_NORET;
NORET_TYPE void complete_and_exit(struct completion *, long)
diff --git a/kernel/panic.c b/kernel/panic.c
index d9e90cf..0269a7f 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -281,7 +281,7 @@ static int init_oops_id(void)
}
late_initcall(init_oops_id);

-static void print_oops_end_marker(void)
+void print_oops_end_marker(void)
{
init_oops_id();
printk(KERN_WARNING "---[ end trace %016llx ]---\n",
diff --git a/lib/bug.c b/lib/bug.c
index 530f38f..3aa60a5 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -148,7 +148,9 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
"[verbose debug info unavailable]\n",
(void *)bugaddr);

+ print_modules();
show_regs(regs);
+ print_oops_end_marker();
return BUG_TRAP_TYPE_WARN;
}

2008-01-17 01:18:18

by Arjan van de Ven

[permalink] [raw]
Subject: Re: [patch 3/3] Add bug/warn marker to generic report_bug()

On Wed, 16 Jan 2008 19:10:00 -0600
Olof Johansson <[email protected]> wrote:

> Powerpc uses the generic report_bug() from lib/bug.c to report
> warnings, and I'm guessing other arches do as well.
>
> Add the module list as well as the end-of-trace marker to the output.
> This required making print_oops_end_marker() nonstatic.
>
>
> Signed-off-by: Olof Johansson <[email protected]>
>
>

All three are
Acked-by: Arjan van de Ven <[email protected]>

2008-01-17 08:37:20

by Russell King

[permalink] [raw]
Subject: Re: [patch 1/3] bug.h: Remove HAVE_ARCH_BUG and HAVE_ARCH_WARN

On Wed, Jan 16, 2008 at 07:08:27PM -0600, Olof Johansson wrote:
> No need to have the HAVE_ARCH_BUG.* / HAVE_ARCH_WARN.* defines, when
> the generic implementation can just use #ifndef on the macros themselves.
>
> Signed-off-by: Olof Johansson <[email protected]>
> Cc: <[email protected]>

For the ARM bit:

Acked-by: Russell King <[email protected]>

--
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: