Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 62359
b: refs/heads/master
c: a586df0
h: refs/heads/master
i:
  62357: b1c2389
  62355: c78372f
  62351: 3cd8587
v: v3
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed Jul 22, 2007
1 parent 7f46b0b commit 23dbfe3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b520b85a963bf7b14b9614579aff14558d7ee264
refs/heads/master: a586df067afe0580bb02b7a6312ca2afe49bba03
18 changes: 18 additions & 0 deletions trunk/include/linux/compiler-gcc4.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions trunk/include/linux/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
8 changes: 4 additions & 4 deletions trunk/include/linux/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 */
Expand Down
8 changes: 4 additions & 4 deletions trunk/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 23dbfe3

Please sign in to comment.