Add dnlc_reduce_cache() support

Provide the dnlc_reduce_cache() function which attempts to prune
cached entries from the dcache and icache.  After the entries are
pruned any slabs which they may have been using are reaped.

Note the API takes a reclaim percentage but we don't have easy
access to the total number of cache entries to calculate the
reclaim count.  However, in practice this doesn't need to be
exactly correct.  We simply need to reclaim some useful fraction
(but not all) of the cache.  The caller can determine if more
needs to be done.
This commit is contained in:
Brian Behlendorf
2011-03-30 17:44:35 -07:00
parent 83150861e6
commit e76f4bf11d
6 changed files with 283 additions and 1 deletions
+28
View File
@@ -185,6 +185,16 @@ invalidate_inodes_t invalidate_inodes_fn = SYMBOL_POISON;
EXPORT_SYMBOL(invalidate_inodes_fn);
#endif /* HAVE_INVALIDATE_INODES */
#ifndef HAVE_SHRINK_DCACHE_MEMORY
shrink_dcache_memory_t shrink_dcache_memory_fn = SYMBOL_POISON;
EXPORT_SYMBOL(shrink_dcache_memory_fn);
#endif /* HAVE_SHRINK_DCACHE_MEMORY */
#ifndef HAVE_SHRINK_ICACHE_MEMORY
shrink_icache_memory_t shrink_icache_memory_fn = SYMBOL_POISON;
EXPORT_SYMBOL(shrink_icache_memory_fn);
#endif /* HAVE_SHRINK_ICACHE_MEMORY */
pgcnt_t
spl_kmem_availrmem(void)
{
@@ -2102,6 +2112,24 @@ spl_kmem_init_kallsyms_lookup(void)
}
#endif /* HAVE_INVALIDATE_INODES */
#ifndef HAVE_SHRINK_DCACHE_MEMORY
shrink_dcache_memory_fn = (shrink_dcache_memory_t)
spl_kallsyms_lookup_name("shrink_dcache_memory");
if (!shrink_dcache_memory_fn) {
printk(KERN_ERR "Error: Unknown symbol shrink_dcache_memory\n");
return -EFAULT;
}
#endif /* HAVE_SHRINK_DCACHE_MEMORY */
#ifndef HAVE_SHRINK_ICACHE_MEMORY
shrink_icache_memory_fn = (shrink_icache_memory_t)
spl_kallsyms_lookup_name("shrink_icache_memory");
if (!shrink_icache_memory_fn) {
printk(KERN_ERR "Error: Unknown symbol shrink_icache_memory\n");
return -EFAULT;
}
#endif /* HAVE_SHRINK_ICACHE_MEMORY */
return 0;
}