[lkml]   [1996]   [Apr]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectAnother 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

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

[IMPORTANT: cd to the the directory where your is]

---------> the script starts here: ----->

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

A=`cat | grep -n -E 'init|probe' | cut -d: -f1`

for N in $A; do
tail +$N > /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`

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

 \ /
  Last update: 2005-03-22 13:37    [W:0.296 / U:0.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site