Skip to contentSkip to conversation

vfs_cache_pressure=0 does not free inode caches

BUG? Christian Thaeter 1 participant 1 message Apr 14, 2009

lore
Share & tools
lore
#0 lore raw

Some time ago I found out that setting vfs_cache_pressure to 0 gives a decent performance boost on my laptop (4200prm 1.8" disk). In most cases metadata intensive/seeking applications (git, make, ..) wont even need to spin up the disk (ls -R / takes 4 seconds from cache). Thats great and I am using that since some time now. My first observation (looking at 'top') was that caches get still freed when memory is demanded otherwise.

But now I hit the wall with really huge directory traversals on a smaller server. Some testing revealed that the inode caches (tested with ext4 and xfs) of the file system are not freed at all. The server is going to die a slow death, all user space memory is swapped out, then all processes are OOM killed until it dies from complete memory exhaustion.

Looking at the source (fs/inode.c):

static int shrink_icache_memory(int nr, gfp_t gfp_mask) {
...
return (inodes_stat.nr_unused / 100) * sysctl_vfs_cache_pressure;
}

makes me no wonder, I didn't investigated this further. Just trying with
vfs_cache_pressure=1 gives the desired result and the inode caches are
freed on demand, case settled.

But still this has some bad taste, a cache is supposed to be a cache and not a memory hog. The documentation doesn't cover this case. It is argueable if this now can be considered as bug or as feature. I think the formula for cache shrinking should be fixed to free memory even in this extreme cases, others may argue that turning this cache off is a feature, but then it should be documented at least.

Christian