shrink dentry cache before inode cache
Subsystems (2)
PATCH 1/1 shrink dentry cache before inode cache
The shrink_slab() function must often be called twice to get significant slab cache reduction.
shrink_slab() walks the shrinker_list to call functions that can release kernel slab memory.
The shrinker_list is walked head to tail and, as it is now, comes across the inode cache shrinker first. This releases inodes found on the inode_unused list. Afterwards the dentry cache shrinker moves many freeable inodes to the list. But those inodes are not freed until a second invocation of shrink_slab().
The dentry cache shrinker (shrink_dcache_memory()) should run before the inode cache shrinker (shrink_icache_memory()).
This can be accomplished by queuing the dentry cache shrinker earlier - simply calling inode_init() before dcache_init().
Diffed against 2.6.15-rc5
--- fs/dcache.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletion(-)
fs/dcache.c +4 -1
@@ -1738,8 +1738,11 @@ void __init vfs_caches_init(unsigned lon filp_cachep =kmem_cache_create ("filp" ,sizeof (struct file ),0 ,SLAB_HWCACHE_ALIGN |SLAB_PANIC , filp_ctor, filp_dtor); -dcache_init (mempages);inode_init (mempages); +dcache_init (mempages);/* place after inode_init so that the dentry +cache shrink goes onto the shrinker list +before the inode cache shrink; +freeing dentry's does iput's of inodes */ files_init (mempages);mnt_init (mempages);bdev_cache_init ();
Signature · 10 lines
Cliff Wickman Silicon Graphics, Inc. [email protected] (651) 683-3824 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 13 lines · Cliff Wickman
The
shrink_slab()function must often be called twice to get significant slab cache reduction.
shrink_slab()walks theshrinker_listto call functions that can release kernel slab memory.The
shrinker_listis walked head to tail and, as it is now, comes across the inode cache shrinker first. This releases inodes found on theinode_unusedlist. Afterwards the dentry cache shrinker moves many freeable inodes to the list. But those inodes are not freed until a second invocation ofshrink_slab().
Quoted 5 lines
The dentry cache shrinker (
shrink_dcache_memory()) should run before the inode cache shrinker (shrink_icache_memory()).This can be accomplished by queuing the dentry cache shrinker earlier - simply calling
inode_init()beforedcache_init().
Is logical, although the implementation is fragile. This came up a year or so ago and we decided it wouldn't make any difference - iirc because slab shrinking tends to occur in little bites across the whole list.
Do you have any measurements or instrumentation which show improvement?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>