folks,
after hacking up a simple/tiny module, I was stunned at its size,
so I cut it down to essentially nothing ..
/* empty module - to find module size cost. */
#include <linux/config.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <asm/io.h>
#include <asm/semaphore.h>
int nada_init_module(void) {
return 0;
}
void nada_cleanup_module(void) {
printk(KERN_NOTICE "nada_cleanup_module\n");
}
-rw-rw-r-- 1 jimc jimc 582 Jan 16 11:18 nada.c
-rw-rw-r-- 1 jimc jimc 54271 Jan 16 11:19 nada.ko
-rw-rw-r-- 1 jimc jimc 632 Jan 16 11:19 nada.mod.c
-rw-rw-r-- 1 jimc jimc 29688 Jan 16 11:19 nada.mod.o
-rw-rw-r-- 1 jimc jimc 25568 Jan 16 11:18 nada.o
that seems like a lot of .o and .ko for a do-nothing module.
How much of that is real ? I mean, how much is actually dedicated
to the module itself, as opposed to tables used in the loading process
and then thrown away ?
I found a big thread on inline functions on LKML which discusses
.text, .bss segments etc, but unsuprisingly nobody said how they got the
numbers.
Id expect that the HOW question doesnt belong on LKML ;-)
I'm not quite sure I buy Ingo's original argument also. If he's only
looking at text size then with the above fixed then he ideally would
like to not inline anything (because except these exceptions above
.text usually near always shrinks when not inlining). But that's not
necessarily best for performance.
well, i think the numbers talk for themselves. Here are my latest
results:
----
The effect of the patches on x86, using a generic .config is:
text data bss dec hex filename
3286166 869852 387260 4543278 45532e vmlinux-orig
3194123 955168 387260 4536551 4538e7 vmlinux-inline
3119495 884960 387748 4392203 43050b vmlinux-inline+units
3051709 869380 387748 4308837 41bf65 vmlinux-inline+units+fixes
3049357 868928 387748 4306033 41b471 vmlinux-inline+units+fixes+capable
i.e. a 7.8% code-size reduction.
can someone explain:
a. what command to run to get those numbers
b. what the numbers mean
c. how the segments differ wrt sharability, readonlyness, etc
d. how they relate to numbers from 'nm -S nada.o nada.ko',
readelf -S nada.o, objdump -h nada.o
[jimc@harpo hwmon]$ nm -S nada.o nada.ko
nada.o:
00000003 0000000c T cleanup_module
00000000 00000003 T init_module
00000000 00000028 r __mod_author8
00000028 00000015 r __mod_license9
00000003 0000000c T nada_cleanup_module
00000000 00000003 T nada_init_module
U printk
nada.ko:
00000003 0000000c T cleanup_module
00000000 00000003 T init_module
00000000 00000028 r __mod_author8
00000028 00000015 r __mod_license9
0000006e 00000009 r __module_depends
00000040 0000002e r __mod_vermagic5
00000003 0000000c T nada_cleanup_module
00000000 00000003 T nada_init_module
U printk
00000000 00000140 D __this_module
00000000 00000080 r ____versions
Finally, what would be a good google-search to find relevant pages ?
searching '.text size' was futile, '.bss size' was *much* better,
any better clues ?
Id be happy to put suitable answers into
http://wiki.kernelnewbies.org/KernelGlossary
in case someone else goes there looking for such info in the future.
tia
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/kernelnewbies/
FAQ: http://kernelnewbies.org/faq/