User application(ftp) causing OOM

Submitted by Anonymous
on May 30, 2009 - 12:22am

am using 2.6.12.6 kernel on my embedded system with 32Mb SDRAM and
no swap partition. My embedded system has support of FTP server and
USB mass-storage. Now I try to put a large file (>50MB) from windows
machine (connected via ethernet to Linux s/s running FTP server) onto
the flash drive which is attched via USB. Sometimes the file transfer
suceedes but most of the time the OOM comes.
Initial free memory is (before OOM issue):
cat /proc/meminfo
MemTotal: 25044 kB
MemFree: 5628 kB
Buffers: 2828 kB
Cached: 7156 kB
SwapCached: 0 kB
Active: 6120 kB
Inactive: 6380 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 25044 kB
LowFree: 5628 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
Mapped: 4936 kB
Slab: 2964 kB
CommitLimit: 12548 kB
Committed_AS: 4908 kB
PageTables: 268 kB
VmallocTotal: 229376 kB
VmallocUsed: 8296 kB
VmallocChunk: 221040 kB

Following is the output of meminfo just before OOM:
cat /proc/meminfo
MemTotal: 25044 kB
MemFree: 588 kB
Buffers: 28 kB
Cached: 14308 kB
SwapCached: 0 kB
Active: 8044 kB
Inactive: 8376 kB
HighTotal: 0 kB
HighFree: 0 kB
LowTotal: 25044 kB
LowFree: 588 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 2764 kB
Writeback: 1504 kB
Mapped: 2528 kB
Slab: 3612 kB
CommitLimit: 12520 kB
Committed_AS: 4916 kB
PageTables: 272 kB
VmallocTotal: 229376 kB
VmallocUsed: 8296 kB
VmallocChunk: 221040 kB
oom-killer: gfp_mask=0xd0
DMA per-cpu:
cpu 0 hot: low 2, high 6, batch 1
cpu 0 cold: low 0, high 2, batch 1
Normal per-cpu: empty
HighMem per-cpu: empty

Free pages: 588kB (0kB HighMem)
Active:2011 inactive:2094 dirty:691 writeback:376 unstable:0 free:147 slab:903 m
apped:632 pagetables:68
DMA free:588kB min:676kB low:844kB high:1012kB active:8044kB inactive:8376kB pre
sent:28672kB pages_scanned:18116 all_unreclaimable? no
lowmem_reserve[]: 0 0 0
Normal free:0kB min:0kB low:0kB high:0kB active:0kB inactive:0kB present:0kB pag
es_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0 0
HighMem free:0kB min:128kB low:160kB high:192kB active:0kB inactive:0kB present:
0kB pages_scanned:0 all_unreclaimable? no
lowmem_reserve[]: 0 0 0
DMA: 21*4kB 1*8kB 1*16kB 3*32kB 0*64kB 1*128kB 1*256kB 0*512kB 0*1024kB 0*2048kB
0*4096kB = 588kB
Normal: empty
HighMem: empty
Out of Memory: Killed process 1047 (bftpd).

I think before OOM the linux kernel should try to free the page cache
which in my case is more than 12MB to fulfil the m/m allocation
request which I doubt is not happening.

dirty

strcmp
on
May 31, 2009 - 2:35am

do you use tmpfs? tmpfs is a normal filesystem, but without a backing store: the pages remain in the page cache, even under memory pressure, because they have nowhere to go. do you have big files in your initramfs? can you move some readonly files into flash backed filesystems like cramfs/squashfs?

compared with what ram you have left, these numbers look big; writeout to the flash drive may be slower than the network transfer:

Dirty: 2764 kB
Writeback: 1504 kB

this possibly just means that the ftpd has to be throttled by the kernel to let the data be received slower; maybe it has to be throttled (forced to wait for some data to be written) earlier. the threshold value for that is dirty_ratio. you may have to fiddle with this and the other tuning parameters in /proc/sys/vm .

Actually we have played with

Anonymous (not verified)
on
June 2, 2009 - 9:54pm

Actually we have played with the dirty_ratio and other vm variables.
The meminfo dump is different everytime we run it, it is not at all consistent. Sometime dirty is 0.The only common thing that happens 80% of the time is OOM geeting called and killing application process.

Also, about out file system , we tried this exercise on squashfs and jffs2. The problem persists on both.

On squashfs we mount the USB in /var/ and put the file via ftp service.

One thing we tried, was to mount usb with O_SYNC to by-pass linux cache code leg. Also, O_DIRECT flag during file open will perhaps do the same thing. But these approaches are not steps to resolve the problem.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.