__init什么意思?
http://www.moses.uklinux.net/patches/lki-3.htmlThe inode cache subsystem is initialised when inode_init() function is called from init/main.c:start_kernel(). The function is marked as __init, which means its code is thrown away later on. It is passed a single argument - the number of physical pages on the system. This is so that the inode cache can configure itself depending on how much memory is available, i.e. create a larger hashtable if there is enough memory.
__init意味该函数在后来被丢弃,怎么理解?后来是指什么阶段? 也就是说,凡是带有__init的函数,只是在系统初始化的时候使用,在系统初始化结束以后,永远不使用这个函数.直到下一次重新启动计算机,再一次进行系统初始化的时候,才会再一次用到. thx. and thus after using all this routines, linux can remove them and save some mem. that is why we can see
"Freeing unused kernel memory: xxxk freed" 恩,但是我不知道kernel释放这些初始化内存的控制路径在什么位置?另外,释放的是什么空间呢?函数体的空间?是不是通过__init定义的函数在编译的时候把这种函数都放在在".text.init"会话区(section)里,在kernel启动完毕后,把整个sectiond都删除呢?
我想这个section也是属于kernel的文本image,删除了能节约多少空间,能不能用上这些空间? free_initmem() in arch/xx/mm/init.c
i think even 100kb mem is useful at some situations. 那__init是放在kernel image的最后部分了,这样释放后__end才又可能减小,对吗? qjfx or ULK have intro. i forget.
my brain only has 640k and becomes smaller and smaller now. 是的,bss段 o, thx bss段不是存放没有初始化的数据吗?还可以存放函数体? include/linux/init.h
#define __init __attribute__ ((__section__ (".text.init")))
#define __exit __attribute__ ((unused, __section__(".text.exit")))
#define __initdata __attribute__ ((__section__ (".data.init")))
#define __exitdata __attribute__ ((unused, __section__ (".data.exit")))
#define __initsetup __attribute__ ((unused,__section__ (".setup.init")))
#define __init_call __attribute__ ((unused,__section__ (".initcall.init")))
#define __exit_call __attribute__ ((unused,__section__ (".exitcall.exit")))
请大家一并看看这几个定义,
代码注释: Mark functions and data as being only used at initialization or exit time. so there are in different seg?
hehe, should check some doc to know this. o,sorry, I was confused i remember books have this. but i forget again. my main memory is so small that, i always have to swap out most of the knowledge i had learned. sigh!
页:
[1]
2