Controlling use of page cache for usb-storage disk access in a MIPS based embedded system

From: Srinivasan Jayarajan
Date: Fri Dec 05 2008 - 00:30:56 EST


Hi,

I have Linux 2.6.16-17 running on a MIPS development board. The
board also has an usb port. I also have samba 3.0.28a running on the
platform, which is used to share usb-storage disk partitions. The
system does not have any swap partition and after a cold reboot, the
system has about 154MB free

cat /proc/meminfo
MemTotal: 404768 kB
MemFree: 153508 kB
Buffers: 80 kB
Cached: 136464 kB
SwapCached: 0 kB
Active: 123828 kB
Inactive: 82316 kB
HighTotal: 163712 kB
HighFree: 376 kB
LowTotal: 241056 kB
LowFree: 153132 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 0 kB
Writeback: 0 kB
Mapped: 98996 kB
Slab: 25364 kB
CommitLimit: 202384 kB
Committed_AS: 235796 kB
PageTables: 2512 kB
VmallocTotal: 1015800 kB
VmallocUsed: 8060 kB
VmallocChunk: 1007568 kB

I have also tweaked the /proc/sys/vm entries as follows to limit the
use of page cache

/proc/sys/vm/dirty_background_ratio = 2
/proc/sys/vm/dirty_ratio = 5
/proc/sys/vm/dirty_expire_centisecs = 1000
/proc/sys/vm/vfs_cache_pressure = 10000

The moment I try to copy a huge file (about 1GB), the cached page
count goes up and eats away about 100MB in spite of the above vm
tweaks. In some cases, the system runs out of memory and OOM kicks in.

MemTotal: 404768 kB
MemFree: 10512 kB
Buffers: 1208 kB
Cached: 274260 kB
SwapCached: 0 kB
Active: 126472 kB
Inactive: 219632 kB
HighTotal: 163712 kB
HighFree: 376 kB
LowTotal: 241056 kB
LowFree: 10136 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 16200 kB
Writeback: 0 kB
Mapped: 101500 kB
Slab: 28176 kB
CommitLimit: 202384 kB
Committed_AS: 240220 kB
PageTables: 2596 kB
VmallocTotal: 1015800 kB
VmallocUsed: 8060 kB
VmallocChunk: 1007568 kB

I even tried copying a file from one folder to another from shell
using dd with the direct flag

dd oflag=direct if=/mnt/usb/test.avi of=/mnt/usb/copy/test.avi

The copy was very slow with the following results

1638660+0 records in
1638660+0 records out
838993920 bytes (839 MB) copied, 1827.17 s, 459 kB/s

But the page cache still ate quite a lot of memory close to 100MB, but
the growth in page cache was much slow. I would like to cap the use of
page cache to a hard limit of say about

Cached: 179200 kB. Is this possible and is it safe?


Thanks,

Srini
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/