aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kernel.h
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2007-07-21 11:10:00 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-07-21 21:37:08 -0400
commita586df067afe0580bb02b7a6312ca2afe49bba03 (patch)
tree7806fef0876a2fd3da2f4c16919cfc551a65ff72 /include/linux/kernel.h
parentb520b85a963bf7b14b9614579aff14558d7ee264 (diff)
x86: Support __attribute__((__cold__)) in gcc 4.3
gcc 4.3 supports a new __attribute__((__cold__)) to mark functions cold. Any path directly leading to a call of this function will be unlikely. And gcc will try to generate smaller code for the function itself. Please use with care. The code generation advantage isn't large and in most cases it is not worth uglifying code with this. This patch marks some common error functions like panic(), printk() as cold. This will longer term make many unlikely()s unnecessary, although we can keep them for now for older compilers. BUG is not marked cold because there is currently no way to tell gcc to mark a inline function told. Also all __init and __exit functions are marked cold. With a non -Os build this will tell the compiler to generate slightly smaller code for them. I think it currently only uses less alignments for labels, but that might change in the future. One disadvantage over *likely() is that they cannot be easily instrumented to verify them. Another drawback is that only the latest gcc 4.3 snapshots support this. Unfortunately we cannot detect this using the preprocessor. This means older snapshots will fail now. I don't think that's a problem because they are unreleased compilers that nobody should be using. gcc also has a __hot__ attribute, but I don't see any sense in using this in the kernel right now. But someday I hope gcc will be able to use more aggressive optimizing for hot functions even in -Os, if that happens it should be added. Includes compile fix from Thomas Gleixner. Cc: Jan Hubicka <jh@suse.cz> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r--include/linux/kernel.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 1eb9cde550c4..4300bb462d29 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -106,7 +106,7 @@ extern int cond_resched(void);
106extern struct atomic_notifier_head panic_notifier_list; 106extern struct atomic_notifier_head panic_notifier_list;
107extern long (*panic_blink)(long time); 107extern long (*panic_blink)(long time);
108NORET_TYPE void panic(const char * fmt, ...) 108NORET_TYPE void panic(const char * fmt, ...)
109 __attribute__ ((NORET_AND format (printf, 1, 2))); 109 __attribute__ ((NORET_AND format (printf, 1, 2))) __cold;
110extern void oops_enter(void); 110extern void oops_enter(void);
111extern void oops_exit(void); 111extern void oops_exit(void);
112extern int oops_may_print(void); 112extern int oops_may_print(void);
@@ -155,14 +155,14 @@ extern void dump_thread(struct pt_regs *regs, struct user *dump);
155asmlinkage int vprintk(const char *fmt, va_list args) 155asmlinkage int vprintk(const char *fmt, va_list args)
156 __attribute__ ((format (printf, 1, 0))); 156 __attribute__ ((format (printf, 1, 0)));
157asmlinkage int printk(const char * fmt, ...) 157asmlinkage int printk(const char * fmt, ...)
158 __attribute__ ((format (printf, 1, 2))); 158 __attribute__ ((format (printf, 1, 2))) __cold;
159#else 159#else
160static inline int vprintk(const char *s, va_list args) 160static inline int vprintk(const char *s, va_list args)
161 __attribute__ ((format (printf, 1, 0))); 161 __attribute__ ((format (printf, 1, 0)));
162static inline int vprintk(const char *s, va_list args) { return 0; } 162static inline int vprintk(const char *s, va_list args) { return 0; }
163static inline int printk(const char *s, ...) 163static inline int printk(const char *s, ...)
164 __attribute__ ((format (printf, 1, 2))); 164 __attribute__ ((format (printf, 1, 2)));
165static inline int printk(const char *s, ...) { return 0; } 165static inline int __cold printk(const char *s, ...) { return 0; }
166#endif 166#endif
167 167
168unsigned long int_sqrt(unsigned long); 168unsigned long int_sqrt(unsigned long);
@@ -212,7 +212,7 @@ extern enum system_states {
212#define TAINT_USER (1<<6) 212#define TAINT_USER (1<<6)
213#define TAINT_DIE (1<<7) 213#define TAINT_DIE (1<<7)
214 214
215extern void dump_stack(void); 215extern void dump_stack(void) __cold;
216 216
217enum { 217enum {
218 DUMP_PREFIX_NONE, 218 DUMP_PREFIX_NONE,