[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kernelnewbies
Subject:    Re: What is __initfunc()?
From:       John Levon <moz () compsoc ! man ! ac ! uk>
Date:       2000-09-15 11:44:13
[Download RAW message or body]

On Fri, 15 Sep 2000, Martin MaD Douda wrote:

> 
> 
> IIRC that means, that fwchain_init() is called _only_ when initializing
> and it's code will be freed after it. It would work without __initfunc(),
> but it would consume a few bits of memory with no good reason.
> 
> 
> 
> 				Martin
> 

Also, in 2.4, this is done by adding __init, for routines that you know
will only be used during the initialising phase. Similarly you can specify
__initdata for data that should be thrown away (this is why having the PCI
names database is not a waste of memory; it's thrown away after
initialisation), and also __initlocaldata to avoid a gcc bug.

What they actually *do* is indicate to the linker that they should be put
in special linker sections, (look in arch/i386/vmlinux.lds and you'll see
sections called ".text.init" and ".data.init") so they can be removed
easily.

There is also __exit ... what use is that ? That's when you have code that
can be a module or compiled into the kernel. If it can be compiled in,
there's no point in keeping the module_exit() routine around, so it is
stripped out during build.

You can see how much memory this technique is saving you by looking at the 
"Freeing init memory" or similar message in the bootlog.

john 

-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.surriel.com/kernelnewbies.shtml

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic