mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-20 04:35:57 +00:00
Wait out a short out-of-memory spell instead of ending the game
Crash logs ended in fatal errors when the system's commit ran out for a moment: a staging buffer (-2), a guest commit with the system at 24442 of 24447 MB, image creation (-2). Windows grows a system-managed page file and some drivers charge device memory to the process commit, so the same request often succeeds a moment later. oom.c holds the wait nvn_api_cmd.c realloc_wait already used: it requests a release, retries every 10 ms for up to 30 s, logs the first 8 with the commit numbers. rt_oom_request sets a flag that vk_texture_new_submit takes (one atomic load per submit): it drops up to 256 released textures of the two kinds sweep_pressure drops (overwritten, clean mirrored), never GPU-written content, and frees the headroom blocks. vk_oom_release does at once what needs no submit: headroom blocks, finished upload batches and deferred objects. - memory.c commit: waits and retries without frz_lock between tries; every caller waits, boot ones too. - vk_staging and the draw-data chunks (vk_exec_draw.c scratch): release, then wait; the open upload batch is not submitted, its caller still records into it. - create_tex: release and one retry; no wait under the texture lock, the texture is asked for again at its next use. - the texture write-back buffer: release, then wait. - the headroom thread keeps no spare block for 30 s after a failure. TOTK_TEST_OOM=<site>:<n> (commit, staging, image, chunk) fails the first n attempts; probe-kernel forces 3 refused commits, probe-vkexec 2 staging buffers, 1 image and 1 chunk, and both pass through them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5e479f593b
commit
213bc6af6a
13 files changed
+323
-32
No files matched your search
@@ -682,6 +682,25 @@ static int cmp_u64(const void *a, const void *b) {
|
||||
return x < y ? -1 : x > y;
|
||||
}
|
||||
|
||||
// A refused commit waits and retries (memory.c commit, oom.c rt_oom_wait): three forced refusals, then the page maps.
|
||||
static void test_oom_commit(void) {
|
||||
const RtGuestLayout *g = mem_layout();
|
||||
uint64_t a = g->alias.base + g->alias.size - 0x10000;
|
||||
rt_oom_force(RT_OOM_COMMIT, 3);
|
||||
uint64_t t0 = plat_now_ms();
|
||||
uint32_t r = mem_map_physical(a, 0x1000);
|
||||
uint64_t ms = plat_now_ms() - t0;
|
||||
CHECK(r == 0 && rt_oom_forced_left(RT_OOM_COMMIT) == 0 && ms >= 20,
|
||||
"MapPhysicalMemory after 3 refused commits: result %#x, %d refusals left, %llu ms", r,
|
||||
rt_oom_forced_left(RT_OOM_COMMIT), (unsigned long long)ms);
|
||||
rt_oom_force(RT_OOM_COMMIT, 0);
|
||||
if (r == 0) {
|
||||
*(volatile uint64_t *)(uintptr_t)a = 1;
|
||||
CHECK(mem_unmap_physical(a, 0x1000) == 0, "UnmapPhysicalMemory after the refused commits");
|
||||
}
|
||||
printf("oom: commit waited %llu ms through 3 refusals\n", (unsigned long long)ms);
|
||||
}
|
||||
|
||||
static void test_platform(void) {
|
||||
PlatThread *t = plat_thread_new(plat_worker, (void *)(intptr_t)1, "probe-kernel plat");
|
||||
CHECK(t, "plat_thread_new");
|
||||
@@ -792,6 +811,7 @@ int probe_kernel(void) {
|
||||
return 1;
|
||||
}
|
||||
test_platform();
|
||||
test_oom_commit();
|
||||
test_crash_report();
|
||||
kern_run_on_guest_main(probe_main);
|
||||
RtStats s = rt_stats();
|
||||
|
||||
Reference in new issue
Block a user