Messages in this thread | | | Date | Sun, 14 Apr 1996 13:41:02 -0400 (EDT) | From | Molnar Ingo <> | Subject | Another silly idea: lets save kernel memory |
| |
Lets split the kernel into two parts:
- boot section - The Rest
boot section includes almost all arch/*/boot and devices/* do_probe functions.
The boot seqence would be the following:
1) LILO or similar 2) all messy things till kernel_start 3) init/main.c, till the while(1) in init 4) now the new part (huoh), lets free all code pages used so far 5) and now we do while(1) happily in init
This needs to split the kernel image into two parts: boot section and The Rest. This split is compile dependent. Has to be adjusted to a page boundary, thus enlarging the kernel >image< by at most 4095 bytes.
Same thing applies for modules too i guess. Besides the reentrancy part of init_module, the rest could be put into a "throw away after one use" section.
I've done some calculations how much kernel memory could be saved with throwing away the boot section:
exactly 32912 bytes on my system (didnt count the bits)
The following (very dumb) script takes all functions who's name contains "*init*" or "*probe*", and calculates the size of them and sums up those sizes:
[IMPORTANT: cd to the the directory where your System.map is]
---------> the script starts here: -----> #!/bin/bash
echo 'void main ( void ) { \ int in; \ scanf("%x\n",&in); printf("%d\n",in); \ } ' > /tmp/hex2dec.c gcc -o /tmp/hex2dec /tmp/hex2dec.c; rm /tmp/hex2dec.c
ALL="0" A=`cat System.map | grep -n -E 'init|probe' | cut -d: -f1`
for N in $A; do tail +$N System.map > /tmp/temp1 head -2 /tmp/temp1 > /tmp/temp2 FUNCTION=`head -1 /tmp/temp2|cut -d\ -f3` X1=`head -1 /tmp/temp2|cut -d\ -f1` X2=`tail -1 /tmp/temp2|cut -d\ -f1` echo "$X1 to $X2, $FUNCTION" DIFF="`echo $X2 | /tmp/hex2dec` - `echo $X1 | /tmp/hex2dec`" DIFF=`echo $DIFF | bc` ALL="$ALL + $DIFF" done
rm -f /tmp/temp1 /tmp/temp2 /tmp/hex2dec
echo $ALL echo "The summed-up size of these functions: `echo $ALL | bc`" <-------- The script ends here <----------
The upper method is more than questionable. And it depends on the .config (and the SMP switch and other defines).
Great, you have read this mail so far. Okay. Now the Right Thing Part: (Dreaming About An Ideal World): each function in the kernel could have a "persistancy" attribute:
- used once, throw away - dont swap, or we gonna race - can swap, i'm the graphics driver (hey, this is Future as i told you)
This actually splits the image into three (3) parts, with page alignment. [and ELF sections come to mind, immediatelly]
-- mingo
| |