[PATCH] Fix dcache and icache bloat with deep directories
This fixes the recently-reported "fsstress memory leak" problem. It has been
there since November 2002.
shrink_dcache() has a heuristic to prevent the dcache (and hence icache) from
getting shrunk too far: it refuses to allow the dcache to shrink below
2*nr_used.
Problem is, _all_ non-leaf dentries (directories) count as used. So when you
have really deep directory hierarchies (fsstress creates these), nr_used is
really high, and there is no upper bound to the amount of pinned dcache.
The patch just rips out the heuristic. This means that dcache (and hence
icache (and hence pagecache)) will be shrunk more aggressively. This could
be a problem, and tons of testing is needed - a new heuristic may be needed.
However I am not able to reproduce the problem which cause me to add this
heuristic in the first place:
Simple testcase: run a huge `dd' while running a concurrent `watch -n1
cat /proc/meminfo'. The program text for `cat' gets loaded from disk once
per second.