Repository navigation
st/mesa: harden the shader cache paths of the locked link - #366
Conversation
Merge train (batch 1): independent reviewVerdict: CLEAN WITH NITS. Independent code-only review (Opus 5.5, xhigh), no blocker or major.
Reach: GL common code only (st/mesa + GLSL), every chip's GL; no Vulkan change. Default behaviour unchanged. Train plan: batch 1 = #366, #564, #565, #446 on aurora-wip 4596393. Gates: host build + |
|
Merge-train status (02:4x): held for its Neo (G17P) row. The independent review is clean with nits, posted above. This PR reaches the A18 Pro (G17P), so per the train's rule it merges only after both of these:
The Neo has been offline since about 02:04 (it idle-suspended and needs a physical wake), so its row can't run until it is back. Everything else for this PR will be ready by then. G17P owners' rows (A18 Pro / M4 Pro / M4 Max) on the head above would unblock it sooner. |
b4e2c39 to
81be996
Compare
|
Merge train: rebased onto aurora-wip afcc08b (conflict-free; authorship kept). Head b4e2c39 -> 81be996.
|
RyanTheTide
left a comment
There was a problem hiding this comment.
No blockers. I read the change on 81be996 together with the lock helpers in shaderobj.c and the caller in shaderapi.c. The key-count fix is correct: the key copy and its count are now taken together while the shaders are locked, so the metadata write can no longer read past the copy. In the fallback, the lock handling holds up. _mesa_unlock_attached_shaders() is safe to call twice, and _mesa_link_program always unlocks after st_link_shader(). So a failed relock (count 0) or a relink that fails while holding the locks leaves nothing locked. link_shaders_init() sets LinkStatus back to success before the compile checks, so st_relink_uncached() does return the real status. The earlier independent review's minor point and nits still apply to this head unchanged. I have two things to add:
-
src/mesa/state_tracker/st_glsl_to_nir.cpp:444-465: the SPIR-V mixing check from that review costs only one line here. After the relock, mark the link failed if any attached shader hasspirv_dataset, asst_link_shader()does:linker_error(prog, "not all attached shaders have the same SPIR_V_BINARY_ARB state"). That also keeps_mesa_glsl_compile_shader()away from a shader with no GLSL source. It closes the one race the unlocked window opens, without restructuring the front end. -
Evidence: no hardware run of this head is listed yet (the re-gate is "queued"). The meson suites never reach the cache-hit path. The
assertat:488also means debug builds stop before the fallback, so only the release-build cache-hit unlock is tested. To exercise the changed path, run the re-gate twice on one freshMESA_SHADER_CACHE_DIR(cold, then warm) with a release build. In the warm run every link takes theLINKING_SKIPPEDbranch, which this PR rewrote.
Hardware row: M1 Pro (G13S) or M2 (G14G) GL, release build, base afcc08b against head. Run dEQP-GLES2.functional.shaders.*, dEQP-GLES3.functional.shaders.* and KHR-GL46.gl_spirv.* twice each with MESA_SHADER_CACHE_DIR pointing at a new empty directory and MESA_GLSL_CACHE_DISABLE unset, then dEQP-EGL.functional.sharing.gles2.multithread.* 50 times on the warm cache. Pass: identical results to base on both runs, the second run reports cache hits (MESA_GLSL=cache_info), and there are no hangs or crashes.
Assisted-by: LLM (Claude:Opus 5.5)
Two follow-ups to the per-shader link locks: - The cache metadata write took its key copy, made while the attached shaders were locked, but sized it from the program's current shader count. Pass the number of copied keys along with them. - A link that hits the disk cache releases the shader locks before it rebuilds the program from the cache, which relies on that rebuild always succeeding. Assert that, and if it ever fails, lock the shaders again and link from source as on a cache miss instead of running the link front end without the locks. shader_cache's recompile of the shaders a cache hit skipped is now exported as shader_cache_compile_shaders() for that fallback. Signed-off-by: Diljit Singh <hey@djdev.me>
81be996 to
1dbbb94
Compare
|
Merge train: rebased onto aurora-wip 7ba2957 (#595, the CI fix that installs the GLVND EGL dispatcher, so the asahi job's EGL priority tests pass), conflict-free, every commit identical, authorship kept. New head 1dbbb94. A mirror |
|
T8140 (MacBook Neo J700, A18 Pro, G17P B1) merge-train batch 2 row ( Setup:
Results:
Assisted-by: LLM (Google:Gemini 4 Neon) |
|
Merged into M5 Pro (J714s, G17S B1) verification row
Assisted-by: LLM (Google:Gemini 4 Neon) |
Follow-up to #356 (per-shader link locks). These are two hardening items for the shader cache paths; behaviour does not change in any case that occurs today.
Change
st_load_nir_from_disk_cache()cannot fail once the program metadata was restored.shader_cache's recompile of skipped shaders is exported asshader_cache_compile_shaders()for that fallback.Testing
meson test --suite asahi: 137 ok, 0 fail.meson test --suite glsl --suite glcpp --suite mesa --suite st_mesa: 185 ok, 0 fail.sharing.gles2.multithread.*, a multi-processprograms.linkstress, the GLES2/3/31 shader query/linkage/negative groups andKHR-GL46.gl_spirv), queued.🤖 Generated with Claude Code