Add direct+indirect ARC reclaim
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 30 Mar 2011 01:08:59 +0000 (18:08 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 7 Apr 2011 16:52:10 +0000 (09:52 -0700)
commit7cb67b45f33fd7a61af24c675c7347eb5264b38c
tree519875ed0fdffbd9946299ca5b3eda533cda0623
parent1834f2d8b715d25bafbb0e4a099994f45c3211ae
Add direct+indirect ARC reclaim

Under OpenSolaris all memory reclaim is done asyncronously.  Under
Linux memory reclaim is done asynchronously _and_ synchronously.
When a process allocates memory with GFP_KERNEL it explicitly allows
the kernel to do reclaim on its behalf to satify the allocation.
If that GFP_KERNEL allocation fails the kernel may take more drastic
measures to reclaim the memory such as killing user space processes.

This was observed to happen with ZFS because the ARC could consume
a large fraction of the system memory but no synchronous reclaim
could be performed on it.  The result was GFP_KERNEL allocations
could fail resulting in OOM events, and only moments latter the
arc_reclaim thread would free unused memory from the ARC.

This change leaves the arc_thread in place to manage the fundamental
ARC behavior.  But it adds a synchronous (direct) reclaim path for
the ARC which can be called when memory is badly needed.  It also
adds an asynchronous (indirect) reclaim path which is called
much more frequently to prune the ARC slab caches.
module/zfs/arc.c