[uClinux-dev] How to know what's taking place in memory
davidm at snapgear.com
Tue Nov 27 18:41:11 EST 2001
Jivin Fabrice Gautier lays it down ...
> I'm trying to run uClinux on my Atmel board with only 1Meg of RAM and it
> fails to load busybox (not enough memory it seems)
> However i don't really understand the figures that the kernel display.
> At the beggining I have this message:
> Memory: 1MB = 1MB total
> Memory: 304KB available (388K code, 150K data, 28K init)
> If I do 304 + 388 + 150 + 28, i'm far from the 1mb total. What does thsi
> figures really mean?
These sizes are raw, not operational size. I am not 100% but I would think
that the rest is lost to runtime memory allocation by the kernel.
Do you have you romfs in ROM or RAM ?
> So at this point I have 304 K free. My /bin/sh is busybox which is about 87
> k (cd text + data +bss).
> when it try to load it it fails with:
> __alloc_pages: 5-order allocation failed (gfp=0x1f0/0) from 0201d110
> Allocation of length 91363 from process 1 failed
> Buffer memory: 0kB
> Free pages: 132kB ( 0kB HighMem)
> ( Active: 0, inactive: 0, free: 33 )
> = 0kB)
> 3*4kB 3*8kB 0*16kB 1*32kB 1*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB =
> 13)= 0kB)
> So at this point i have only 132KB left. First question, who took those 384
> - 132 KB? Is it possible to reduce this?
No idea where the memory has gone ;-)
> Anyway with 132 KB i should have enough memory to load the 91363 bytes. But
> it seems that the memory is already fragmented so that the bigest available
> page is 64 kb.
> This mean that some part of the kernel is allocating and freeing memory
> before init.
Quite possible. Any kernel threads will allocate memory for the task
structures etc. Some drivers may allocate memory when they startup.
The easiest way if you have a debugger will be to stop on kmalloc and
page_alloc routines and see who is calling them during startup, and how
much they are using. You may find someone who can be reduced.
> Is there any part of the kernel I should look for that? I'm wondering why
> there is so much memory wasted...
You could try the page_alloc2/kmalloc2 patches (Actually they should be in
any recent kernel). This removes the power of 2 allocator and may get you
enough RAM to start up init. You init seems quite large at 91K, perhaps
you should try a smaller one like simple-init.c from userland or the
David McCullough: Ph: +61 7 3435 2815 http://www.SnapGear.com
davidm at snapgear.com Fx: +61 7 3891 3630 825 Stanley St., W'gabba QLD 4102, Oz
This message resent by the uclinux-dev at uclinux.org list server http://www.uClinux.org/
More information about the uClinux-dev