2

Suppose that I want to put a big file (or a bunch of files) into a TMPFS, for whatever reason. Using dd with various combinations of direct and nocache flags, whether I copy a file from disk or create a blank file by reading from /dev/zero, the written data still gets stuffed into the filesystem cache. This is obviously kind of redundant, as the files are already in a filesystem in memory, and thus it would not make sense to also cache it, right? That is, my memory usage goes up by approximately the size of the files, as expected, but the cache usage also grows by the same amount.

The commands I used are pretty much variations of the following (/tmp is mounted as a TMPFS).

# Testing copying a file from disk to a TMPFS.
dd bs=4M iflag=fullblock,nocache oflag=nocache if=foo of=/tmp/foo
# Testing spawning a file from /dev/zero to a TMPFS.
dd bs=4M iflag=fullblock,nocache oflag=nocache if=/dev/zero of=/tmp/bar
# (also tried vith "direct", and combinations thereof)

Using vmtouch -e to try to evict the file from cache also doesn't work, for some reason. Granted, I have "enough" RAM that this "doubled" memory usage is not too big of a problem, but it does bug me a little. This problem does not seem to arise if I do the same things on my ext4 disk.

0

You must log in to answer this question.

Browse other questions tagged .