diff options
author | Andi Kleen <ak@suse.de> | 2007-07-21 11:10:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-21 21:37:08 -0400 |
commit | a586df067afe0580bb02b7a6312ca2afe49bba03 (patch) | |
tree | 7806fef0876a2fd3da2f4c16919cfc551a65ff72 /include/linux/init.h | |
parent | b520b85a963bf7b14b9614579aff14558d7ee264 (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/init.h')
-rw-r--r-- | include/linux/init.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/include/linux/init.h b/include/linux/init.h index 5b5285316339..f0d0e3295a9b 100644 --- a/include/linux/init.h +++ b/include/linux/init.h | |||
@@ -40,10 +40,10 @@ | |||
40 | 40 | ||
41 | /* These are for everybody (although not all archs will actually | 41 | /* These are for everybody (although not all archs will actually |
42 | discard it in modules) */ | 42 | discard it in modules) */ |
43 | #define __init __attribute__ ((__section__ (".init.text"))) | 43 | #define __init __attribute__ ((__section__ (".init.text"))) __cold |
44 | #define __initdata __attribute__ ((__section__ (".init.data"))) | 44 | #define __initdata __attribute__ ((__section__ (".init.data"))) |
45 | #define __exitdata __attribute__ ((__section__(".exit.data"))) | 45 | #define __exitdata __attribute__ ((__section__(".exit.data"))) |
46 | #define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) | 46 | #define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) __cold |
47 | 47 | ||
48 | /* modpost check for section mismatches during the kernel build. | 48 | /* modpost check for section mismatches during the kernel build. |
49 | * A section mismatch happens when there are references from a | 49 | * A section mismatch happens when there are references from a |
@@ -59,9 +59,9 @@ | |||
59 | #define __initdata_refok __attribute__ ((__section__ (".data.init.refok"))) | 59 | #define __initdata_refok __attribute__ ((__section__ (".data.init.refok"))) |
60 | 60 | ||
61 | #ifdef MODULE | 61 | #ifdef MODULE |
62 | #define __exit __attribute__ ((__section__(".exit.text"))) | 62 | #define __exit __attribute__ ((__section__(".exit.text"))) __cold |
63 | #else | 63 | #else |
64 | #define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) | 64 | #define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) __cold |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | /* For assembly routines */ | 67 | /* For assembly routines */ |