Skip to contentSkip to conversation

mark __init code noinline to stop erroneous inclusions

PATCH In review Ben Dooks 2 participants 3 messages Oct 17, 2005 – Oct 18, 2005

lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

PATCH 1/1 mark __init code noinline to stop erroneous inclusions

Make __init also have the noinline attribute attached to it, to stop code marked as __init being included into non __init code. This not only wastes space, but also makes it impossible to track down any calls from non-init code as differing compilers and optimisations make differing decisions on what to inline.

include/linux/init.h +1 -1
@@ -41,7 +41,7 @@
 
 /* These are for everybody (although not all archs will actually
    discard it in modules) */
-#define __init		__attribute__ ((__section__ (".init.text")))
+#define __init		noinline __attribute__ ((__section__ (".init.text")))
 #define __initdata	__attribute__ ((__section__ (".init.data")))
 #define __exitdata	__attribute__ ((__section__(".exit.data")))
 #define __exit_call	__attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
#1 lore raw
Quoted 6 lines · Ben Dooks

Make __init also have the noinline attribute attached to it, to stop code marked as __init being included into non __init code. This not only wastes space, but also makes it impossible to track down any calls from non-init code as differing compilers and optimisations make differing decisions on what to inline.

I think this is overkill. __init code could be inlined into __init code. Instead we should make sure to not to call __init code from non-init code `directly'.

It is a gcc bug. Gcc really should respects __attribute__ ((__section__ (".init.text"))), and not inline the code in that section.
--
Coywolf Qi Hunt
http://sosdg.org/~coywolf/

author
#2 lore raw
Quoted 11 lines · Coywolf Qi Hunt
Quoted 6 lines · Ben Dooks

Make __init also have the noinline attribute attached to it, to stop code marked as __init being included into non __init code. This not only wastes space, but also makes it impossible to track down any calls from non-init code as differing compilers and optimisations make differing decisions on what to inline.

I think this is overkill. __init code could be inlined into __init code. Instead we should make sure to not to call __init code from non-init code `directly'.

This is very difficult to detect when the compiler is inlining the function code.

Quoted 6 lines

It is a gcc bug. Gcc really should respects __attribute__ ((__section__ (".init.text"))), and not inline the code in that section.

From the gcc 4.0 manual,

http://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html

section ("section-name")
Normally, the compiler places the code it generates in the text section. Sometimes, however, you need additional sections, or you need certain particular functions to appear in special sections. The section attribute specifies that a function lives in a particular section.

My reading of the passage is that the output code will be put in the specified section. It does not say wether or not the compiler is allowed to do any other optimisations it sees fit on the data.

My belief is that the compiler should be able to do this form of optimisation, unless we tell it otherwise. The only harm is that it makes it difficult to detect errors from compilers that do not do it.

Signature · 3 lines
Ben ([email protected], http://www.fluff.org/)

  'a smiley only costs 4 bytes'