A class's slab of the Shared pool went back the moment its last buffer did
(RgfxPoolSlabSource::keepsFreed() answered false), and a large buffer's own slab
skipped the cache. A process that makes one buffer and frees it again and again
in an otherwise empty class then took a pool block for each buffer: a take the
thread waits for, a HEAP_OVER_POOL, the host zeroing the block, then the heap's
destroy and the block's give. Each new slab doubles its class's next one, so
after seven rounds every block was 16 MiB, for a buffer of one page. A user's
guest logged one process making and giving back about 17 such slabs a second,
none of them taken from again. The serialiser test of that pattern at
805c93a65 counted 100 small slabs (1539968 KiB) and 100 large slabs for 100
rounds of each, and 200 pool takes.
keepsFreed() is gone, so every source's slabs follow the one form. Each class
keeps two empty slabs, and large buffers' own slabs are cached, each for
kCacheIdleMs (2 s) at most. The pool source now takes a capacity, as the pages
source does, and the device passes the guest's RAM: the kext tells the bundle
nothing of the pool's length, so the pool's cache holds a sixteenth of the
guest's RAM at most. A refused take still lets the process's own kept and
cached slabs go first.
What changes for the guest: a buffer of the pool may lie in a slab an earlier
buffer emptied, at that heap's GPU address and offset, rather than in a new
block's heap, and the host sees fewer POOL_TAKE, HEAP_OVER_POOL,
OBJECT_DESTROY and POOL_GIVE messages. A kept block is its process's alone for
up to 2 s after its last buffer goes. A new buffer still reads zeros: the test
writes 0xa5 over each buffer before its free and reads zeros in the next.
test_pool_slab_churn_is_bounded holds the bound: one small slab, one large one
and two takes for those rounds. The pool tests that held the old let-go now
let kept slabs go through the idle clock or reclaim(). The guest sets are
rebuilt with the next commit, which changes the bundle too.