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
+17 -1
View File
@@ -25,6 +25,22 @@
#ifndef _SPL_DNLC_H
#define _SPL_DNLC_H
#define dnlc_reduce_cache(percent) ((void)0)
/*
* Reduce the dcache and icache then reap the free'd slabs. Note the
* interface takes a reclaim percentage but we don't have easy access to
* the total number of entries to calculate the reclaim count. However,
* in practice this doesn't need to be even close to correct. We simply
* need to reclaim some useful fraction of the cache. The caller can
* determine if more needs to be done.
*/
static inline void
dnlc_reduce_cache(void *reduce_percent)
{
int nr = (uintptr_t)reduce_percent * 10000;
shrink_dcache_memory(nr, GFP_KERNEL);
shrink_icache_memory(nr, GFP_KERNEL);
kmem_reap();
}
#endif /* SPL_DNLC_H */