upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/xmem.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-26 10:05:43 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-26 10:05:43 -0500
commit4a6a8a633e71ceb5af7afbaadcf9ad2e4ba9a377 (patch)
tree711e71b9a2c47b22c2775d152380c3df48c1a9c3 /runtime/shims/xmem.cpp
parent1f7cbeff9a0461c037287e83297e9add75d2646a (diff)
xmem: read LEONIDA_GEOMETRY_REMAP_RELEASE once, with a test seam to read it again
GetEnvironmentVariableA at every remap ran under g_phys_mutex in every scatter call; with it, xmem_test's split race ("the reader of the views' last pages never faults or misreads") failed in two full Wine runs in a row, where main passed it twice. The value is cached as before #2350's default changed; rt::xmem::reload_remap_release_setting lets test_remap_releases switch it. Two full runs since: no change against main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/xmem.cpp')
-rw-r--r--runtime/shims/xmem.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/runtime/shims/xmem.cpp b/runtime/shims/xmem.cpp
index 0d982be4b..d6d6f408c 100644
--- a/runtime/shims/xmem.cpp
+++ b/runtime/shims/xmem.cpp
@@ -1044,10 +1044,16 @@ thread_local const char* t_unmap_cause = "unmap";
1044// using what names it, and some of what names a copy's address is never rewritten when the copy is retired (a root 1044// using what names it, and some of what names a copy's address is never rewritten when the copy is retired (a root
1045// view a list resolved while it was recorded, executed after the retirement; a placed buffer view written outside a 1045// view a list resolved while it was recorded, executed after the retirement; a placed buffer view written outside a
1046// console heap). On by default, it freed copies under such views: a GPUVM page fault and a lost device about 40 s 1046// console heap). On by default, it freed copies under such views: a GPUVM page fault and a lost device about 40 s
1047// into the world on an RX 7900 XTX. Read at every remap, so a test can switch it. 1047// into the world on an RX 7900 XTX. Read once; rt::xmem::reload_remap_release_setting reads it again (for a test).
1048std::atomic<int> g_remap_releases{-1};
1048bool remap_releases_enabled() { 1049bool remap_releases_enabled() {
1049 char value[2]{}; 1050 int on = g_remap_releases.load(std::memory_order_relaxed);
1050 return GetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", value, sizeof(value)) == 1 && value[0] == '1'; 1051 if (on < 0) {
1052 char value[2]{};
1053 on = GetEnvironmentVariableA("LEONIDA_GEOMETRY_REMAP_RELEASE", value, sizeof(value)) == 1 && value[0] == '1';
1054 g_remap_releases.store(on, std::memory_order_relaxed);
1055 }
1056 return on != 0;
1051} 1057}
1052struct RemapReleases; 1058struct RemapReleases;
1053thread_local RemapReleases* t_remap_releases = nullptr; 1059thread_local RemapReleases* t_remap_releases = nullptr;
@@ -2423,6 +2429,8 @@ bool host_page(std::uintptr_t address, HostPage& out) {
2423 2429
2424namespace rt::xmem { 2430namespace rt::xmem {
2425 2431
2432void reload_remap_release_setting() { g_remap_releases.store(-1, std::memory_order_relaxed); }
2433
2426void note_stream_reservation(uintptr_t base, size_t size, uintptr_t caller_rva) { 2434void note_stream_reservation(uintptr_t base, size_t size, uintptr_t caller_rva) {
2427 if (caller_rva != 0x1e1d00f && caller_rva != 0x1e1d03e) return; 2435 if (caller_rva != 0x1e1d00f && caller_rva != 0x1e1d03e) return;
2428 const std::lock_guard physical(g_phys_mutex); 2436 const std::lock_guard physical(g_phys_mutex);