From 23dbfe3e4e0cd6028e1f445d3e5283d7e39a2693 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Sat, 21 Jul 2007 17:10:00 +0200 Subject: [PATCH] --- yaml --- r: 62359 b: refs/heads/master c: a586df067afe0580bb02b7a6312ca2afe49bba03 h: refs/heads/master i: 62357: b1c23893479dd00c5504ef9020804688be04be0e 62355: c78372f81b4eedc4b9f2e1f0bc85a7624f563988 62351: 3cd8587db67322940511dc3def868ae7dcb0547c v: v3 --- [refs] | 2 +- trunk/include/linux/compiler-gcc4.h | 18 ++++++++++++++++++ trunk/include/linux/compiler.h | 9 +++++++++ trunk/include/linux/init.h | 8 ++++---- trunk/include/linux/kernel.h | 8 ++++---- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index 0803ddcf039f..8cf6f2e959fc 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: b520b85a963bf7b14b9614579aff14558d7ee264 +refs/heads/master: a586df067afe0580bb02b7a6312ca2afe49bba03 diff --git a/trunk/include/linux/compiler-gcc4.h b/trunk/include/linux/compiler-gcc4.h index a03e9398a6c2..14f7494280f0 100644 --- a/trunk/include/linux/compiler-gcc4.h +++ b/trunk/include/linux/compiler-gcc4.h @@ -23,3 +23,21 @@ * code */ #define uninitialized_var(x) x = x + +#if !(__GNUC__ == 4 && __GNUC_MINOR__ < 3) +/* Mark functions as cold. gcc will assume any path leading to a call + to them will be unlikely. This means a lot of manual unlikely()s + are unnecessary now for any paths leading to the usual suspects + like BUG(), printk(), panic() etc. [but let's keep them for now for + older compilers] + + Early snapshots of gcc 4.3 don't support this and we can't detect this + in the preprocessor, but we can live with this because they're unreleased. + Maketime probing would be overkill here. + + gcc also has a __attribute__((__hot__)) to move hot functions into + a special section, but I don't see any sense in this right now in + the kernel context */ +#define __cold __attribute__((__cold__)) + +#endif diff --git a/trunk/include/linux/compiler.h b/trunk/include/linux/compiler.h index 8287a72bb6a9..12a1291855e2 100644 --- a/trunk/include/linux/compiler.h +++ b/trunk/include/linux/compiler.h @@ -174,4 +174,13 @@ extern void __chk_io_ptr(const void __iomem *); # define __attribute_const__ /* unimplemented */ #endif +/* + * Tell gcc if a function is cold. The compiler will assume any path + * directly leading to the call is unlikely. + */ + +#ifndef __cold +#define __cold +#endif + #endif /* __LINUX_COMPILER_H */ diff --git a/trunk/include/linux/init.h b/trunk/include/linux/init.h index 5b5285316339..f0d0e3295a9b 100644 --- a/trunk/include/linux/init.h +++ b/trunk/include/linux/init.h @@ -40,10 +40,10 @@ /* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __attribute__ ((__section__ (".init.text"))) +#define __init __attribute__ ((__section__ (".init.text"))) __cold #define __initdata __attribute__ ((__section__ (".init.data"))) #define __exitdata __attribute__ ((__section__(".exit.data"))) -#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) +#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) __cold /* modpost check for section mismatches during the kernel build. * A section mismatch happens when there are references from a @@ -59,9 +59,9 @@ #define __initdata_refok __attribute__ ((__section__ (".data.init.refok"))) #ifdef MODULE -#define __exit __attribute__ ((__section__(".exit.text"))) +#define __exit __attribute__ ((__section__(".exit.text"))) __cold #else -#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) +#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) __cold #endif /* For assembly routines */ diff --git a/trunk/include/linux/kernel.h b/trunk/include/linux/kernel.h index 1eb9cde550c4..4300bb462d29 100644 --- a/trunk/include/linux/kernel.h +++ b/trunk/include/linux/kernel.h @@ -106,7 +106,7 @@ extern int cond_resched(void); extern struct atomic_notifier_head panic_notifier_list; extern long (*panic_blink)(long time); NORET_TYPE void panic(const char * fmt, ...) - __attribute__ ((NORET_AND format (printf, 1, 2))); + __attribute__ ((NORET_AND format (printf, 1, 2))) __cold; extern void oops_enter(void); extern void oops_exit(void); extern int oops_may_print(void); @@ -155,14 +155,14 @@ extern void dump_thread(struct pt_regs *regs, struct user *dump); asmlinkage int vprintk(const char *fmt, va_list args) __attribute__ ((format (printf, 1, 0))); asmlinkage int printk(const char * fmt, ...) - __attribute__ ((format (printf, 1, 2))); + __attribute__ ((format (printf, 1, 2))) __cold; #else static inline int vprintk(const char *s, va_list args) __attribute__ ((format (printf, 1, 0))); static inline int vprintk(const char *s, va_list args) { return 0; } static inline int printk(const char *s, ...) __attribute__ ((format (printf, 1, 2))); -static inline int printk(const char *s, ...) { return 0; } +static inline int __cold printk(const char *s, ...) { return 0; } #endif unsigned long int_sqrt(unsigned long); @@ -212,7 +212,7 @@ extern enum system_states { #define TAINT_USER (1<<6) #define TAINT_DIE (1<<7) -extern void dump_stack(void); +extern void dump_stack(void) __cold; enum { DUMP_PREFIX_NONE,