Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
12748 Discussions

µCLinux - How to minimize buffers

Altera_Forum
Honored Contributor II
1,365 Views

Hello, im trying to minimize the buffers used by Linux to gain more free memory. My custom board is equipped with a 2MB SDRAM chip, but after booting the kernel I have only between 200-300 KB free. I heard wentao talking about the kernel dynamically allocating a lot of RAM during the boot process - does this include buffers .....and is there a way to decrease the size of these buffers? 

 

When I use the "free"-command on my development board (Altera Nios Cyclone) after booting up Linux, it says: 

 

MemTotal:        14776 kB MemFree:         11720 kB Buffers:          1208 kB 

 

Here the buffers take up 1208 KB which is OK because the dev. board got plenty of ram....but if it also takes up over 1MB of RAM on my custom board that too much. I can&#39;t use the "free"-command on my custom board because - I believe - "free" requires /proc which in turn requires a RAM-drive which requires "mount" to be called .....and I don&#39;t have enough free ram to execute "mount" ......so thats just perfect http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/huh.gif  

 

If anyone has any ideas I would be glad to hear them! Currently im also trying to make the kernel execute in place .....but im still having a bit trouble with that even thou wentao pointed me in the right direction. 

 

Hope you guys can help me 

 

Regards  

 

Goon
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
863 Views

Hello, I guess it wasn&#39;t the buffers that consumed all my memory after all. When I use the command: 

 

cat meminfo 

 

I get the following result: 

 

# cat meminfo MemTotal:         1220 kB MemFree:           380 kB Buffers:           148 kB Cached:             56 kB SwapCached:          0 kB Active:            136 kB Inactive:           60 kB HighTotal:           0 kB HighFree:            0 kB LowTotal:         1220 kB LowFree:           380 kB SwapTotal:           0 kB SwapFree:            0 kB Dirty:               0 kB Writeback:           0 kB Mapped:              0 kB Slab:              512 kB Committed_AS:        0 kB PageTables:          0 kB VmallocTotal:  4194303 kB VmallocUsed:         0 kB VmallocChunk:  4194303 kB 

 

It seems that it is the Slab allocator that eats most of my memory, but how can I minimize its consumption? And what exactly DOES this Slab-allocator actually do? 

 

Hope anybody can help me. 

 

By the way I removed the RAM-drive in the kernel-setup - so now i write: 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

mount -t ramfs ramfs /var -n[/b] 

--- Quote End ---  

 

 

instead of: 

 

<div class='quotetop'>QUOTE </div> 

--- Quote Start ---  

mount -t ext2 /dev/ram0 /var -n[/b] 

--- Quote End ---  

 

 

Regards  

 

Goon
0 Kudos
Altera_Forum
Honored Contributor II
863 Views

Hi Goon, 

 

The slab layer manages the small data structures frequently allocated and freed by kernel. For example, process descriptors, inodes, etc are all from it. Since kernel needs allocate all kinds of structures in order to run, and will automatically try to free memory from it when system available memory is low, I don&#39;t think you can squeeze much from the 512K. 

 

Regards, 

wentao
0 Kudos
Reply