A client's view of a pool BO is a physical-range descriptor; a task can
copy its mapping in the VM, and the copy refers to the device pager's VM
object, not to the descriptor, so the view's free did not mean the pages
were unmapped and every viewed grant was retired for good (run68: 77
grants, 25524 KiB).
Where the kernel has iokit_physical_descriptor_close_notify (XNU patch
gpupool-device-pager-close), a view registers the grant with it before
anything can map the view, and its reference to the grant goes only when
the kernel reports the pager's close: IOKit has released the descriptor
and the VM has reported the object's last unmap, which it does only once
no map entry, memory entry or copy object refers to it. The pages then
return to the pool, marked for the cache pass before their next zero
fill. A view the kernel cannot track (the symbol is weak; kernels
without the patch) retires its grant as before, and gpu-pool=2 still
recycles those too. native_adreno_pool_views counts both kinds, the
reports and the grants given back.
Not run on hardware.
The board registers free DRAM the kernel does not manage with native_adreno_pool_add. A write-combined system BO first asks the pool (NativeAdrenoPool.cpp: a bitmap a range, best single run, else the longest runs first, zero fill through the range's own write-combined kernel mapping before a grant is handed out); whatever the pool does not serve takes the descriptor path unchanged. A pool BO has a grant and no descriptor: its spans are the grant's runs, nothing of it is cleaned, audited or read through the cacheable aperture, its client view maps its physical runs write-combined and holds the grant until IOKit frees the view, and an import of pool pages is refused. Pages a client had a view of are retired unless gpu-pool=2; gpu-pool=0 turns the pool off. Counters: native_adreno_pool_state, native_adreno_pool_fallbacks, native_adreno_pool_zero.
Host tests: test_pool (allocator against a page model) and test_pool_memory (BO paths); the existing 23 pass as before, test_client and test_gmuconfig fail as at the base. Every changed kernel source passes the kernel's compile recipe as a syntax check. Not built into an image and not run on hardware.
User BOs are pageable IOBufferMemoryDescriptors with no task and no
kernel mapping, wired by prepare(), as Metal resources are system
memory. The VM zero-fills them and sets the write-combined attribute in
one batch while wiring, and restores it when the object is reaped.
Client views map the descriptor itself, so no device-pager view resets
the page attribute and submissions no longer re-assert it.
The 1536 MiB boot-time pool is gone. In untagged-ed1611b1 it filled
with the runtime's blocks, 404 BOs fell back to scattered kernel memory,
96 allocations of 96 MiB failed and the pressure flag stayed set.
Memory pressure is now reported when the system refuses a BO.
Imports are proven exclusive through a page bitmap of the driver's own
BOs instead of a pairwise span check.
The pool is a set of physically contiguous chunks instead of one fixed
block. The board's reservation is the first chunk and stays; when no
chunk has room a new one is taken from the system (2 MiB, the 4 KiB
granule's block size, halved down to 64 KiB, or a large BO's own size),
write-combined once as it is made, and given back when it empties.
Memory pressure is reported only when the system cannot give a chunk
(that BO falls back to scattered pages) and ends once the pool serves an
allocation again; the seven-eighths rule and the 2 s window are gone.