Repository navigation
util/idalloc: keep sparse allocations within their segment - #842
2 commits merged into
Conversation
The lowest-free word can still point to a full final word. If a scan finds no free bit, the dense allocator grows beyond the segment and returns an ID belonging to the next segment. Freeing that ID then clears a different bitmap. Bound the single-ID search and growth to the segment. If all its words are full, continue to the next segment and let free lower the search hint when space becomes available again. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
RyanTheTide
left a comment
There was a problem hiding this comment.
The single-ID fix is sound at 0a7f4b2e93e96. I compiled the exact allocator and its parent with GCC and Clang under ASan/UBSan. Both compilers reproduced the duplicate rollover ID on the parent. The PR returned 4,194,304 and 4,194,305 in order, and the released tail was reusable.
One-ID callers through _mesa_HashFindFreeKeyBlock(table, 1) still reach the unbounded dense allocation via util_idalloc_sparse_alloc_range(). Shader and program creation use this form. On a full first segment, it temporarily allocates in the wrong segment, rolls back and returns the correct ID from the next segment. The first segment's bitmap stays at 262,144 words, twice its 131,072-word limit.
Routing num == 1 to util_idalloc_sparse_alloc(buf) at the start of the sparse range function closes that path. With that change, both compilers passed both entry points, kept the first bitmap at 131,072 words and reused the freed tail. The recorded J413 A/B covers the original duplicate-ID fix. A same-revision non-G14 Gallium smoke remains open.
A one-ID range request still used the dense allocator directly. At a full sparse segment it grew that segment bitmap from 131072 to 262144 words before backing off to the next segment. Route one-ID range requests through the bounded sparse allocator. Test allocated and reserved segment tails through both single-ID entry points, checking bitmap bounds, distinct IDs, freeing and tail reuse. Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
|
Added 7e3205c: bound sparse single-ID range allocations (the growth bug in the single-ID range path), with four regression cases. All 19 Meson util tests pass. Ready to undraft once CI is green. |
|
Opened #1438 with both signed allocator commits unchanged and aurora-wip merged. All four sparse allocator rollover and range tests passed on the carrier. J413 and a second Gallium GPU still need the current one-ID range fix checked with gl-1.5-gen-buffers-unique. |
Problem
The sparse allocator can return the same buffer name twice when allocation crosses a segment boundary. Piglit's buffer-name test reports success before Mesa crashes in context cleanup.
Change
Bound the search and bitmap growth for a single allocation to the current segment. Continue to the next segment when the first is full. The change applies to Mesa's shared allocator.
Testing
J413 MacBook Air, Apple M2 G14G, Linux 7.3.0-aurora-fleet85. Both arm64 Mesa builds use the same configuration and report OpenGL 4.6. Piglit edf7738, same surfaceless EGL command, three runs per arm.
efabab38502dc32302a058503231b12e815a21f90a7f4b2e93e961c63dfe7b70a1338de04055d21fBoth arms reported the Apple M2 renderer. There were zero GPU errors or SELinux denials in the A/B capture and zero failed units at production verification. Timing includes the baseline's signal exit, so the table documents the runs without a speed claim.
Still to run
Repeat the same-revision Piglit row and a GL smoke on a second Mesa Gallium GPU. The J413 result covers G14G.
Test commands and allocator checks
The aarch64 builds shared the same EGL loader and process-local dependencies. Each run loaded its matching Gallium library. The test command in each environment was
PIGLIT_PLATFORM=surfaceless_egl EGL_PLATFORM=surfaceless gl-1.5-gen-buffers-unique -auto -fbo. The workload is in Piglit.Host checks compiled the unmodified and changed allocator. Across sequential and reserved-tail allocations, the old allocator returned ID 4,194,304 twice and retained an ID after free. The change returned 4,194,304 and 4,194,305 in order, retained zero after free and reused the released tail in both cases.