On Mon, Aug 29, 2011 at 02:53:51PM -0400, Mikulas Patocka wrote:
> On Tue, 23 Aug 2011, Christoph Hellwig wrote:
> > FYI, the "shrinker" interface in include/linux/shrinker.h is how the
> > VM tells subsystems to shrink their memory usage. It is used for
> > various slab caches, and the XFS buffercache in
> > fs/xfs/linux-2.6/xfs_buf.c
> BTW. shrinker functions from xfs_qm.c - xfs_qm_shake and
> xfs_qm_shake_freelist - look completely bogus. They don't read
> sc->nr_to_scan to determine how many values they should scan (and compare
> it with zero to test if they should scan at all) and they return the
> number of entries freed - the interface specifies that they should return
> the number of entries remaining the in cache.
It's a relic from the days of Irix that we've kept around and never
really touched because it's never shown up as a problem. Such code
is cleaned up as we go along or as problems arise.
As it is, this patchset:
that I'm currently working on changes the shrinker API to be much
more sane - the shrinker now has a separate "count objects"
operation and the "scan objects" operation now returns the number of
items freed rather than the number of items left in the cache.
As the API is being changed, the xfs_qm shrinker is also fixed to
return the right values according to the new API. It still doesn't
pay attention to nr_to_scan, but that's not a big deal and will get
addressed in future when other upcoming changes are made to the