d69a892268
Tim and Ananiev report that the recent WARN_ON_ONCE changes cause increased cache misses with the tbench workload. Apparently due to the access to the newly-added static variable. Rearrange the code so that we don't touch that variable unless the warning is going to trigger. Also rework the logic so that the static variable starts out at zero, so we can move it into bss. It would seem logical to mark the static variable as __read_mostly too. But it would be wrong, because that would put it back into the vmlinux image, and the kernel will never read from this variable in normal operation anyway. Unless the compiler or hardware go and do some prefetching on us? For some reason this patch shrinks softirq.o text by 40 bytes. Cc: Tim Chen <tim.c.chen@intel.com> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: "Ananiev, Leonid I" <leonid.i.ananiev@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
60 lines
1.3 KiB
C
60 lines
1.3 KiB
C
#ifndef _ASM_GENERIC_BUG_H
|
|
#define _ASM_GENERIC_BUG_H
|
|
|
|
#include <linux/compiler.h>
|
|
|
|
#ifdef CONFIG_BUG
|
|
#ifndef HAVE_ARCH_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
|
|
#define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0)
|
|
#endif
|
|
|
|
#ifndef HAVE_ARCH_WARN_ON
|
|
#define WARN_ON(condition) ({ \
|
|
typeof(condition) __ret_warn_on = (condition); \
|
|
if (unlikely(__ret_warn_on)) { \
|
|
printk("BUG: warning at %s:%d/%s()\n", __FILE__, \
|
|
__LINE__, __FUNCTION__); \
|
|
dump_stack(); \
|
|
} \
|
|
unlikely(__ret_warn_on); \
|
|
})
|
|
#endif
|
|
|
|
#else /* !CONFIG_BUG */
|
|
#ifndef HAVE_ARCH_BUG
|
|
#define BUG()
|
|
#endif
|
|
|
|
#ifndef HAVE_ARCH_BUG_ON
|
|
#define BUG_ON(condition) do { if (condition) ; } while(0)
|
|
#endif
|
|
|
|
#ifndef HAVE_ARCH_WARN_ON
|
|
#define WARN_ON(condition) unlikely((condition))
|
|
#endif
|
|
#endif
|
|
|
|
#define WARN_ON_ONCE(condition) ({ \
|
|
static int __warned; \
|
|
typeof(condition) __ret_warn_once = (condition); \
|
|
\
|
|
if (unlikely(__ret_warn_once)) \
|
|
if (WARN_ON(!__warned)) \
|
|
__warned = 1; \
|
|
unlikely(__ret_warn_once); \
|
|
})
|
|
|
|
#ifdef CONFIG_SMP
|
|
# define WARN_ON_SMP(x) WARN_ON(x)
|
|
#else
|
|
# define WARN_ON_SMP(x) do { } while (0)
|
|
#endif
|
|
|
|
#endif
|