A pool's buffer is made over writable pages: GPU copies into a chunk whose pages were write-protected are no longer lost (issue #1591)

A zero-copy Metal buffer made while any of its pages is read-only drops every GPU write through it, silently. Chunks of large pools, a lengthened chunk, the whole-pool buffer
of raw global memory and a small pool sharing a page with a protected neighbour were all made that way. pool_buf makes them under nvn_dirty_hold: protected pages become
writable and count as written (packaged textures are read again), and GPU-written storage the CPU had not written gets its stamp and protection back (PR #1604's spans).
Open: a CPU write into such storage while the buffer is being made is not seen.

Co-authored-by: daviddiblasi <[email protected]>
This commit is contained in:
seeddsanddaviddiblasi committed 2026-11-07 12:23:43 +08:00
1 parent 473c90266b
commit 2d544e0df6
6 files changed
+108 -7

No files matched your search

+9
View File
@@ -176,6 +176,15 @@ void nvn_dirty_remove_range(const void *mem) {
if (r) { prep_write((void *)r->base, r->end - r->base); atomic_store_explicit(&r->live, 0, memory_order_release); atomic_fetch_sub(&g_live, 1); }
pthread_mutex_unlock(&g_slot_mu);
}
// A zero-copy Metal buffer made while any of its pages is read-only drops every GPU write through it, with no error, even to pages never protected and even once its pages are writable again;
// one made over writable pages keeps working when they are protected later (M4 Pro probe; LEGO Star Wars: The Skywalker Saga's font copies inside its 1.4 GB pool, issue #1591). So every
// protected page of [addr, addr + len) is made writable and counts as written (its textures are read again and protected again at their next use, as after a host write), and no protection
// starts until nvn_dirty_unhold: hold, make the buffer, unhold. Protection and pool retirement wait meanwhile; the page-fault path takes no lock and is not held up
void nvn_dirty_hold(const void *addr, size_t len) {
pthread_mutex_lock(&g_slot_mu);
prep_write((void *)addr, len);
}
void nvn_dirty_unhold(void) { pthread_mutex_unlock(&g_slot_mu); }
int nvn_dirty_tracked(const void *addr, size_t len) {
return find_span((uintptr_t)addr, len) != NULL;
}
+2
View File
@@ -6,6 +6,8 @@
void nvn_dirty_add_range(const void *mem, size_t size); // Register a memory pool as a tracked range (the first call registers the page-fault hook and the host pre-write hook)
void nvn_dirty_stat(int *live, int *peak, int *cap); // number of registered memory pools, peak, tracking table capacity (for the memory readout line)
void nvn_dirty_remove_range(const void *mem); // Pool destruction: restore protected pages to writable and mark invalid
void nvn_dirty_hold(const void *addr, size_t len); // Make the covered pages writable (counted as written) and hold off protection until nvn_dirty_unhold: around making a zero-copy buffer the GPU writes through
void nvn_dirty_unhold(void);
int nvn_dirty_tracked(const void *addr, size_t len);
void nvn_dirty_protect(const void *addr, size_t len); // Set the covered pages read-only
void nvn_dirty_protect_sparse(const void *addr, size_t len); // The same, for the pages behind a placement sparse tile: a later write to one moves nvn_dirty_sparse_writes
+30 -6
View File
@@ -675,6 +675,7 @@ static void pool_res(int i) {
enum { BIG_MIN = 512u << 20, BIG_S = 16u << 20, BIG_UNKNOWN = 64u << 20, BIG_MAX = 32 };
typedef struct { uintptr_t lo, hi, a, b; const void *mem; int *chunk, full; NSMutableArray *old; } big_pool; // chunk: stride → g_pools index + 1; full: the whole pool's entry + 1; old: buffers a longer chunk replaced, alive with the pool
static big_pool g_big[BIG_MAX]; static int g_nbig;
static id<MTLBuffer> pool_buf(uintptr_t a, uintptr_t b); // a pool's zero-copy buffer over [a, b), made over writable pages (beside the GPU-written storage spans below)
static int big_of(uint64_t addr) { for (int i = 0; i < g_nbig; i++) if (addr >= g_big[i].lo && addr < g_big[i].hi) return i; return -1; }
void mtl_pool_add(const void *mem, uint64_t size) {
mtl_init(); // the change is recorded once the pool can be found (reg_bump below): a reader that sees the new generation sees the pool
@@ -688,12 +689,12 @@ void mtl_pool_add(const void *mem, uint64_t size) {
pthread_mutex_unlock(&g_mu);
if (k >= 0) { reg_bump(-1, REG_POOL); static int nl; if (nl++ < 8) MLOG("memory pool %p+%llu MB: in chunks, wired as far as lookups reach", mem, (unsigned long long)(size >> 20)); return; }
}
id<MTLBuffer> buf = [g_dev newBufferWithBytesNoCopy:(void *)a length:b - a options:MTLResourceStorageModeShared deallocator:nil];
id<MTLBuffer> buf = pool_buf(a, b);
// Pokémon Legends: Z-A: twice on the Mac a small pool's buffer was refused although its pages were one read-write VM region, both times while another heavy job (a shader compile,
// a second game instance) took the machine's memory; every run on an idle machine created all of them. Wiring the pages may fail under memory pressure: retry for up to about 2 s
for (int t = 0; !buf && t < 12; t++) {
usleep(10000u << (t < 4 ? t : 4));
buf = [g_dev newBufferWithBytesNoCopy:(void *)a length:b - a options:MTLResourceStorageModeShared deallocator:nil];
buf = pool_buf(a, b);
if (buf) MLOG("[RED] memory pool %p+%#llx: the zero-copy buffer was refused, created at retry %d", mem, (unsigned long long)size, t + 1);
}
if (!buf) { // say what the pages looked like: every VM region over the range, with its protection (an unmapped page in the range is the usual cause)
@@ -756,7 +757,7 @@ static void pidx_sort(void) {
qsort(g_pidx, (size_t)g_npool, sizeof *g_pidx, pidx_cmp); g_pidx_ok = 1;
}
static int big_new(big_pool *b, uintptr_t lo, uintptr_t hi, uintptr_t end, uint64_t unk) { // caller holds g_mu: a new entry for [lo, end) of the pool, looked up for addresses in [lo, hi)
id<MTLBuffer> buf = [g_dev newBufferWithBytesNoCopy:(void *)lo length:end - lo options:MTLResourceStorageModeShared deallocator:nil];
id<MTLBuffer> buf = pool_buf(lo, end);
if (!buf) { MLOG("[RED] memory pool %p: the zero-copy buffer over %#lx..%#lx was refused", b->mem, (unsigned long)lo, (unsigned long)end); return -1; }
if (g_npool == g_cap) { g_cap = g_cap ? g_cap * 2 : 64; g_pools = realloc_or_die(g_pools, g_cap * sizeof *g_pools, "the memory pool table"); }
g_pidx_ok = 0; atomic_fetch_add(&g_pool_gen, 1);
@@ -2755,7 +2756,8 @@ static void rb_swap_rows(uint8_t *p, size_t wb, size_t rows, size_t nz, size_t r
}
// A zero-copy buffer over [addr, addr + len) for the open upload batch, which retires it with its staging, for a large pool, or a pool no address was given out in and that is not resident: a
// one-time read must not leave that memory wired. In Ocarina of Time's first scene, pools that hold only textures took 4.6 GB of the working set against 1.6 GB for the textures made from them.
// nil elsewhere (or if it is refused: the caller looks the address up as usual)
// nil elsewhere (or if it is refused: the caller looks the address up as usual). The GPU only reads it, so it is made over the pages the upload has just protected, not through pool_buf,
// which would make them writable again and the texture count as written at once
static id<MTLBuffer> up_big_src(uint64_t addr, uint64_t len, uint64_t *off) {
// Not once the raw memory table holds the whole pool (big_full): the lookup finds that buffer. Ocarina of Time's first scene made 4,664 of these in one batch, 2.1 GB counted against the working set for pages already wired
pthread_mutex_lock(&g_mu); int k = big_of(addr), in = k >= 0 && !g_big[k].full;
@@ -3387,8 +3389,8 @@ static void cpu_tex_drop_pool(const void *pool) {
// part of one cuts it, and the parts outside keep their own stamp, so a CPU write there since stays seen (merging them made the whole merged span the GPU's again). Storage the CPU
// cannot write (a CPU_NO_ACCESS or virtual pool) has no span: tex_cpu_content takes no texture there, and most render targets lie there. GPU writes are stamped when recorded, so a
// command buffer submitted again does not stamp its writes again (open: storage the CPU wrote since counts as the CPU's until the next recorded GPU write there)
typedef struct { uintptr_t lo, hi; uint64_t stamp, seen; const void *rg; int taken; } gws_span; // seen: dirty generation at the last look; rg: the dirty-page range holding its whole pages
// (NULL: none, or untracked); taken: tex_cpu_content took a texture over it since its stamp
typedef struct { uintptr_t lo, hi; uint64_t stamp, seen; const void *rg; int taken, gpu; } gws_span; // seen: dirty generation at the last look; rg: the dirty-page range holding its whole pages
// (NULL: none, or untracked); taken: tex_cpu_content took a texture over it since its stamp; gpu: pool_buf's note
static gws_span *g_gws; static size_t g_ngws, g_cgws; static pthread_mutex_t g_gws_mu = PTHREAD_MUTEX_INITIALIZER;
static _Atomic int g_gws_new; // the GPU wrote storage anew, or wrote storage a texture was taken from, since cpu_unc_drop last looked
static void whole_pages(uintptr_t lo, uintptr_t hi, uintptr_t *a, uintptr_t *e) {
@@ -3515,6 +3517,28 @@ static void gws_take(uintptr_t lo, uintptr_t hi) { // a texture over [lo, hi)
}
pthread_mutex_unlock(&g_gws_mu);
}
// A pool's zero-copy buffer, which the GPU writes through. One made while any of its pages is read-only drops every GPU write through it, silently (nvn_dirty_hold), so it is made over
// writable pages with protection held off meanwhile. A chunk of a large pool is made long after the pool, by when uploads and GPU writes have protected pages in it; a small pool's first or
// last page may be a neighbour's, protected by that pool's texture (issue #1591). The hold counts the pages it makes writable as written, which a packaged texture takes as a reason to be read
// again; storage the GPU wrote would instead count as the CPU's and be taken from guest memory the GPU never wrote. So a span the CPU had not written since its stamp gets its stamp and
// protection back once the buffer is made (open: a CPU write into such a span while the buffer is being made is not seen)
static id<MTLBuffer> pool_buf(uintptr_t a, uintptr_t b) {
pthread_mutex_lock(&g_gws_mu);
size_t i0 = gws_find(a);
for (size_t i = i0; i < g_ngws && g_gws[i].lo < b; i++) {
g_gws[i].gpu = !gws_cpu_since(&g_gws[i], g_gws[i].lo, g_gws[i].hi);
}
nvn_dirty_hold((void *)a, b - a);
id<MTLBuffer> buf = [g_dev newBufferWithBytesNoCopy:(void *)a length:b - a options:MTLResourceStorageModeShared deallocator:nil];
nvn_dirty_unhold();
for (size_t i = i0; i < g_ngws && g_gws[i].lo < b; i++) {
if (g_gws[i].gpu) {
gws_stamp(&g_gws[i]);
}
}
pthread_mutex_unlock(&g_gws_mu);
return buf;
}
static void gws_drop_pool(const pool_t *p) { // the pool goes: its spans with it
if (!p->mem || (p->flags & NVN_MEMORY_POOL_FLAGS_VIRTUAL)) {
return;
+58 -1
View File
@@ -1,6 +1,7 @@
// A large memory pool in chunks (nvn_mtl.m BIG_MIN): a lookup gets a zero-copy buffer that holds what it asked and starts at its stride, so only what lookups reach is wired. The buffers must
// say the same memory as the guest address, a read of unknown extent must have BIG_UNKNOWN past it, a chunk asked for more is lengthened, a texture's upload wires no chunk (up_big_src),
// raw global memory's pool table covers the whole pool (big_full), the pool's removal takes every entry, and a smaller pool stays one buffer.
// raw global memory's pool table covers the whole pool (big_full), the pool's removal takes every entry, a smaller pool stays one buffer, and each kind of pool buffer made over a
// write-protected page still takes the GPU's writes (pool_buf).
#include "../nvn/nvn_mtl.m"
void *front_metal_layer(void) { return NULL; }
module_t *module_of(const void *p) { (void)p; return NULL; }
@@ -21,6 +22,15 @@ static id<MTLBuffer> look(uint64_t a, uint64_t n) {
void *cb = NULL; uint64_t co = 0; CHECK("the CPU lookup agrees", mtl_addr(a, n, &cb, &co) && (uint64_t)(uintptr_t)((__bridge id<MTLBuffer>)cb).contents + co == a);
return b;
}
// A GPU fill of [a, a + n) through the buffer a lookup gives, then whether the guest's memory holds it
static int gpu_fill_ok(uint64_t a, uint64_t n, uint8_t v) {
id<MTLBuffer> b = look(a, n); if (!b) return 0;
uint64_t off = a - (uint64_t)(uintptr_t)b.contents;
id<MTLCommandBuffer> cb = q_cb(); id<MTLBlitCommandEncoder> ce = [cb blitCommandEncoder];
[ce fillBuffer:b range:NSMakeRange(off, n) value:v]; [ce endEncoding]; [cb commit]; [cb waitUntilCompleted];
const uint8_t *p = (const uint8_t *)(uintptr_t)a; for (uint64_t i = 0; i < n; i++) if (p[i] != v) return 0;
return 1;
}
int main(void) { @autoreleasepool {
mtl_init();
const uint64_t GB = 1ull << 30, MB = 1ull << 20;
@@ -150,5 +160,52 @@ int main(void) { @autoreleasepool {
CHECK("the small pool still answers, its entry moved", look((uint64_t)(uintptr_t)small + 20, 16).length == 64 * MB);
CHECK("the large pool's addresses do not", !mtl_gpu_addr(base + 100, 4, &mb, &mo, &gpu));
mtl_pool_del(small); mtl_drain();
// A buffer made while any of its pages is write-protected (nvn_dirty_protect: a packaged texture's upload, an index range) drops every GPU write through it, with no error, even to pages
// never protected (issue #1591). Each kind of zero-copy buffer over pool memory, made over a protected page, must still take the GPU's writes
{
uint8_t *wp = mmap(NULL, GB, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (wp == MAP_FAILED) abort();
uint64_t wb = (uint64_t)(uintptr_t)wp;
mtl_pool_add(wp, GB); nvn_dirty_add_range(wp, GB);
nvn_dirty_protect(wp + 40 * MB, 4096); // a texture's page in the stride the lookup below makes a chunk for
CHECK("a new chunk over a protected page takes GPU writes", gpu_fill_ok(wb + 41 * MB, 4096, 0x5a));
(void)look(wb + 200 * MB, 64); // a short chunk, made over writable pages
nvn_dirty_protect(wp + 220 * MB, 4096); // then a page past its end is protected, and a longer lookup lengthens it over that page
CHECK("a lengthened chunk over a protected page takes GPU writes", gpu_fill_ok(wb + 200 * MB, 32 * MB, 0x6b));
// Storage the GPU wrote (render targets in a CPU-visible pool, mtl_tex_gpu_written) is protected too. A chunk made over it must not make it the CPU's, which would take its textures
// from guest memory the GPU never wrote (PR #1604); storage the CPU wrote since stays the CPU's
{
pool_t wpool = {.magic = MAGIC('P', 'O', 'O', 'L'), .mem = wp, .size = GB, .flags = NVN_MEMORY_POOL_FLAGS_CPU_UNCACHED | NVN_MEMORY_POOL_FLAGS_GPU_CACHED};
tex_t gt = {.magic = MAGIC('T', 'E', 'X', 0), .has_layout = 1, .pool = &wpool, .mem = wp + 400 * MB}, ct = gt;
gt.L.size = ct.L.size = 4 * MB; ct.mem = wp + 440 * MB;
uintptr_t g0 = (uintptr_t)gt.mem, c0 = (uintptr_t)ct.mem;
mtl_tex_gpu_written(&gt); mtl_tex_gpu_written(&ct);
dm_guest_write_prepare(ct.mem + MB, 4096); ct.mem[MB] = 1; // the CPU writes the second after the GPU did
CHECK("GPU-written storage: the GPU's", gws_owned(g0, g0 + 4 * MB));
CHECK("written by the CPU since: the CPU's", !gws_owned(c0, c0 + 4 * MB));
CHECK("a chunk over both takes GPU writes", gpu_fill_ok(wb + 400 * MB, 60 * MB, 0x4e));
CHECK("GPU-written storage stays the GPU's once the chunk is made", gws_owned(g0, g0 + 4 * MB));
CHECK("storage the CPU wrote stays the CPU's", !gws_owned(c0, c0 + 4 * MB));
dm_guest_write_prepare(gt.mem + MB, 4096); gt.mem[MB] = 1;
CHECK("protected again: a CPU write makes it the CPU's", !gws_owned(g0, g0 + 4 * MB));
}
nvn_dirty_protect(wp + 600 * MB, 4096);
mtl_pool_addressed(wp + 700 * MB, 4096);
mtl_sub_begin(); CHECK("pool table over the protected pool", gmem_map_gpu() != 0); finish();
CHECK("the whole-pool buffer over a protected page takes GPU writes", look(wb + 700 * MB, 4096).length == GB && gpu_fill_ok(wb + 700 * MB, 4096, 0x7c));
// Pools are 4 KB aligned and buffers whole host pages: a pool made after its neighbour's texture protected the page they share
uint8_t *two = mmap(NULL, 4 * MB, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (two == MAP_FAILED) abort();
size_t pg = (size_t)getpagesize(), half = pg + 4096;
mtl_pool_add(two, half); nvn_dirty_add_range(two, half);
uint64_t st = nvn_dirty_now(); nvn_dirty_protect(two + pg, 4096); // the first pool's last page, which the second pool starts in
mtl_pool_add(two + half, 2 * MB); nvn_dirty_add_range(two + half, 2 * MB);
CHECK("a pool made over its neighbour's protected page takes GPU writes", gpu_fill_ok((uint64_t)(uintptr_t)(two + half + MB), 4096, 0x8d));
CHECK("the page made writable counts as written: its texture is read again", nvn_dirty_since(two + pg, 4096, st));
st = nvn_dirty_now(); nvn_dirty_protect(two + pg, 4096); // read again and protected: tracked as before (a host write; the test has no fault handler for a CPU one)
CHECK("protected again: unwritten", !nvn_dirty_since(two + pg, 4096, st));
dm_guest_write_prepare(two + pg, 4096); two[pg] = 1;
CHECK("protected again: a write is seen", nvn_dirty_since(two + pg, 4096, st));
nvn_dirty_remove_range(two + half); mtl_pool_del(two + half); nvn_dirty_remove_range(two); mtl_pool_del(two);
nvn_dirty_remove_range(wp); mtl_pool_del(wp); mtl_drain();
}
printf("t_pool_chunks: %d checks, %d failed\n", checks, failed); return failed != 0;
}}
+1
View File
@@ -492,6 +492,7 @@ One line per symptom in the [subsystem references](../reference/): what you see
- `kIOGPUCommandBufferCallbackErrorOutOfMemory` on every command buffer from the first frames, no frame presented, "GPU allocated" near the Mac's memory; `large texture … in a sparse virtual pool` lines name textures of gigabytes. → [Large sparse textures as Metal placement sparse textures](../reference/nvn-objects.md#large-sparse-textures-as-metal-placement-sparse-textures)
- the placement heaps (`sparse tiles: placement heap N`) keep growing through a session, to several times the memory the game maps behind its sparse textures. On a 16 GB M1 Pro, Mario Kart World's race reached 11 heaps (2.75 GB) within three minutes, wired memory 8.7 GB, and the system swapped: frames went from 25 to 50 ms. A GPU write through one place of a page is also not seen at another. → [Physical pages mapped at several places of a placement sparse texture](../reference/nvn-objects.md#physical-pages-mapped-at-several-places-of-a-placement-sparse-texture)
- frames of 100 ms and more every few frames on a Mac short of memory, with no failing command buffer; a Metal System Trace shows the driver wiring and unwiring all the time (3.2 s of a 6 s trace on the game below), and the `restop` line of `DM_CTL` shows gigabytes of shared buffers. → [Large pools wrapped in chunks](../reference/nvn-objects.md#large-pools-wrapped-in-chunks)
- what the GPU copies, fills or renders into a pool never shows, with no error and no red line: garbled text where the game copies its font textures inside one pool. `DM_NVN_POOL_CHUNKS=0` clears it when the buffer is a chunk. → [GPU writes dropped by a pool buffer made over write-protected pages](../reference/nvn-objects.md#gpu-writes-dropped-by-a-pool-buffer-made-over-write-protected-pages)
- GPU memory grows with every scene change (Engage's idle title demo reached 5.4 GB of GPU memory and 3.6 GB resident in 850 s). → [Finalized pools kept alive by residency and the sharing table](../reference/nvn-objects.md#finalized-pools-kept-alive-by-residency-and-the-sharing-table)
- the memory line's `freed but alive` count only grows, while no host table holds those buffers; "GPU allocated" is far above resident memory (Ghost Trick: Phantom Detective, 125 to 146 buffers and 6.6 to 8.7 GB of GPU allocations against 2.2 GB resident). → [Finalized pool buffers kept by a guest thread's autorelease pool](../reference/nvn-objects.md#finalized-pool-buffers-kept-by-a-guest-threads-autorelease-pool)
- GPU and resident memory keep growing during texture streaming while pool, residency and serial-object counts stay nearly flat, with no freed pool buffers alive. → [Finalized textures kept by registered descriptor views](../reference/nvn-objects.md#finalized-textures-kept-by-registered-descriptor-views)
+8
View File
@@ -126,6 +126,14 @@ The game may also write into an NVN object directly, without an NVN call, throug
- **Found on:** [Mario Kart World](../../dm/games/0400C3F00006E000/README.md)'s base game, on a 16 GB M6: the GPU has touched 1,111 MB of its 2,427 MB graphics pool by the first race. Shared buffers in the residency set went from 3,864 to about 1,500 MB, wired memory stayed at 9.3 to 9.8 GB (it swung to 12.7 GB), and the 95th percentile frame of a race went from 33-85 ms to 17-33 ms.
- **Check:** `t_pool_chunks`: a lookup's buffer says the same memory as the guest address, a read of unknown length has 64 MB past it, a chunk asked for more is lengthened, a texture's upload wires no chunk, raw global memory's table covers the whole pool, the pool's removal takes every entry, and a smaller pool stays one buffer.
### GPU writes dropped by a pool buffer made over write-protected pages
- **Symptom:** what the GPU copies, fills or renders into a pool never shows, with no error and no red line: garbled text where the game copies its font textures inside one pool. `DM_NVN_POOL_CHUNKS=0` clears it when the buffer is a chunk.
- **Cause:** a zero-copy Metal buffer made while any of its pages is read-only drops every GPU write through it, even to pages never protected and even once its pages are writable again. One made over writable pages keeps working when they are protected later (probe on an M4 Pro). The dirty tracker protects pool pages after a packaged texture's upload and after an index range is read (`nvn_dirty_protect`). A chunk of a [large pool](#large-pools-wrapped-in-chunks) is made long after the pool, by when uploads have protected pages in its stride; a lengthened chunk and the whole-pool buffer of raw global memory are made the same way; and a small pool's first or last 16 KB page may be shared with a neighbour whose texture protected it.
- **Fix:** every pool buffer the GPU writes through is made by `pool_buf` (`nvn_mtl.m`): `nvn_dirty_hold` (`nvn_dirty.c`) makes the protected pages of its range writable and counts them as written, so their textures are read and protected again at their next use, and holds off protection until the buffer is made. Protection and pool retirement wait meanwhile; the page-fault path takes no lock. [Storage the GPU wrote](#uncompressed-storage-beside-storage-the-gpu-writes) would then count as the CPU's and its textures be taken from guest memory the GPU never wrote, so a span the CPU had not written since its stamp gets its stamp and protection back once the buffer is made. Open: a CPU write into such a span while the buffer is being made is not seen. An upload's own source buffer (`up_big_src`) is only read by the GPU and stays as it was.
- **Found on:** LEGO Star Wars: The Skywalker Saga (`010042D00D900000`, 1.10.0, from a provisional profile with `tex_dirty_upload` on; not in the [games table](../../dm/games/README.md#games); [issue #1591](https://github.com/seedds/nxnative/issues/1591)): all its text garbled since pools came in chunks, correct with `DM_NVN_POOL_CHUNKS=0` and with the reporter's change to `big_new`. Not run here with this fix.
- **Check:** `t_pool_chunks`: a new chunk, a lengthened chunk, the whole-pool buffer and a small pool next to a protected page each take a GPU fill made over a protected page (all four fail before the fix); the page made writable counts as written and is tracked again once protected; and a chunk made over GPU-written storage leaves it the GPU's, and storage the CPU wrote since the CPU's.
### Finalized pools kept alive by residency and the sharing table
- **Symptom:** GPU memory grows with every scene change (Engage's idle title demo reached 5.4 GB of GPU memory and 3.6 GB resident in 850 s).