Repository navigation
util/idalloc: keep sparse allocations within their segment - #1438
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>
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>
Keep both signed allocator commits, the bounded single-ID range regression tests and the current util_tests registration. Signed-off-by: DjDeveloperr <hey@djdev.me>
There was a problem hiding this comment.
Verdict: HOLD at c1740924ba3a
Blockers:
- Complete the exact-head
c1740924ba3ahardware verification noted in the PR body: repeatgl-1.5-gen-buffers-uniqueon J413 and a second Gallium GPU covering both the segment rollover fix and the single-ID range fix (7e3205c449).
Checked:
- Audited the full 3-file diff (
src/util/u_idalloc.c,src/util/tests/u_idalloc_test.cpp,src/util/meson.build,+100/-21,MERGEABLEagainstaurora-wip):util_idalloc_try_alloc()boundsnum_elementsand growth (MIN2(MAX2(num_elements, 1) * 2, max_elements)) tomax_elements, advanceslowest_free_idx, and returnsfalsewheni >= max_elementsinstead of growing a full segment's bitmap.util_idalloc_sparse_alloc_range()delegatesnum == 1toutil_idalloc_sparse_alloc(), closing the single-ID range rollover gap while keepingutil_idalloc_alloc()semantics unchanged.- Parameterized
idalloc_sparsegtest (u_idalloc_test.cpp) covers bothalloc()andalloc_range(..., 1)across allocated-tail and reserved-tail rollover and tail reuse; all 4 tests passed on the carrier build.
Evidence
- Head:
c1740924ba3a383750c6c0b40affe88ba2cfea96(baseaurora-wip,MERGEABLE, carries signed commits0a7f4b2e93and7e3205c449cleanly). - No code defects found; ready to approve once exact-head Piglit
gl-1.5-gen-buffers-uniquerows are posted.
|
Merge readiness at
Areas: none matched in CODEOWNERS Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
There was a problem hiding this comment.
Verdict: MERGE at c1740924ba3a
Converts this App's earlier review at the same head to an approval under the 12-01 merge bar (better than before and doesn't break; block only on a shown failure). No code blocker was found in it. The merge gate (a row on one Mac at this head + fast CI) is tracked by pr-readiness, not held here.
Checked: - Audited the full 3-file diff (src/util/u_idalloc.c, src/util/tests/u_idalloc_test.cpp, src/util/meson.build, +100/-21, MERGEABLE against aurora-wip):
util_idalloc_try_alloc()boundsnum_elementsand growth (MIN2(MAX2(num_elements, 1) * 2, max_elements)) tomax_elements, advanceslowest_free_idx, and returnsfalsewheni >= max_elementsinstead of growing a full segment's bitmap.util_idalloc_sparse_alloc_range()delegatesnum == 1toutil_idalloc_sparse_alloc(), closing the single-ID range rollover gap while keepingutil_idalloc_alloc()semantics unchanged.- Parameterized
idalloc_sparsegtest (u_idalloc_test.cpp) covers bothalloc()andalloc_range(..., 1)across allocated-tail and reserved-tail rollover and tail reuse; all 4 tests passed on the carrier build.
Follow-ups (not blocking): exact-head gl-1.5-gen-buffers-unique on J413 (2nd GPU not required)
|
Row:
|
|
Merge train status at Still owed:
|
|
J700 (G17P) row: mesa#1438 · J700 MacBook Neo (A18 Pro, G17P B1), stock Fedora 44 7.3.0-41.fc44.aurora.aarch64, same boot, base 8b59f2b vs head c174092: PASS — glnames (4456448 names via glGenBuffers(99991) across the 2^22 segment boundary): base returned name 4194304 twice (1 duplicate); head all unique, objects/delete/teardown clean; 1438-gles3 991/991 compared, base 991 Pass → head 991 Pass, 0 status changes; 0 GPU faults, 0 kernel WARNINGs; stock handback verified. Kit B payload |
|
Row:
|
satchlj
left a comment
There was a problem hiding this comment.
Verdict: MERGE
Blockers: none.
Checked:
src/util/u_idalloc.c:util_idalloc_try_alloc()bounds both the scan (MIN2(buf->num_elements, max_elements)) and growth (MIN2(MAX2(num_elements, 1) * 2, max_elements)) to the segment limit, advanceslowest_free_idxsafely without overflowing, and returnsfalsewhen full soutil_idalloc_sparse_alloc()moves cleanly to the next segment.util_idalloc_sparse_alloc_range()delegatesnum == 1toutil_idalloc_sparse_alloc(), closing the single-ID range rollover bug. Plainutil_idalloc_alloc()keeps its2^32capacity with explicit exhaustion abort.src/util/tests/u_idalloc_test.cpp+src/util/meson.build: parameterized GoogleTest suite covers bothutil_idalloc_sparse_allocandutil_idalloc_sparse_alloc_range(..., 1)across allocated-tail and reserved-tail segment boundaries plus tail reuse. (Non-blocking note:u_idalloc_test.cppcarriesSPDX-License-Identifier: GPL-2.0-only; fine for a standalone test binary sincelicenses/GPL-2.0-onlyexists in the tree, though switching it toMITin a follow-up would match the rest ofsrc/util/tests/.)- Clean merge state (
MERGEABLE), PR metadata complete (What/Tested/Risk/Not yet), fork ARM64 Asahi build and test CI passed (46830114864), and exact-headc1740924ba3ahardware PASS rows across three generations: J615 (M3, 3,828 Vulkan CTS Pass->Pass), J700 (A18 Pro, reproduced the base4194304duplicate bug and verified fixed on head + 991/991 GLES3 CTS), and J773g (M4,test_gen_buffers_uniquePASS + 1,286 GL/GLES CTS 0 diffs + Vulkan verify).
Evidence
- Audited full 3-file diff (
+100/-21) atc1740924ba3aalongside surroundingutil_idalloc_resize()andutil_idalloc_sparse_*()helpers insrc/util/u_idalloc.c. - Verified fork ARM64 CI pass (
https://github.com/DjDeveloperr/mesa/actions/runs/46830114864) and exact-head hardware receipts on J615 (#issuecomment-7331454035), J700 (base repro -> head fix), and J773g.
|
Local CI on the merge tree (hosted Actions is off, so this stands in for the Arm64 Asahi build-test job). Head
The J773g and J700 Gallium rows at this head are linked under Tested. Merging at |
What: The sparse ID allocator (
util_idalloc_sparse, used for GL object names insrc/mesa/main/hash.c) now bounds single allocations and one-ID ranges to the current segment before moving to the next, so a range can no longer run past a segment's end. This carries Ryan Murray's two signed commits from #842, including the single-ID range fix. The first parent is7e3205c449e0and the second isaurora-wipat8b59f2b0a70e. The allocator implementation and its regression fixture are byte-identical to the original head, and both commits keep their IDs and sign-offs.Tested: The allocator object and its regression test built in a warm Mesa build, and all four sparse rollover and range tests passed. J615 (MacBook Air M3, G15G) at this head: Vulkan memory, object-management and timeline-semaphore CTS lists matched the merge base with 0 GPU faults (row). The original J413 Piglit run covered the first fix only. Gallium GL at this head, same-boot A/B against the merge base with 0 GPU faults: J773g (M4 Mac mini, G16G) matched on 1,286 GL/GLES object-name and buffer CTS cases (0 diffs) and passed a sparse
glGenBuffersname-uniqueness check (row), and on J700 (MacBook Neo, G17P) 4,456,448glGenBuffersnames across the 2^22 segment boundary are all unique (the base hands out 4194304 twice) with 991/991 GLES3 cases unchanged (row).Risk: two-way door · all Macs: GL object names go through the sparse allocator, and the plain
util_idalloc_alloc()it now shares a helper with is used across Gallium (for example resource and buffer IDs). Its search and growth are unchanged apart from the new exhaustion abort.Not yet: nothing owed for merge.