Commits
Alexey Dobriyan authored and Pavel Emelianov committed b0b30176219
Speedup the dcache shrinker Backport of commit d52b908646b88cb1952ab8c9b2d4423908a23f11 Author: Miklos Szeredi <mszeredi@suse.cz> Date: Tue May 8 00:23:46 2007 -0700 fix quadratic behavior of shrink_dcache_parent() The time shrink_dcache_parent() takes, grows quadratically with the depth of the tree under 'parent'. This starts to get noticable at about 10,000. These kinds of depths don't occur normally, and filesystems which invoke shrink_dcache_parent() via d_invalidate() seem to have other depth dependent timings, so it's not even easy to expose this problem. However with FUSE it's easy to create a deep tree and d_invalidate() will also get called. This can make a syscall hang for a very long time. This is the original discovery of the problem by Russ Cox: http://article.gmane.org/gmane.comp.file-systems.fuse.devel/3826 The following patch fixes the quadratic behavior, by optionally allowing prune_dcache() to prune ancestors of a dentry in one go, instead of doing it one at a time. Common code in dput() and prune_one_dentry() is extracted into a new helper function d_kill(). shrink_dcache_parent() as well as shrink_dcache_sb() are converted to use the ancestry-pruner option. Only for shrink_dcache_memory() is this behavior not desirable, so it keeps using the old algorithm. Signed-off-by: Miklos Szeredi <mszeredi@suse.cz> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Maneesh Soni <maneesh@in.ibm.com> Acked-by: "Paul E. McKenney" <paulmck@us.ibm.com> Cc: Dipankar Sarma <dipankar@in.ibm.com> Cc: Neil Brown <neilb@suse.de> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Additionally merged: commit 24c32d733dd44dbc5b9dcd0b8de58e16fdbeac7 From: Andrew Morton <akpm@linux-foundation.org> Date: Tue, 8 May 2007 07:23:49 +0000 (-0700) Subject: mm: shrink parent dentries when shrinking slab X-Git-Tag: v2.6.22-rc1~799 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=24c32d733dd44dbc5b9dcd0b8de58e16fdbeac76 mm: shrink parent dentries when shrinking slab Teach the dentry slab shrinker to aggressively shrink parent dentries when shrinking the dentry cache. This is done to attempt to improve the situation where the dentry slab cache gets a lot of internal fragmentation due to pages containing directory dentries. It is expected that this change will cause some of those dentries to be reaped earlier, and with less scanning. Needs careful testing. Cc: Miklos Szeredi <mszeredi@suse.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Typical numbers after mkdir("foo")/chdir("foo") done N times and immediate "time vzctl stop" Before: N=32768 real 1m14.529s 1m16.602s 1m16.143s user 0m0.009s 0m0.014s 0m0.007s sys 1m4.569s 1m6.638s 1m7.187s After: real 0m10.078s 0m10.080s 0m10.079s user 0m0.007s 0m0.012s 0m0.012s sys 0m0.055s 0m0.053s 0m0.054s Less easy case for this patch is the following configuration *--*--*--* ... \ \ \ \ * * * * Speedup for this case is less rosy but significant anyway: L before after 4096 11.40s 9.75s 8192 24.00s 16.80s 65536 15m39.897s 5m29.738s Bug #73640